1) My ExitLongLimit orders are not being triggered at all, even when the position is alive for several 100 bars and StopLoss isn't active. When i comment out the SetStopLoss, the ExitLongLimit works fine. Is there some issue with my SetStopLoss code?
2) How do i change the SL price depending on # of Bars of position? I want to say
if (Position.Bars ==0) SetStopLoss(entryPrice - 2*SlAtr*ATR(10)[0]);
else SetStopLoss(entryPrice - SlAtr*ATR(10)[0])
Note - since my SetStopLoss is in Entry condition, no Position object formed yet, so i can't check for the position bars.
if (MACD(Close, MacdPer, MacdPer*2, 9).Diff[0] > MACD(MacdPer, MacdPer*2, 9).Diff[1])
{
double entryPrice = Close[0]-entryTicks*TickSize;
EnterLongLimit(DefaultQuantity, entryPrice, "Enter-Lim");
SetStopLoss("", CalculationMode.Price, entryPrice-SlAtr*ATR(10)[0], true); //
}
// Condition set 2
if (MACD(Close, MacdPer, MacdPer*2, 9).Diff[0] < MACD(MacdPer, MacdPer*2, 9).Diff[1])
{
ExitLongLimit(Close[0] + exitTicks* TickSize, "Exit-lim", "");
}
Comment