The code utilizes ExitLong() to terminate the position, the problem is that ExitLong() seems to stop all following orders on the day while utilizing backtesting.
My Question: How do I exit a historical position without cancelling future orders for the day? Do I need to switch to unmanaged orders?
code snippet below:
if (LongPositionOpen == true)
{
LongPriceList.Add(High[0]);
if (MaxLong != 0) // This code will make a list of all the bar's high's since a position opens, and stores the highest high in a variable called MaxLong.
{ // This list gets cleared every time LongPositionOpen == false so as to reset.
if (LongPriceList.Max() > MaxLong)
{
MaxLong = LongPriceList.Max();
}
}
else
{
MaxLong = LongPriceList.Max();
}
if (MaxLong !=0 )
{
if (Low[0] < MaxLong - (MaxLong * 0.002)) // If the most recent low is more than X percent below the value of MaxLong, exit the position.
{
ExitLongLimit((MaxLong - (MaxLong * 0.002)));
}
}

Comment