Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Changing Entry or Exit Bar

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

    Changing Entry or Exit Bar

    Any way to exit on the close of the bar that the conditions were met rather than at the open on the next bar? I realize that the closing of this bar is usually the same as the opening of the next bar but this inquiry is due to the following:

    What I see happening is say for example I'm long... and the exit Long condition signals... and the very next bar signals a short. What happens is the short signal won't enter or will enter a bar late (if the conditions for the short are still valid) because that bar it should enter on is exiting the long.

    It's probably a setting I need to set.

    Also, any way to enter at the close of the "signal" bar... ie. the bar where the conditions were met, rather than on the open of the next bar?

    #2
    Hello TicksBandit,

    Thank you for your note.

    If you were to run your strategy with Calculate set to On Each tick or On Price Change, so that your conditions are updating on each tick, then it’s possible to have your order fire off before the next tick of the new bar. See calculate, https://ninjatrader.com/support/help...?calculate.htm

    If you’re long and you get a sell signal to get short, two orders will be submitted, a sell to close and a sell to short order.

    What you could consider doing would be to move your if statements out of OnBarUpdate into a method, which you can then call from the strategy that’s running with calculate on each tick, but to prevent the strategy from evaluating until 1 minute before the close, you could use an if statement like below, where the evaluateConditionsTime is a DateTime object set to a time before the close.

    Code:
    if(Time[0] < evaluateConditionsTime) return;
    specialMethod();
    This would have the effect of jumping the gun on OnBarUpdate and would allow you to execute orders before technically the bar closed.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Christopher_R, Today, 12:29 AM
    0 responses
    6 views
    0 likes
    Last Post Christopher_R  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    166 responses
    2,235 views
    0 likes
    Last Post sidlercom80  
    Started by thread, Yesterday, 11:58 PM
    0 responses
    3 views
    0 likes
    Last Post thread
    by thread
     
    Started by jclose, Yesterday, 09:37 PM
    0 responses
    7 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,415 views
    0 likes
    Last Post Traderontheroad  
    Working...
    X