Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceEntry - multi-timeframe / mutli-instrument strategies

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

    BarsSinceEntry - multi-timeframe / mutli-instrument strategies

    NT Support,

    Does BarsSinceEntry() work (i.e. report the correct value) in multi-timeframe and multi-instrument strategies in Forex?

    Thanks and regards,

    drolles

    #2
    Hello drolles,

    Thank you for your post.

    BarsSinceEntry() will work in a multi-instrument / timeframe scenario as long as you use the appropriate method signature.

    Note however if you have the same instrument with different timeframes, the BarsSinceEntry() will return you the elapsed bars as determined by the first Bars object for the instrument specified by the barsInProgressIndex.
    DexterNinjaTrader Customer Service

    Comment


      #3
      Dexter,

      Thanks very much for your reply.

      Can I please make sure I understand, are you saying that regardless of using the switch in the BarsSinceEntry() method which says that I should able specify which BarsInProgress element I want the count to be against doesn’t matter; BarsSinceEntry() will always return the first timeframe for that instrument? For example, if I have AUDJPY 1 min and AUJPY 60 min (assuming 1 min is first) the BarsSinceEntry() will always be against the 1 min timeframe.

      Thanks and regards,

      drolles

      Comment


        #4
        Hello drolles,

        Yes, your understanding of BarsSinceEntry() is correct.

        Please let me know if I can assist you any further.
        DexterNinjaTrader Customer Service

        Comment


          #5
          Dexter,

          Thanks for the prompt reply.

          I’ve just found the Note in the documentation on BarsSinceExit() – I must have looked at the documentation on that method 30 times and never noticed that before. Thanks for pointing it out.

          Is there a development request into fix that?

          Kind regards,

          Dan

          Comment


            #6
            Hi drolles,

            This request has been sent to development with a tracking number of #933.

            Thank you for your feedback.
            DexterNinjaTrader Customer Service

            Comment


              #7
              Dexter,

              Thanks very much.

              Kind regards,

              drolles

              Comment


                #8
                Dexter,

                Does this apply to Managed Approach orders as well (e.g. ExitLongStop())?

                Thanks and regards,

                drolles

                Comment


                  #9
                  Hello,

                  Order methods always run in the bars in progress you're filtering. Unless you specify otherwise.



                  Entering, Exiting and Retrieving Position Information

                  Let me know if I can be of further assistance.
                  BrettNinjaTrader Product Management

                  Comment


                    #10
                    Brett,

                    Thanks very much for that.

                    Unfortunately, I don’t understand what you mean by “filtering” in this context? Do you mean the using the barsInProgressIndex switch on the method? Are you sure, as the conversation below refers to this functionality not working with BarsSinceEntry().

                    Thanks and regards,

                    drolles

                    Comment


                      #11
                      Hello,

                      Yes I mean BarsInProgress filtering.

                      As shown in the help guide page I linked to you.

                      if (BarsInProgress == 1)
                      {
                      EnterLong(); // EnterLong Will submit to BarsInProgress 1
                      }

                      Let me know if I can be of further assistance.
                      BrettNinjaTrader Product Management

                      Comment


                        #12
                        Brett,

                        Thanks for that.

                        Unfortunately, I’m looking to use this method in OnExecution().

                        Thanks and regards,

                        drolles

                        Comment


                          #13
                          Hello,

                          OnExecution() does not relate to a chart at all. I would not recommend using this in OnExecution() as I foresee possible issues with this and I do not see a reason why you would need to do this.

                          Perhaps let me know what your trying to do and I can send you a better method to get where you're trying to go.

                          I look forward to assisting you further.
                          BrettNinjaTrader Product Management

                          Comment


                            #14
                            Brett,

                            Thanks for your reply.

                            I’m a bit confused what you mean by “chart”. I’m not looking to apply this strategy to a chart. I’m not sure what relevance charts have here?

                            Let me try to answer your other question regarding what I am trying to achieve.

                            I have a strategy which runs across multiple timeframes (e.g. 1 min and 60 min) for single instrument (e.g. AUDJPY) and includes multiple instruments within a single strategy. I’m looking to used Managed orders to manage a stop loss against those positions. I don’t think this should be done in OnBarUpdate() as the order of execution can’t be guarantee (i.e. don’t know if you are in a position once EnterLong() has been called). Therefore, I thought you should do it only once you have a confirmed position in place; which happens once you have an entry order executed (i.e. confirming in OnExecution()).

                            Kind regards,

                            drolles

                            Comment


                              #15
                              NinjaScript strategies always run on charts. Whether you start it on a chart or not start it on a chart since strategies always run on a data series.

                              The best way to manage the stop loss on this is to use SetStopLoss() method. This will handle the stop loss for you no need to go into OnExecution or anything like that.

                              Inside the previous sample I sent you below you would have the following -

                              if (BarsInProgress == 1)
                              {
                              SetStopLoss(); // Put in your SetStopLoss conditions.
                              EnterLong(); // EnterLong Will submit to BarsInProgress 1
                              }


                              When you do this NinjaTrader will manage the stop loss on this BarsInProgress for you inside of OnExecution and be tracked correctly as the order fills.



                              lso please see this guide on how to change and manage stop losses, this will work in multi instrument strategies.





                              Let me know if I can be of further assistance.




                              Let me know if I can be of further assistance.
                              BrettNinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              574 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X