In a nutshell, I'm looking to understand how why this behavior happens only occasionally, and how I can safeguard myself from it happening in the future.
Over the last few months I've been building on my strategy based around the managed trade approach.. It is stable enough to use with my live account and has been working well through June. Today, when it hit take profit it exited the long position and then proceeded to sell an addition 5 MES contracts thus reversing my position. Because the strategy is still new, and I'm an new to coding, I'm babysitting it while it takes trades to make sure it is doing the right thing. Most of the time it does, but today it didn't and I can't understand why it behaved differently. More details below...
Here is a screen shot of the executions:
Under the name column you see the order signal "PrimeMicroProfitLong" for the next to last order which is listed as an entry. The last order was where I had to "Flatten Everything" in order to fully exit the position.
Here is where this signal is executed in the code (I put an ascii arrow to indicate the line in the code, that arrow is NOT present is the script itself):
if(direction == "LONG")
{
// Stop
ExitLongStopMarket(MiniQuantityInt, PrimeStp1Price, "PrimeMiniStopLong", "PrimeEntryLong" );
ExitLongStopMarket(HMMiniQtyInt, PrimeStp1Price, "HMMiniStopLong", "HMEntryLong" );
ExitLongStopMarket(MicroQuantityInt, PrimeStp1Price, "PrimeMicroStopLong", "PrimeMicroEntryLong" );
ExitLongStopMarket(HMMicroQtyInt, PrimeStp1Price, "HMMicroStopLong", "HMMicroEntryLong" );
// Profit
ExitLongLimit(MiniQuantityInt, PrimeTargetPrice, "PrimeProfitLong", "PrimeEntryLong" );
ExitLongLimit(HMMiniQtyInt, PrimeTargetPrice, "HMProfitLong", "HMEntryLong" );
--->>> ExitLongLimit(MicroQuantityInt, PrimeTargetPrice, "PrimeMicroProfitLong", "PrimeMicroEntryLong" );
ExitLongLimit(HMMicroQtyInt, PrimeTargetPrice, "HMMicroProfitLong", "HMMicroEntryLong" );
}
Plus, the development guide suggests it managed orders would ignore orders that would reverse direction.
"Methods that generate orders to exit a position will be ignored if:
•A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction"
As a result, I'm left scratching my head as to why chose to do this today. And if it was just a random glitch, I would love to learn a way to return it to flat automatically if this should happen again.
Thanks for reading all the way through!

Comment