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

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 jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              167 responses
                              2,260 views
                              0 likes
                              Last Post jeronymite  
                              Started by warreng86, 11-10-2020, 02:04 PM
                              7 responses
                              1,362 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Perr0Grande, Today, 08:16 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Perr0Grande  
                              Working...
                              X