I hope you are doing well.
I have been testing a strategy that i created and that I use in a Topstep trading account with Rythmic connection that enters with limit orders up to 5 times in 1 min bar when price reach certain levels.
I keep having the same issue over and over and I don't know how to solve it. For instance, see below today's trade report where you can see how that the entryorder "MMDOL3" is executed twice at 03.50.20 and 03.50.22:
However, in the code I have an explicit filter using BarsSinceEntryExecution to only create "MMDOL3" once per bar (see below code of OnBarUpdate where i create the entry orders).
Something I realized is that this issue ALWAYS happens when the "MMDOL1" position is exited before "MMDOL2" and the rest of entry orders are executed. In the case above, you can see how "MMDOL1E" is executed at 3.50.12 and then "MMDOL2" in 3.50.16.
Do you know how can i solve this issue? Below sharing pieces of code that i believe might have the issue.. However, happy to share other pieces of code if you think the issue is coming from anywhere else.
I have the following OnStateChange configuration (where MAXPositionSize = 5):
Calculate = Calculate.OnEachTick; EntriesPerDirection = MAXPositionSize; EntryHandling = EntryHandling.AllEntries;
if (Close[0] < Open[0] - 2 && (ToTime(Time[0]) >= 090500 && ToTime(Time[0]) <= 160500) && (CurrentBarSec <= LimitSecL) ) { if (entryOrder1 == null && BarsSinceEntryExecution(0, "MMDOL1", 0) != 0 ) { EnterLongLimit(0, true, Qty, (LLL1 - EntryFactorL), "MMDOL1"); } if (entryOrder2 == null && BarsSinceEntryExecution(0, "MMDOL2", 0) != 0 ) { EnterLongLimit(0, true, Qty, (LLL1 - EntryAggressiveL1), "MMDOL2"); } if (entryOrder3 == null && BarsSinceEntryExecution(0, "MMDOL3", 0) != 0 ) { EnterLongLimit(0, true, Qty, (LLL1 - EntryAggressiveL2), "MMDOL3"); } if (entryOrder4 == null && BarsSinceEntryExecution(0, "MMDOL4", 0) != 0 ) { EnterLongLimit(0, true, Qty, (LLL1 - EntryAggressiveL3), "MMDOL4"); } if (entryOrder5 == null && BarsSinceEntryExecution(0, "MMDOL5", 0) != 0 ) { EnterLongLimit(0, true, Qty, (LLL1 - EntryAggressiveL4), "MMDOL5"); } }
Comment