When trying to place a market order when it's not flat, nothing happens...
I have a strategy that works with two dataseries and my intention is to to place complementary orders in the same direction of the initial orders when a certain condition is reached.
The code is the following:
protected override void OnBarUpdate()
{
if (Bars == null)
return;
// Initial positions
if ( PositionsAccount[0].MarketPosition == MarketPosition.Flat
&& PositionsAccount[1].MarketPosition == MarketPosition.Flat
&& <condition1> == true)
{
EnterLong(0, 1, "LongEntryPrimaryA");
EnterShort(1, 1, "ShortEntrySecondaryA");
}
// Complementary positions
if( PositionsAccount[0].MarketPosition != MarketPosition.Flat
&& PositionsAccount[1].MarketPosition != MarketPosition.Flat
&& <condition2> == true)
{
Print("Before Enter Long");
EnterLong(1, 1, "LongEntryPrimaryB");
Print("Before Enter Short");
EnterShort(1, 1, "ShortEntrySecondaryB");
Print("After Enter Long and Short");
}
}
Even though <condition2> is met, it doesn't place the complementary positions, but it do print the three messages:
Before Enter Long
Before Enter Short
After Enter Long and Short
Any suggestions about the cause of the problem?
Thanks in advance.
Comment