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

Indicator output is different when invoked by strategy

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

    Indicator output is different when invoked by strategy

    I have an indicator that plots differently when invoked via a strategy vs when just placed on a chart.

    I'm looked and double checked everything I can think of..


    Looking for some help in determining why this would happen??
    Attached Files

    #2
    Try it with an SMA. Does it come up the same if you do an SMA?

    I am also baffled as to why it would come up different.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      No problem with SMA .. or other indicators I've tried .. so far. But does make me wonder about some of the odd/un-explained problems I've had. Perhaps other indicators are reading 'wrong' when invoked in a strategy

      I deleted all other custom indicators and strategies to see if there was some other indicator that was somehow causing a problem.
      No luck .. still have the same issue.

      Most likely an indicator problem... but what?
      And how would any user created indicator problem cause it to plot differently like this? That may be an NT bug.

      I've attached the indicator/strategy/template to re-create
      adxvma is the indicator, zz is the strategy, the zz.xml.blah file is a simple template to recreate the attached chart

      This happens in both 6 and 6.5 b4
      Attached Files

      Comment


        #4
        I think I've seen that happen before when the indicator starts from the beginning of the data series (like EMA) and the strategy and chart aren't starting on the same date. Make sure the chart and strategy are loading the exact same data and see what happens.

        Comment


          #5
          Good suggestion Pete S. On your strategy and indicator try adding BarsRequired = 20; in the Initialize() method. If that standardizes the plots then we know it was just a data issue.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thanks folks.
            Tried with BarsRequired = 20; and BarsRequired = 90; in both strategy and indicator.

            No change/Same symptoms

            Comment


              #7
              Ok zoltran. I found the problem with your indicator after staring at it for a long while. In the Initialize() method you did this:
              Code:
              WeightDX = ADXPeriod;
              WeightDM = ADXPeriod;
              WeightDI = ADXPeriod;
              ChandeEMA = ADXPeriod;
              When you define the variables like that inside the Initialize() method it doesn't necessarily sync up with the adxperiod you defined as the user input at the exact moment the Initialize() method is called.

              Instead you want to move it to the OnBarUpdate() method.
              Code:
              if (CurrentBar == 0)
              {
                  WeightDX = ADXPeriod;
                  WeightDM = ADXPeriod;
                  WeightDI = ADXPeriod;
                  ChandeEMA = ADXPeriod;
              }
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Josh.. they don't pay you enough !!

                Many thanks..!!

                Comment


                  #9
                  Josh . . . I too have tripped myself up on this issue enough in the past such that it would be a good candidate for the "Tips" section. In particular, when to assign values from parameters in the Initialize() section and when to do so within the OnBarUpdate() CurrentBar < 1 block. Just a thought.

                  Regards,

                  Whitmark
                  whitmark
                  NinjaTrader Ecosystem Vendor - Whitmark Development

                  Comment


                    #10
                    Dito 1
                    Also pros/cons of declaring vars in the variables region vs inline.

                    Comment


                      #11
                      So how extensive is the impact of this anomaly? I’ve often had strategy actions fire off when the charted version of the indicators they are based on show that they should not have fired – sometimes with disastrous results! My examples are not as obvious as the chart zoltran posted but they relate to the same kind of divergence. Most of my problems have to do with more subtle differences between the indicator and the strategy prints, but they can be just as important for trading results. Maybe this is the explanation.
                      Does it mean that all or most of our custom indicators need a complete overhaul to remove this possible source of live trading errors? Do any of you more experienced programmers feel up to outlining some practical guidelines for live NT traders on how to deal with this issue?

                      Comment


                        #12
                        It is not an anomoly but a logic flow in custom code on the part of the user. We will put together a tip shortly.
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          Thanks Ray, that will be very helpful. Great support as usual.

                          Comment


                            #14
                            Thanks for the suggestion whitmark and raintree. Will work on it shortly.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              The next 6.5 Beta has some logic changes that will allow you to assign user defined inputs (properties) to other variables. This will be true for indicators that have been "Saved/Compiled" with this next version or later.
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by naanku, Today, 07:25 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post naanku
                              by naanku
                               
                              Started by milfocs, Today, 07:23 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post milfocs
                              by milfocs
                               
                              Started by PaulMohn, Today, 06:59 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post PaulMohn  
                              Started by bortz, 11-06-2023, 08:04 AM
                              48 responses
                              1,754 views
                              0 likes
                              Last Post carnitron  
                              Started by Jonker, 04-27-2024, 01:19 PM
                              3 responses
                              24 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X