How to Code a Stoploss at Low of Current Candle(0) at time of entry for EA?

 

Hi all,

I'm trading using a breakout retracement setup that involves setting a stoploss at the low of the current candle (0) at the time of entry.

To be more clear, once I get a signal, I set a buystop at the the high of the previous candle (1) and wish to put my stoploss at the current low of the candle being formed to be triggered when the buystop is triggered.

So once the buystop gets hit, the stoploss is also entered at the same time. This means that the stoploss will vary, and can get wider with price moving lower in the current candle before the buystop is hit.

Picture attached for clarification (please excuse my terrible labels)

How do you code something like this? I'm completely lost.

Files:
 
jreedman5:

Hi all,

I'm trading using a breakout retracement setup that involves setting a stoploss at the low of the current candle (0) at the time of entry.

To be more clear, once I get a signal, I set a buystop at the the high of the previous candle (1) and wish to put my stoploss at the current low of the candle being formed to be triggered when the buystop is triggered.

So once the buystop gets hit, the stoploss is also entered at the same time. This means that the stoploss will vary, and can get wider with price moving lower in the current candle before the buystop is hit.

Picture attached for clarification (please excuse my terrible labels)

How do you code something like this? I'm completely lost.

I am not sure if I've understood you or not!

Let me answer (at least) what I've understood, 
while you have only pending orders placed by your EA with a magic number then:
1- inside the OnTick() main function make a loop using the operator "for" to detect the number of executed market orders having same magic number with stoploss=0.
2- use the functions "OrderSelect()" & "OrderModify()" to change the selected order SL.
3- you may reach the current candle low price by using "iLow()".

These 3 steps above are the simplest and basic idea, you cannot do it without error(s) if you are not a programmer.
So, opening a job and hiring a developer will save your time.