Upon signal==0, I want this code to flip any open short position to a long position if lettradefinish==false (and cancel the signal if lettradefinish==true). if lettradefinish==true it cancels the signal correctly. But if lettradefinish==false, it just exits the short position while not opening the new long one.
assumptions:
Lettradefinish is an arbitrarily set bool that i have permanently set to false
signal==0 means the rest of my code generated a signal to go long (default for no signal is signal==-1), assume signal==0
AllowTrade is true
we head into this code with a short position
if (signal==0)
{
if (Position.MarketPosition==MarketPosition.Short)
{
if(!LetTradeFinish)
{
Position.Close();
}
else
{
signal=-1;
}
}
if(AllowTrade && (Position.MarketPosition==MarketPosition.Flat || (Position.Quantity<Quantity*this.EntriesPerDirecti on && AllowMultiEntries)))
{
IOrder order = this.EnterLong(0,Quantity,"Long Entry");
}
}
Would greatly appreciate any help as I think I must not understand what some of these order lines are doing from a process/order of events perspective.
Comment