Is there an IF statement in the strategy script so i can turn on and off SetSimStop orders? Below is example of what I'm trying to achieve, but "If" isn't a valid command
Pl suggest how to achieve this ..
Optimize("useSL",0,1,1);
if (useSL) SetSimStop(_StopLoss,_Point, sl*TickSize(),1);
if (useSL) SetSimStop(_StopProfit,_Point,pt*TickSize(),1);
You can use "iff". Example:
a = iff(close > 10, 1, 0);
But as you can see this wouldn't work with the "SetSimStop". You need to use the money management script or use something like this:
Optimize("useSL",0,1,1);
t = iff(userSL, 1, 100000);
SetSimStop(_StopLoss,_Point, sl*TickSize()*t,1); // by multiplying the level with 100000, the stop will be reached
I tried this code below, but it the SetSimStop doesn't recognize the iff condition 1. i.e. I see some trades where the StopProfit is triggered at 4.5% (not 1000%) even though ref(open,1)<ref(close,1).
It's the same issue with the other iff condition 2, so the issue isn't related to the peak-ahead I'm doing in condition1.
Pl advise how to fix it. The reason i'm using this condition is to remove the Peak-ahead bias that is introduced by the Same-Day-Stop (as entry), so I have more realistic backtest results.
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.