- Increase the position size to 2 when switching from short to long.
- If the previous position was short, the position size is increased to 2.
- Otherwise, it enters a long position with the default size.
// Longs
if ((Close[0] > SMA1[0])
&& (Close[0] <= Bollinger1.Lower[0]))
{
if (lastPosition == MarketPosition.Short)
{
EnterLong(2, "GoLong2");
}
// lastPosition = MarketPosition.Long;
else
{
EnterLong(Convert.ToInt32(DefaultQuantity), "GoLong");
}
}
else if ((Close[0] > SMA1[0]) && (Close[0] <= Bollinger2.Lower[0]))
{
if (lastPosition == MarketPosition.Short)
{
EnterLong(2, "AgroLong2");
}
else
{
EnterLong(Convert.ToInt32(DefaultQuantity), "AgroLong");
}
}
// Shorts Exit.........
..........................

Comment