• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

calling built in indicators

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

    calling built in indicators

    Hi , I want to pass custom series ( for example sum of all previous close ) to built-in indicators that only take ISeries. ? please advise.

    #2
    Hello HighTrade,

    That is fine to do.

    Are you getting an error when doing this?

    Attached is an example.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am doing this in onBarUpdate ();

      sum += Close[0] * Volume[0];
      TotalSumSeries[0] = sum;

      Value[0]= FisherTransform( TotalSumSeries ,Period)[0];

      I got the following error: OnBarUpdate' method on bar 0: Object reference not set to an instance of an object

      Comment


        #4
        Hello HighTrade,

        Is TotalSumSeries initialized as a Series<double> in State.DataLoaded?

        Is the example I provided for you working?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          got it working without error, however, the plot does not look right, it is straight line. should be oscilating.

          Comment


            #6
            declared private Series<double> TotalSumSeries; in the indicator class, and also did TotalSumSeries = new Series<double>(this); in State.DataLoaded.

            Comment


              #7
              Hello HighTrade,

              Are you printing the values for the indicator to the output window?

              How do you what the values should be, are you doing the math and the math is not the same as what is in the prints?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Ok, this is what i need working : OnBarUpdate:

                TotalSumSeries[0] = TotalSumSeries[1] + ( Close[0] - Close[1]) * Volume[0] ;
                Value[0]= FisherTransform( TotalSumSeries ,Period)[0];

                I receive this error:
                Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                please advise.

                Comment


                  #9
                  Hello HighTrade,

                  Are you making sure you are using valid indexes?

                  In other words are you ensuring that CurrentBar is greater than any barsAgo value used?
                  https://ninjatrader.com/support/foru...262#post812262
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    this fixed the problem with the error:
                    if (CurrentBar > 0)
                    {
                    TotalSumSeries[0] = TotalSumSeries[1] + ( Close[0] - Close[1]) * Volume[0] ;
                    }

                    Value[0]= FisherTransform( TotalSumSeries ,Period)[0];
                    Print(Value[0]);

                    the values seems correct, but no plot is shown.

                    Comment


                      #11
                      Upon closing the old chart and open a new chart with the indicator, the correct plot was shown. thanks for your help.

                      Comment


                        #12
                        trying to add another value to be returned by the indicator , but nothing shows up in the plot
                        // Value[0]= FisherTransform( TotalSumSeries ,Period)[0];
                        Values[1][0] = FisherTransform( TotalSumSeries2 ,Period)[0];
                        Values[0][0] = FisherTransform( TotalSumSeries ,Period)[0];

                        Comment


                          #13
                          Hello HighTrade,

                          Is the plot added with AddPlot() in State.SetDefaults?

                          Did you remove the instance of the script and add a new instance after modifying the State.SetDefaults?

                          Have you printed the values for this plot to ensure they are set?
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hi , thank you for your response, i got the both plots to show , the only question is why this indicator or the built-in indicator does not show the value for the latest data point ( with the following settings ) :
                            Data series : number of data series loaded 100, Indicator : setup max bars look back infinite. Visual / displacement 0. , I printed values of the indicator and the current bar. and found that the current bar is printed from bar 0 through bar 66 ( which is one bar before the last price data ?) . I want to be able to show the value for the last price data ? ( P.S. if i use displacement = 1 , it just shifts the plot of values, i.e the value for the last price data is still not calculated. ) please advise.

                            Comment


                              #15
                              Hello HighTrade,

                              I'm not understanding.

                              Are you asking why the indicator is not updating for each tick or price change?

                              What is Calculate set to?
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ralett, Today, 11:44 AM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_Spencer  
                              Started by DMDINAZ, Today, 11:03 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by sukhob, Today, 10:14 AM
                              4 responses
                              10 views
                              0 likes
                              Last Post sukhob
                              by sukhob
                               
                              Started by beaacontreras, Today, 09:27 AM
                              1 response
                              20 views
                              0 likes
                              Last Post NinjaTrader_PatrickG  
                              Started by fxSol, 03-17-2019, 04:17 AM
                              5 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_ChristopherS  
                              Working...
                              X