I have this strategy in which ExitLong(), ExitShort() aren't working even though I can see by means of a "Print ()" that the portion/set of code is firing.
private bool myCloseTrade;
protected override void OnStateChange()
{
}
protected void Button1Click(object sender, RoutedEventArgs e)
{
if (Position.MarketPosition != MarketPosition.Flat) {myCloseTrade = true;}
}
protected override void OnBarUpdate()
{
if (myCloseTrade)
{
Print("closing trade");
if (Position.MarketPosition == MarketPosition.Long) { ExitLong(); }
if (Position.MarketPosition == MarketPosition.Short) { ExitShort(); }
}
}
What could be the cause ?
I see "closing trade" in the output window and the trade is active/live, the buttons are being placed on the Chart Trader by means of the code provided on this forum by Chelsea (if I remember well). By the way, Very good piece of code !!
Thank you.
Anthony
Comment