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 DJ888, 04-16-2024, 06:09 PM
    4 responses
    12 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by terofs, Today, 04:18 PM
    0 responses
    7 views
    0 likes
    Last Post terofs
    by terofs
     
    Started by nandhumca, Today, 03:41 PM
    0 responses
    6 views
    0 likes
    Last Post nandhumca  
    Started by The_Sec, Today, 03:37 PM
    0 responses
    3 views
    0 likes
    Last Post The_Sec
    by The_Sec
     
    Started by GwFutures1988, Today, 02:48 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X