Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry at open

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_JoshP
    replied
    Correct. Exit on Close will not be influenced.

    Leave a comment:


  • tjendra
    replied
    Originally posted by NinjaTrader_Josh View Post
    Yes. Or you can stop your strategy when 4PM hits.

    Code:
    if (ToTime(Time[0]) > 160000)
         return;
    You may even need to return before that last bar too with >=.
    Thanks, I think your solution should work. I will need to place this code

    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:


  • NinjaTrader_JoshP
    replied
    Yes. Or you can stop your strategy when 4PM hits.

    Code:
    if (ToTime(Time[0]) > 160000)
         return;
    You may even need to return before that last bar too with >=.

    Leave a comment:


  • tjendra
    replied
    Originally posted by NinjaTrader_Josh View Post
    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.
    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?

    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:


  • NinjaTrader_JoshP
    replied
    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:


  • tjendra
    replied
    Originally posted by NinjaTrader_Josh View Post
    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
    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.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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:


  • tjendra
    replied
    Originally posted by NinjaTrader_Josh View Post
    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.
    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.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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:


  • tjendra
    replied
    Originally posted by NinjaTrader_Josh View Post
    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.
    I will try that. What if it shows the order was submitted at market open? Is that possible if CalculateOnBarClose is set to True?

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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:


  • tjendra
    replied
    Originally posted by NinjaTrader_Josh View Post
    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.
    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?

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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:


  • tjendra
    replied
    Originally posted by NinjaTrader_Josh View Post
    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.
    In that case, if I change it to:

    if (ToTime(Time[0]) < 93500)

    That should evaluate the first bar then?

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    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 Mindset
by Mindset
 
Started by M4ndoo, 04-20-2026, 05:21 PM
0 responses
161 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by M4ndoo, 04-19-2026, 05:54 PM
0 responses
83 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
127 views
0 likes
Last Post cmoran13  
Started by PaulMohn, 04-10-2026, 11:11 AM
0 responses
87 views
0 likes
Last Post PaulMohn  
Working...
X