Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Repeating EnterLongLimit in Realtime
Collapse
X
-
Repeating EnterLongLimit in Realtime
I'm testing a simple strategy with EnterLongLimit (isLiveUntilCancelled = true) which works fine on historical bars but in realtime "Long Limit Entry" keeps shifting right each time a new bar arrives. I realise I may need to provide more but just checking if this is an easy fix?Tags: None
-
Hello dibDab,
Right, only a filled order would be displayed on a specific bar and not move. Open orders are not associated with a specific bar because its not filled yet and has no specific time for a fill yet. Once that order fills it would be marked on the bar where the fill happened based on the time of the orders fill.
Comment
-
Looks like I'm doing something incorrect ...
I EnterLongLimit(sLiveUntilCancelled = true) and historically that works ok and I get OnExecutionUpdate to confirm as expected.
but in real-time it moves along another few bars and then gets executed on a bar whose OHLC is above the displayed limit.
do I still need to cancel the EnterLongLimit after execution?
using PlayBack also seems to work ok but I get execution on same price but on the previous bar?Last edited by dibDab; 10-26-2022, 06:34 AM.
Comment
-
Hello dibDab,
OnExecutionUpdate would only be called once that limit order fills.
In historical data you are using only the OHLC of the bar series for fills using the historical fill engine which may work differently that realtime orders. Realtime orders are using live data to fill. When using limit orders the price is guaranteed, but the filling of the order is not. Limit orders will be executed only if the price meets the order qualifications.
In realtime if the order has not filled you should see that the order just remains working and if bars close the order marker would continue to progress along and show up until filled.
You wouldn't need to cancel the order after execution, you actually can't cancel an already executed order because it has filled and that would cause an error. You would only need to cancel the order if it has not filled yet and you no longer want the order to exist.
Playback is also a realtime mode using the sim fill engine, you should see similar results as you do in realtime when playing forward. I am not sure what you mean that you get an execution on the same price but on the previous bar. The working order should show up and remain working until filled. once filled that order has a filled timestamp, depending on the time it filled it will show up on a specific bar.
Comment
-
thanks. Getting there slowly.
Trying to setup something simple (see below) so I can watch in realtime
if the limitPrice < market, don't see anything and if limiPrice is hit then I see my problem?
protected override void OnBarUpdate()
{
double limitPrice = 3867;
if (IsFirstTickOfBar)
++elapsedBars;
if (Count - 2 == CurrentBar && entryCnt == 0)
{
++entryCnt;
elapsedBars = 0;
EnterLongLimit(0, true, 1, limitPrice, "Long Limit");
}
if (elapsedBars >= 5)
ExitLong("Long Limit");
}
Last edited by dibDab; 10-26-2022, 08:46 AM.
Comment
-
Hello dibDab,
The code you had provided earlier is incrementing for every bar so you could have an exit on the same bar as the entry fill. As soon as 5 bars had elapsed it would try to exit on every bar after that. You can use BarsSinceEntry to know how many bars happened since an entry fill: https://ninjatrader.com/support/help...barssinceentry
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
71 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
143 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
47 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|

Comment