Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Entry at open
Collapse
X
-
Thanks, I think your solution should work. I will need to place this codeOriginally posted by NinjaTrader_Josh View PostYes. Or you can stop your strategy when 4PM hits.
You may even need to return before that last bar too with >=.Code:if (ToTime(Time[0]) > 160000) return;
if (ToTime(Time[0]) >= 160000)
return;
right in the beginning of OnBarUpdate() right? So that it doesn't evaluate the 4pm bar.
This shouldn't affect the Exit on close orders right?
Leave a comment:
-
Yes. Or you can stop your strategy when 4PM hits.
You may even need to return before that last bar too with >=.Code:if (ToTime(Time[0]) > 160000) return;
Leave a comment:
-
If all that's happening is that the strategy wanted to enter long/short after evaluating the strategy at the 4:00pm bar without knowing that the session will end after 4:00pm?Originally posted by NinjaTrader_Josh View PostThe first step is to figure out exactly what the scenario is. To do this you need to use TraceOrders = true and see what the outputs are around the switch from market close to a new market open. Then you can tailor a solution when you figure out what exactly is happening.
All I want to do here is cancel any pending order that still exists after 4:00pm so that it doesn't execute on market open.
Leave a comment:
-
The first step is to figure out exactly what the scenario is. To do this you need to use TraceOrders = true and see what the outputs are around the switch from market close to a new market open. Then you can tailor a solution when you figure out what exactly is happening.
Leave a comment:
-
How do I implement A or B solution in the strategy? Do I test using IOrder objects at 4pm? If you can provide some advice, it would be very helpful. Thanks.Originally posted by NinjaTrader_Josh View PostStopping a strategy and restarting it just means the strategy goes and recalculates everything again. If it saw a submission at the end that was not explicitly cancelled by the strategy then it will try and place that in.
A. Don't submit that order
B. Cancel that order explicitly in the strategy
Leave a comment:
-
Stopping a strategy and restarting it just means the strategy goes and recalculates everything again. If it saw a submission at the end that was not explicitly cancelled by the strategy then it will try and place that in.
A. Don't submit that order
B. Cancel that order explicitly in the strategy
Leave a comment:
-
What you said here is exactly what I think happened. But doesn't stopping the strategy and restarting it stop this from happening? There should be no carry over trade from the last trading day given all strategies would have stopped at the end of the trading session.Originally posted by NinjaTrader_Josh View PostThe order has to have come from before market open. It was likely generated on the last bar before the new session and filled on the market open because that is the next tradeable location.
Leave a comment:
-
tjendra,
An order submitted with CalculateOnBarClose = true gets filled on the next bar. Not possible to have an order filled at market open from a submission at market open when using CalculateOnBarClose = true. The order has to have come from before market open. It was likely generated on the last bar before the new session and filled on the market open because that is the next tradeable location.
Leave a comment:
-
I will try that. What if it shows the order was submitted at market open? Is that possible if CalculateOnBarClose is set to True?Originally posted by NinjaTrader_Josh View Posttjendra,
No. Those orders are not from what you evaluated at market open. Those are coming from whatever you had left over before. You need to cancel your working orders.
Please go back to your code and use TraceOrders = true to see when your order is being submitted. Then all you have to do is not submit that order or cancel that order and it will be gone.
Leave a comment:
-
tjendra,
No. Those orders are not from what you evaluated at market open. Those are coming from whatever you had left over before. You need to cancel your working orders.
Please go back to your code and use TraceOrders = true to see when your order is being submitted. Then all you have to do is not submit that order or cancel that order and it will be gone.
Leave a comment:
-
I also don't get why I keep getting orders entered right at market open. That's why I thought with such a filter, I can make sure it doesn't evaluate any bars prior to 9:35am. Do you think it could be a synchronisation issue with the session time? If my session time is set a few seconds earlier than the actual market open, probably that why my strategy execute earlier than it should? Maybe if I make it a few seconds slower than market open?Originally posted by NinjaTrader_Josh View Posttjendra,
Consider the logic. On 5 min charts, the first bar of the chart is timestamped as 93500. There would be no bars timestamped earlier than that unless you are charting pre-market information. If you are not charting pre-market information using such a line doesn't do anything. There is no information being filtered.
Leave a comment:
-
tjendra,
Consider the logic. On 5 min charts, the first bar of the chart is timestamped as 93500. There would be no bars timestamped earlier than that unless you are charting pre-market information. If you are not charting pre-market information using such a line doesn't do anything. There is no information being filtered.
Leave a comment:
-
In that case, if I change it to:Originally posted by NinjaTrader_Josh View Post93500 will filter out the first 5 minute bar. The first 5 minute bar is timestamped as 93500 and for sure will be filtered out with an <= operator.
In a five minute chart you do not have any bars that are timestamped as 93400. This means your time filter condition doesn't do anything. You might as well not use it if you are on 5 minute bars.
if (ToTime(Time[0]) < 93500)
That should evaluate the first bar then?
Leave a comment:
-
93500 will filter out the first 5 minute bar. The first 5 minute bar is timestamped as 93500 and for sure will be filtered out with an <= operator.
In a five minute chart you do not have any bars that are timestamped as 93400. This means your time filter condition doesn't do anything. You might as well not use it if you are on 5 minute bars.
Leave a comment:
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
115 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
161 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
83 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
127 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
87 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Leave a comment: