I need some help to formulate a code which will close the order exactly at the bar's end.It is for a special scalper EA, so it needs pinpoint precision.Let me illustrate what i mean:

Here you can see for example an M15 EUR/USD chart.Now imagine if i had any indicator that took me into a long trade right at the open of the candle marked X, so it went up then a bearish candle followed, with a low very low, but that doesnt matter, what matters it that based on my calculations, the optimal exit here would be the close point of the bar marked 1.The tricky part is that i dont know how to close the order at the close price of bar nr 1, and here i need help!

The best solution that i could think of for now is this (in case of this imaginary BUY trade):

This code closes the buy trade exactly at the Open[0], but not the Close[1].You see, because if you look on the picture and check the bar marked 2, you can see that the bar 2 did not opened at that price as the previous one closed it opened at a slightly different price.And sometimes a huge gap happens like here:

So experience tells that:

Close[1] != Open[0]

In very rare situations it is.So this is why i need the order to be closed right at Close[1].

The one feasable solution i though is that by counting the time, for example this is M1 and M15 chart, count the number of seconds either 60 for M1 or 900 for M15 in either case and close the order at seconds 59 or 599.The problems with this is that ticks are 6 seconds i guess (correct me if i`m wrong) and you cant precisely hit that because because of this time problem and additional slippage problem you might close the trade way after the bar closes.

So let's recap my question is this possible to count the time just like i described above, if yes then how to evade the slippage and tick lagging problem?

Or if you come up with other solutions how to close the order right at Close[1] and not Open[0] then i`m open to it.Please help me with this, this is a very important problem of my EA!

Hi

I work with binary option and this problem its very problemátic.

I resolved this problem installing a tick simulator like M4TICKER35 with tick interval 500ms and making my EA líke this...

...

...

If ( TIMESECOND (TIMECURRENT ())=59 ;

...

...

You can operate with close [0] in the sec 59 asuming this value its the same Open [0] in the New bar

And making the ea without bars counts, only with time and work

Proximus:I need some help to formulate a code which will close the order exactly at the bar's end.It is for a special scalper EA, so it needs pinpoint precision.Let me illustrate what i mean:

Here you can see for example an M15 EUR/USD chart.Now imagine if i had any indicator that took me into a long trade right at the open of the candle marked

X, so it went up then a bearish candle followed, with a low very low, but that doesnt matter, what matters it that based on my calculations, the optimal exit here would be the close point of the bar marked1.The tricky part is that i dont know how to close the order at the close price of bar nr 1, and here i need help!The best solution that i could think of for now is this (in case of this imaginary BUY trade):

This code closes the buy trade exactly at the Open[0], but not the Close[1].You see, because if you look on the picture and check the bar marked

2, you can see that the bar2did not opened at that price as the previous one closed it opened at a slightly different price.And sometimes a huge gap happens like here:So experience tells that:

Close[1] != Open[0]In very rare situations it is.So this is why i need the order to be closed right at Close[1].

The one feasable solution i though is that by counting the time, for example this is M1 and M15 chart, count the number of seconds either 60 for M1 or 900 for M15 in either case and close the order at seconds 59 or 599.The problems with this is that ticks are 6 seconds i guess (correct me if i`m wrong) and you cant precisely hit that because because of this time problem and additional slippage problem you might close the trade way after the bar closes.

So let's recap my question is this possible to count the time just like i described above, if yes then how to evade the slippage and tick lagging problem?

Or if you come up with other solutions how to close the order right at Close[1] and not Open[0] then i`m open to it.Please help me with this, this is a very important problem of my EA!

Hi

I work with binary option and this problem its very problemátic.

I resolved this problem installing a tick simulator like M4TICKER35 with tick interval 500ms and making my EA líke this...

...

...

If ( TIMESECOND (TIMECURRENT ())=59 ;

...

...

You can operate with close [0] in the sec 59 asuming this value its the same Open [0] in the New bar

And making the ea without bars counts, only with time and work

You need al good pc with good ammount of memory

I hope help You!

Sorry my bad english