I am trying to program under what circumstances I should not trade.
The code below I have under the OnBarUpdate(). However, it doesn't seem to eliminate unwanted trades during the backtest. Please confirm if such code structure/syntax are right for my purpose:
if
(
//conditions when NOT to trade
)
{
[B]Position.MarketPosition = MarketPosition.Flat;[/B] //Is this the correct syntax to use if I intend to stay out of the market?
}
else if
(
//conditions when TO TRADE
)
{
//I do this when I want to Trade
}

Comment