Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicators: which one will be first executed

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

    Indicators: which one will be first executed

    Hi,

    I have 2 indicators in a Chart.
    One indicator draws some lines.
    The second indicator reads the drawn lines in the chart and does some action.

    How will be these indicators executed?
    Will be one indicator first complete executed and then proceed with the second one?
    Or will be both indicatos executed after every bar?

    #2
    Hello artson,

    As instrument updates come in, this will trigger OnBarUpdate() on every DataSeries dependent script running on that instrument, according to the Calculate setting for that script instance.

    The order that the indicators are updated is not guaranteed.

    Instead of depending on drawing objects drawn by other script instances, I would recommend making the indicator a hosted indicator that sets a plot value, which called by the host indicator.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      The order that the indicators are updated is not guaranteed.
      This could be solved more or less during live execution, but it is a problem for a historical analysis.


      The solution with an external indicator is not valid for me:
      I mean different lines, not plots. If I draw supports / resistances, I can have several of them.
      I alsou would like to have information from another bigger TimeFrames.

      How does it work in real time and in historical?
      I have some indicator wich draw lines (global) in charts with big TimeFrames and many loaded days.
      I have an indicator reading the draw elments (lines, rectangles, etc) in a chart with low TF an only 1-2 days.

      Will the lines from the big TF indicator from other chart be there when I'm executing the small TF indicator?
      Will this also happend for historical test?


      Thanks!

      Comment


        #4
        Hello artson,

        My meaning is, your code should never be dependent on a drawing object to function.
        Instead a signal should be provided from the host to a hosted script with an indicator method call that returns a plot value.
        This will work in both real-time and historical.​

        Additional time frames would be added with AddDataSeries().

        Will the lines from the big TF indicator from other chart be there when I'm executing the small TF indicator?
        Will this also happend for historical test?​
        I would not be to answer this question as there is not enough information.

        If one indicator loops through the DrawObjects collection, and then another script adds an object to the collection after, the first indicator would not have seen that object when it looped through the collection.

        However, a hosted indicator that sets a plot value that is returned to the hosting indicator or strategy would not have this issue.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The "best" solution in terms of reliability (at the cost of making one big indicator instead of two medium-sized ones) would be to combine them into one indicator so you didn't have to pass the information around at all.
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            yes, I know, but the problem would be then to load 100 days in 1 minute TF with several volumetric series........

            Because of that I wanted to separate in 2 indicators: the "small TF" for the volumetric and the "big TF" for the EMAs etc....

            Comment


              #7
              Maybe you could use the AddDataSeries signature that allows you to specify how many bars to load for each.
              Bruce DeVault
              QuantKey Trading Vendor Services
              NinjaTrader Ecosystem Vendor - QuantKey

              Comment


                #8
                Originally posted by QuantKey_Bruce View Post
                Maybe you could use the AddDataSeries signature that allows you to specify how many bars to load for each.
                Hey!!

                This could be a very good point!
                I will try it and check if it doesn't need too long

                One thing: when using ian indicator with an AddDataSeries with ticks in order to read POC and similar, it doesn't work well if I load "number of bars" instead of days....


                I'll try what you mentioned.

                Thanks a lot Bruce!!!

                Comment


                  #9
                  Yes, it would be nice if there were also a signature for "number of days" because sometimes the number of bars needed is indeterminate - for instance, to make something up, maybe you want the highest RSI value from yesterday for some bar type and you don't know how many bars there were yesterday. If that extra signature for AddDataSeries with a number of days were there, I would use it a lot personally.

                  But, at least, if you have that ability to go X bars back you have a possible alternative path to running it as two indicators which introduces some sequencing complexity.

                  Another approach would be keep it two indicators, but don't fret which one runs first (which is non-deterministic because of the threading model) - instead have the "reader" one run on a timer basis and just check for changes once a second or whatever and pick up whatever new information there is rather than trying to keep them locked bar-to-bar.
                  Last edited by QuantKey_Bruce; 03-28-2023, 04:21 PM.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Hi again,

                    2 things:


                    it seems that with volumetric Bars it is not possible to add a certain number of bars as with AddSeries.
                    It would be interesting to have this possibility!


                    I've tested tha AddSeries with number of bars, but it seems it is not done correctly. I have differences when comparing a chart with in TF 60' and the indicator applied to an AddSeries with X bars of 240' compared to a chart of the same X bars in TF 240'.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Jonafare, 12-06-2012, 03:48 PM
                    5 responses
                    3,984 views
                    0 likes
                    Last Post rene69851  
                    Started by Fitspressorest, Today, 01:38 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post Fitspressorest  
                    Started by Jonker, Today, 01:19 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post Jonker
                    by Jonker
                     
                    Started by futtrader, Today, 01:16 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post futtrader  
                    Started by Segwin, 05-07-2018, 02:15 PM
                    14 responses
                    1,791 views
                    0 likes
                    Last Post aligator  
                    Working...
                    X