backtesting work fine.
must i use OnOrderUpdate() or OnExecution???
... because the code do not open position or cancel position after realized (P/L). Position is open in the position tab. Not in the Strategy tab.
protected override void OnBarUpdate()
{
//Entry Condition
if ( (Position.MarketPosition == MarketPosition.Flat) &&
// (High[2] < High[1]) &&
(High[1] < High[0]) &&
(CCI(20)[0] > 0) &&
(ParabolicSAR(0.09, 0.2, 0.02)[0] < Close[0]) &&
(DM(10).DiPlus[0] > DM(10).DiMinus[0]))
{
EnterLong();
}
if ( (Position.MarketPosition == MarketPosition.Flat) &&
// (Low[1] < Low[2]) &&
(Low[0] < Low[1]) &&
(CCI(20)[0] < 0) &&
(ParabolicSAR(0.09, 0.2, 0.02)[0] > Close[0]) &&
(DM(10).DiPlus[0] < DM(10).DiMinus[0]))
{
EnterShort();
}
//Exit Condition
if ( (Position.MarketPosition == MarketPosition.Long) &&
(Low[0] < Low[1]))
{
ExitLong();
}
if ( (Position.MarketPosition == MarketPosition.Short) &&
(High[1] < High[0]))
{
ExitShort();
}
}
best regards
Comment