Download MetaTrader 5

EA for Binary Options

To add comments, please log in or register
Loite27
16
Loite27  

Hi community.

I am new to MQL4. I am currently developing an EA to operate with binary options. After a few months of work and checking the reference and forum I have come to the conclusion that there is no course of action left for me but to ask here if someone can help me solve my issue.

My investment strategies rely on operating with extreme precision on the close of a bar. Ex: if a bars price closes over previous bar close, order a sell. In order for my strategy to work I need to operate almost exactly when the bar closes in broker's server. I have tried three diferent approaches to achieve this:

  1. Classic solution proposed in forum to figure out when a bar closes. On every tick, check for Time[0] to see if this is a new bar and operate then. The problem with this solution is that I sometimes have delays of many seconds which completely ruins my strategy.
  2. Set timers. I tried setting up a timer synchronized with server time but the issue with this is that synchronization does not seem to work very well and some of my orders ar sent down to a second before a bar closes and some of them up to a second after. This also ruins my strategy because many times the EA is making a decission with incorrect information.
  3. Continuos timer. Finally, I also tried running a timer every 5 miliseconds and execute the decission making proccess when local clock assumes that server´s clock variation is enough to make a bar close. This brought up the same issues than solution 2.

To sum up. I would need a way to run in perfect sync with server time. I checked that MQL5 has a function for this but saddly I can´t use it due to my broker. Can anyone please help me?

Thanks a lot!

Alain Verleyen
Moderator
33611
Alain Verleyen  

If you want coding help show your attempt.

What precision do you need ? Timer is not working reliably with 5 milliseconds, minimum precision is around 16 ms.

Loite27
16
Loite27  
Alain Verleyen:

If you want coding help show your attempt.

What precision do you need ? Timer is not working reliably with 5 milliseconds, minimum precision is around 16 ms.


Thanks Alain,

I´ll attach the code version that I am currently testing. It corresponds to the continuos timer solution I referred to in my original question. Don´t worry it´s only a few lines long. My code is pretty simple.

Regarding precission, I would need to test it. Maybe 16 ms is good enough.

Another thing I realized is that my code is throwing "correct orders" when I run it on a 1 minute timeframe. By correct orders I mean that conditions set on my strategy (RSI and BB) are met before ending an order. When I test this same code on other timeframes, I can´t figure out why but EA throws orders when conditions on RSI are not necessarily met.

Please let me know if there is any more information I can provide to help you help me.

Thanks a lot again!

Files:
whroeder1
16306
whroeder1  
Loite27: The problem with this solution is that I sometimes have delays of many seconds which completely ruins my strategy. This also ruins my strategy because many times the EA is making a decission with incorrect information.
If there has been no tick, there is no new bar. Nothing has changed. Why does nothing ruin your strategy? What incorrect information?
Loite27
16
Loite27  
whroeder1:
If there has been no tick, there is no new bar. Nothing has changed. Why does nothing ruin your strategy? What incorrect information?


Hi wroeder1, thanks for your reply.

Remember that I am trying to create an EA for binary options. Let's say I'm investing in a 1 minute timeframe. My strategy is to place an order (if certain conditions are met) as soon as the bar closes, in order to compare Close[1] with Close[0] when 60 seconds pass. (or something as close as possible to those values). The issue with maybe 5 seconds of no tick before placing an order is that I would be comparing Close[1+5s] vs Close[0+5s] and there is no way in which I can predict that behaviour to create a reasonable investment strategy. 

This is because of two reasons:

  1. I don't have that information on history in MT4 to run a backtest
  2. The time lapsus in which the first tick comes is a random variable

I am currently studying different strategies comparing always Close[i] with Close[i-1] obtained from MT4 history.

Thanks for your interest in my issue, if there are any more questions please let me know!

Loite27
16
Loite27  

Hi everyone,

Just trying to revive this post.. Anyone with any cool ideas?

Thanks!

To add comments, please log in or register