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

How does NT8 treat EnterLong and EnterShort issued on same bar close?

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

    How does NT8 treat EnterLong and EnterShort issued on same bar close?

    I have a strategy running on bar close.
    It has multiple entry criteria for long and multiple entry criteria for short.
    I use EnterLong() and EnterShort()

    Suppose on a bar close of the same primary series, conditions for long and for short are valid at the same time, how does ninjatrader decide which order to send to the exchange? or does it do nothing at all?

    PS: using boolean flags, i filtered for a strategy to only trade when both long and short entries are valid on the same bar close. Weirdly I found that it actually does take the trades randomly long or short... sometimes from flat position or it exits and reverses the position.

    Thanks

    #2
    Hello madb123,

    That can cause problems however the second order should be blocked. You should never call multiple order actions in the same event because that will not allow for other items like the position to update. That can also lead to incorrect position depending on the order actions being called at the same time. If your conditions are too similar your logic should prevent this by disabling the other condition if the first condition becomes true.

    JesseNinjaTrader Customer Service

    Comment


      #3
      ok so confirmed that ninjatrader doesnt handle this situation and it needs to be logic handled.
      How come does it calculate as if there is no conflict in the backtests though.

      Comment


        #4
        Hello madb123,

        It should work similar in realtime as well, that specific scenario the second order should get ignored because the managed approach will not let you submit opposing entry orders. There are other combinations of orders that will result in problems with entering incorrect positions so its best to just avoid doing conflicting logic like that in general. Your logic should always try to be as specific as possible to avoid multiple order submission methods becoming true at once.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks jesse
          Other situations that the must be handled handled manually by the developer:
          - submitting an order to enter short, when marketposition is long, and at the same time having an ExitLong condition trigger.. it looks fine in backtesting but it incorrectly would exit the Long position two times in live. (and vice versa)
          - in multi instrument strategies, on bar close is not simultaneous for the 2 instruments. so Closes[0][0] and Closes[1][0] in backtesting is actually Closes[0][0] and Closes[1][1] in live. this is huge difference in larger timeframes. can only be fixed by adding tick data series in live trading. This also looks fine in back testing but not in live.

          these 2 plus what we discussed above, are 3 major pitfalls that new users especially those starting out from the strategy builder, can easily fall into and not realise until they start testing live, if at all.

          The help guide page is very thorough and clear, but one would have to deduce the above. There isnt enough or explicit warning anywhere that ninjatrader would not handle these situations in the managed approach.

          My conclusion is to use Booleans always for submitting entry orders and exit orders. just in case there is a possibility of multiple condition sets testing positive on the same bar close.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          7 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X