I have created a button to close manually trades.
protected void Button1Click(object sender, RoutedEventArgs e) { if(PositionAccount.MarketPosition == MarketPosition.Long) { EnterShort(PositionAccount.Quantity, "Close"); // ExitLong(PositionAccount.Quantity); } else if(PositionAccount.MarketPosition == MarketPosition.Short) { EnterLong(PositionAccount.Quantity, "Close"); // ExitShort(PositionAccount.Quantity); } }
It is not working, when I open a long trade manually for example and press the button, the long trade is closed but it opens a new short trade automatically.
I also have tried ExitShort and ExitLong and it is not working.
Is there a way to flat all positions?
Thanks
Comment