Hello!
Im testing a code to set my SL just below “swing low” when going long. This code seems to work the way I want to on DAX, but when testing it in Forex I just cant get it to work properly. I tried to use “pointsize” but I just cant get it to work the way it does in DAX. The problem is that it just closes the order directly with SL or TP. With *pointsize it goes a bit longer but not even close to where it should.
Below a simple code just to show in a simple way the way it works.
//Test SL from low
Defparam cumulateorders = false
N=10
TPP=1.5//risk/reward
extra=15//pips below Low for SL
C1 = ExponentialAverage[3](close)
C2 = ExponentialAverage[20](close)
IF c1 crosses over c2 THEN
Low1=LOWEST[5](low)//lowest point of the 5 recent candle
SL= (close-LOW1)+extra//Lowest + 15 extra pips under
TP= SL*TPP//Risk/reward
BUY N/SL SHARES at MARKET
Set target pprofit TP
SET STOP pLOSS SL
ENDIF
Try
SL= (close-LOW1)*pipsize+extra//Lowest + 15 extra pips under
Thanks Roberto for your reply,
I still dont get it to work. example pic from GBPUSD where it doesnt work and another from DAX where it looks ok. On Dax it only works without Pipsize and on GBPUSD it doesnt work with or without. Do I need to add pipsize anywhere else?
If you add 15 to GbpUsd you’ll reach around 16.3 which will NEVER be true.
You’ll have to convert also the other value to pips:
extra=15 * pipsize //pips below Low for SL
I forgot to write it in my previous answer, sorry.
Ok, everything is working now. I actually had to divide with pipsize at pairs where the the number was lower than 1 (ex 0.002) . I also had to do it at the “extra” as you mentioned Roberto.
Thank you Roberto, Grazie Mille!
SL= (close-LOW1)/Pipsize+extra//Lowest + 15 extra pips under
Sorry, it was DIVIDE, you’re right!