Hi, I have a startegy when I enter Long when:
Close[1] > SMA 20 // ENTER LONG
I would like to exit when price close below SMA 20 and below first Close[1] - 10 pips :
Close[1] < SMA 20 && Low of the first Close[1] - 10*Points (this one I enter long)
My problem is to recall the candle of reference .
Here the graph to understand . I know Gordon will guide me to the right thing to read :-)
Thanks for your help !
I did a mistake in the picture, here the amendment 'Stop loss' by 'Exit trade'.
Just 'cos Gordon is sometimes busy, I will take a crack...
When you enter the trade, take a time for the reference bar...
ref_bar_time =iTime(NULL,0,1);
Then use ibarshift to to get back to your reference bar.
ref_bar=iBarShift(NULL,0,ref_bar_time);
SL=iLow((NULL,0,ref_bar)-10pips;
Of course you could simply set a variable SL based on the low of the prev bar when you open the trade and then test if price is below this and the ma..
SL=ilow(NULL,0,1)-10pips;
HTH
V
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I have a startegy when I enter Long when:
Close[1] > SMA 20 // ENTER LONG
I would like to exit when price close below SMA 20 and below first Close[1] - 10 pips :
Close[1] < SMA 20 && Low of the first Close[1] - 10*Points (this one I enter long)
My problem is to recall the candle of reference .
Here the graph to understand . I know Gordon will guide me to the right thing to read :-)
Thanks for your help !