Thanks for your reply.
What I would suggest is to remove this statement: int longCount = 0; // declare and reset counter
At the class level ( below the statement "public class..."), add a statement like private int longCount = 0;
In your code somewhere you can add:
if (Position.MarketPosition == MarketPosition.Flat)
{
longCount = 0; // reset counter when flat
}
Those changes will allow the counter to accumulate until you are flat.
Comment