I understand that I do not violate any Internal Order Handling Rules since I exit the operation with ExitLong () or ExitShort ()
Could you help me solve how to properly close the original position so on the reverse it does not open the double of contracts?
Thank you
This is the code
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1
|| CurrentBars[1] < 0)
return;
// Set 1
if ((Momentum1[0] < 0)
&& (ATRenTicks1[0] >= Rango)
&& (ATRenTicks1[0] < Rango_Max)
&& (Close[1] > Open[1])
&& (Close[0] < Open[0]))
{
EnterShort(Convert.ToInt32(DefaultQuantity), "");
}
// Set 2
if ((Momentum1[0] > 0)
&& (ATRenTicks1[0] >= Rango)
&& (ATRenTicks1[0] < Rango_Max)
&& (Close[1] < Open[1])
&& (Close[0] > Open[0]))
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
// Set 3
if ((Position.MarketPosition == MarketPosition.Short)
&& (CrossAbove(Close, Open, 1)))
{
ExitShort(Convert.ToInt32(Position.AveragePrice), "", "");
}
// Set 4
if ((Position.MarketPosition == MarketPosition.Long)
&& (CrossBelow(Close, Open, 1)))
{
ExitLong(Convert.ToInt32(Position.AveragePrice), "", "");
}
}
Comment