Adding SL, BE and TS to all trades triggered by signal provider?

Back to topics list To post a new topic, please log in or register
avatar
4
gdtrade 2016.04.07 06:34
 

Hi, 

Looking for some advice here. I'm trying to figure out how to automatically add SL, BE and TS to trades in MT4 that are triggered by a signal provider . I found a bunch of scripts that do this, but they need to applied to a chart, a currency pair, and I don't know how to apply it to a signal provider without knowing ahead what currency pair will be traded by the signal provider. Can this be accomplished?

 Thank you.

 George 

avatar
1197
FMIC 2016.04.07 14:18 #
 

Firstly, I have to say that since I have never used "Signals", I don't know if that is allowed or not - that is, if the system allows you to directly change S/L or T/P of a signal order.

So, depending on that condition, one could do it in one of two ways.

  • If the condition is allowed, then an "EA" or "Script" attached to any chart, could use the functions "OrdersTotal()", "OrderSelect()" to find all open orders (irrespective of symbol or magic number) and manage them in accordance to your rules by using "OrderModify()".
  • If however, there are restrictions in place for Signal Orders, but if closing an order is still allowed, then you could still use "OrdersTotal()", "OrderSelect()", but you would have to keep track of stops virtually in arrays (or array of a structure) and then use "OrderClose()" to close an order when the "OrderClosePrice()" hits the virtual S/L, T/P or T/S. This is somewhat more complex but possible, provided you are allowed to close signal orders on your side.

In essence, an "EA" or "Script" has access to all information irrespective of the chart it is attached to but they work slightly differently and so the code would have to be handled differently between an EA and a Script. I think that an "EA" attached to a busy Symbol, such as "EUR/USD" would be best because the "Tick Event" would happen more often and that is when your code would execute. A "Script", would have to run continuously in a loop to keep track of things and would obviously be more "CPU" intensive than an "EA", but both can do the job.

avatar
4
gdtrade 2016.04.07 17:12 #
 

FMIC,

Thank you for your response.

I think a "script" would be a better option here because then I wouldn't have to rely on the "busy" symbol being busy all the time. Not 100% reliable as a trigger method for all pairs.

I generally understand the technique you suggested. I am fairly certain that the signal provider  allows for direct change of a signal order. But even if they don't, I like your method of keeping an array of active trades and their various order points. It's just programming.

I am not very familiar with the scripting language tor MT4, or how to get started on that... could you maybe point me toward some resources? I write other code almost every day, so I just need to learn the syntax, and the mechanics of MT4.

 

Thanks! 

avatar
1197
FMIC 2016.04.07 18:44 #
 

As for the EA, it can also have a "Timer Event" and not just the "Tick Event", which allows for it to be called every "x" seconds, or every second if need be.

For a beginner at MQL4+, I can say that it is going to take same work and time for you to achieve this, but here are some of the links (also found on page header):

Also, there is plenty of example code in the Code Base (https://www.mql5.com/en/code/mt4)

avatar
4
gdtrade 2016.04.07 21:01 #
 
Great, thank you for your help.
avatar
Moderator
3404
GumRai 2016.04.07 21:43 #
 

gdtrade, there is no need to name the signal provider that you intend to use. I have removed the references to them.

Do it again, and it may be considered advertising, which is not allowed here.

avatar
4
gdtrade 2016.04.08 06:17 #
 

OK, sorry. I only mentioned it because I thought it may be relevant to what I was trying to do. I'm new to this. 

Thanks. 

Back to topics list  

To add comments, please log in or register