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

Error on indicator when accessed by another indicator

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

    Error on indicator when accessed by another indicator

    Hi Everyone,

    So now I developed Ron Black's Swing Line indicator in the multiple time frame form. The idea is that if the price bar is making higher lows it is up, and lower highers down, others are noise. It works as expected. And I used a dataseries "mytrend" to denote the trends: mytrend[0]==1 is up, mytrend[0]==-1 is down, mytrend[0]==0 is noise. It plots properly. But when I access the Mytrend series from another indicator. It gives all mytrend[0]==0.

    Don't know why is this happening. I checked the exposure part in the code :

    Code:
            [Browsable(false)]
            [XmlIgnore]
            public Series<double>  Mytrend
            {
                get { return  mytrend; }
            }
    And it seems all right. Any help is appreciated.
    Attached Files

    #2
    Hello wolfcuring,

    Thank you for your post.

    In this situation, I believe this is caused because you are using a series<double> instead of creating a Plot. Generally, if you create a public series you would need to call Update() in the get of the property:


    Code:
    public Series<double>  Mytrend
    {
       get { 
    [B]Update();[/B]
            return  mytrend;
        }
    }
    This would also require you to remove/reapply the indicator to see it change. The alternative would be to create Plots in the indicator, a plot does not need to have Update called.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you Jesse, it worked.

      Comment


        #4
        Hi Jesse, when I access it from a strategy, it is still the same: giving all mytrend[0]==0.

        Thank you.

        Comment


          #5
          Hello wolfcuring,

          Thank you for the post.

          I took a look at the indicator again and wanted to gather some information on the overall goal. It looks like you are doing two items in the indicator one which can cause problems, the other I am not certain of your goal to know if that is needed or not.

          The first item is using a dynamic variable with AddDataSeries. This is known to fail, you need to hard code the value instead of using a variable:

          Code:
          AddDataSeries(Data.BarsPeriodType.Minute, HighTimeFrame );
          would need to be:

          Code:
          AddDataSeries(Data.BarsPeriodType.Minute, 240);

          The second item is that you are creating your series and syncing them to the second bar's array, but you are trying to access the later from another script. Generally, to expose a value, it would need to be synced with the primary series which would be the default way you create a series or plot.

          I see using mytrend=new Series<double>(this); allows the value to be exposed, however, I don't know if this affects your overall logic so this is something you could test to confirm if this change would allow your script to continue to work as you wanted.


          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Hi Jesse,

            I made the changes you suggested: using specific time periods not a variable, and access the primary data series. But it still does not work properly. The indicator still throw all 0s when accessed from an strategy.
            Attached Files

            Comment


              #7
              Hi Jesse,

              Finally, I figure out what caused the error. So, within a multiple time frame strategy, using a multiple time frame indicator can cause conflicts. Because, both the indicator and strategy are trying to reload the data series object, even they are both loading the same data series, for example 60 mins, they are still in conflict.

              That is my hunch, and I am not 100% sure. But when it does not work, the output window threw some information about the reloading data series. And when I used a non-multiple-time-frame indicator, it all works fine.

              Hope this can also help other people.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Jltarrau, Today, 05:57 AM
              0 responses
              1 view
              0 likes
              Last Post Jltarrau  
              Started by f.saeidi, Today, 05:56 AM
              0 responses
              1 view
              0 likes
              Last Post f.saeidi  
              Started by Stanfillirenfro, Yesterday, 09:19 AM
              7 responses
              51 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by TraderCro, 04-12-2024, 11:36 AM
              4 responses
              70 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Mindset, Yesterday, 02:04 AM
              1 response
              15 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X