I've changed the time interval to 1 minute ... using the exact code I posted this is what I get:
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Repeating EnterLongLimit in Realtime
Collapse
X
-
Hello dibDab,
Your PC clock should be set to the current time by syncing it using windows.
Again the logic you provided should not be happening in the same bar, the BarsSinceEntryExecution only reports a positive value when bars elapse after an entry is filled. The screenshot you had shown is showing a sell order exiting the long position so there is still some issue with your logic.
If you have other conditions for sell orders or short orders please remove those for the time being.
Comment
-
Hello dibDab,
I would suggest to try and use a Print and make sure the exit condition is happening when expected. I see this type of logic working fine on my end when using a 5 second chart, it waits 5 bars and then exits.
Code:if(State == State.Realtime && Position.MarketPosition == MarketPosition.Flat) { EnterLongLimit(Close[0], "MyEntry"); } if(BarsSinceEntryExecution("MyEntry") >= 5) { ExitLong("MyEntry"); }
Comment
-
Hello dibDab,
I don't see that happening on my end, are you certain that you are compiling the code after making changes?
With the sample that I provided You should see a entry and exit order in 1 bar when using OnEachTick because you have a generic entry condition that can happen as soon as the position is flat again. The first entry will happen and the exit should occur 5 bars after the entry it targets. Then you would see another entry on the same bar as that exit. 5 bars later you would see another exit and immediately have another entry. To avoid that you would have to make a more specific entry condition.
Comment
-
Hello dibDab,
The sample that I provided was simply to demonstrate using BarsSinceEntryExecution in realtime. This method works for both OnBarClose or OnEachTick. If you choose to use OnEachTick in realtime then it would be expected that a simple condition like that would allow another entry as soon as it was flat again so you would see an entry and exit on a single bar after the first exit had closed the first entry. Every time an exit happened after that an entry would be placed on the bar with the exit because you are using OnEachTick and it was flat again.
In your original script you had logic to make a single entry which is something you could still do if you wanted to test something one time in realtime.
Comment
-
I really appreciate your help but I just can't get to the bottom of this.
I've attached Test_v2.zip (Calculate.OnEachTick) which has one entry and prints 1 submitted and 1 filled.
Yet the chart signal keeps on moving to the right on each new bar?
Comment
-
Hello dibDab,
It looks like you added quite a bit of code to this sample. If you are having trouble with that I would suggest using prints to identify how your code is working when you run it. You may also want to avoid using OnEachTick until you have your idea working as you wanted. I can see on my end that BarsSinceEntryExecution works as expected and waits 5 bars before doing an exit.
Comment
-
Hello dibDab,
If you mean a working order that has not filled, that should remain working until filled. An unfilled order has no associated bar because it has not filled yet. The "entry bar" or where you condition happened is not a guarantee of where a limit order will fill, limit orders have specific price requirements to fill and if that requirement is not met it would keep working until filled.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
139 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment