Hello,
i have a strategy that work in EURUSD pair and I want to add a protective stop loss when the current order reach a determinate level o profit. I want to add these protection in addition to traditional stop loss and take profit. Below the code. The strategy work in IG CFD account. It’s correct ?
//when the strategy reach a gain of 50$ set the breakeven with a profit of 5$
If LongOnmarket and (close[1]- tradeprice)>= 0.05 then
sell at (tradeprice + 0.005) limit
endif
//when the strategy reach a gain of 50$ set the breakeven with a profit of 5$
If shortONmarket and (tradeprice-close[1])>= 0.05 then
exitshort at (tradeprice - 0.005) limit
endif
SET STOP $LOSS 90
SET TARGET $PROFIT 100
Hi,
I think you should use the instruction PIPVALUE to calculate the real value in money of a pips difference:
If LongOnmarket and (close[1]- tradeprice)>= 50/pipvalue then
That way, your code will be universal with all traded instruments.
Also, to exit a long position below the actual price, you’ll have to use a STOP order and not a LIMIT one. It is the same to exit a short position (use STOP order instead).
exitshort at (tradeprice - 5/pipvalue) STOP