let say if my buy signal triggered and currently holding 1 long contract,
if i want to exit:
1. when high of current bar crossing var1, or
If you want to exit instantly when the described condition is met, you should be using
IOG + 1 tick BM to achive this goal witht he following code:
Code: Select all
[IntrabarOrderGeneration=true]
Vars: var1(0);
if marketposition > 0 then begin
If var1 crosses above high then sell ("sell") next bar market;
end;
If you want to do this with a stop order, then should differentiate 2 things:
1. Place stop order, when particular conditions are met;
2. Place stop order with a particular price.
In your example you place stop order when your conditions are met, but it doesn't guarantee the order will be executed right after that.
2. when low hits stoploss,
The condition is not clear. If you mean "when stop loss level is hit", then your initial SetStopLoss variant is ok.