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

NT7 to NT8 migration - error while executing the scripts

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

    NT7 to NT8 migration - error while executing the scripts

    Hi NT8 support team,

    I have a custom indicator in NT7 which i'm migrating to NT8, I resolved all compilation errors but when loading the indicator to the chart, I'm getting exception when i assign the plot values. My first 2 plot values got initialized but 3 &4 at line 216 throw error. Could you please check and let me know how to set multiple plots in NT8?

    //Output window
    Long condition - 175 - True
    Trend condition -187 True
    made it to - 205
    made it to - 208
    made it to - 216
    Indicator 'RMheikinashi': Error on calling 'OnBarUpdate' method on bar 1: 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.

    //Code snippet

    //6 plots
    OnStateChange()

    AddPlot(Brushes.Green, "BUY");
    AddPlot(Brushes.OrangeRed, "SELL");
    AddPlot(Brushes.Transparent, "closePlotUP");
    AddPlot(Brushes.Transparent, "openPlotUP");
    AddPlot(Brushes.Transparent, "closePlotDN");
    AddPlot(Brushes.Transparent, "openPlotDN");

    OnBarUpdate()

    Print("made it to - 205");

    Value[0] = plGreen[0];
    Value[1] = plRed[0];

    Print("made it to - 208");

    if(trendState)
    {
    Print("made it to - 216");
    Value[2] = plGreen1[0];
    Value[3] = plRed1[0];
    }


    #2
    Hello radhmu978,

    Thanks for your post.

    Value[0] represents the current value of the primary plot.

    Value[1] represents the previous value of the primary plot.

    When working with multiple plots...

    Values[0][0] represents the current value of the primary plot.

    ​​​​​​​​​​​​​​Values[1][0] represents the current value of the secondary plot.

    Values[0][1] represents the previous value of the primary plot.

    ​​​​​​​​​​​​​​Values[1][1] represents the previous value of the secondary plot.

    AddPlot - https://ninjatrader.com/support/help...ml?addplot.htm
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you Jim. Plot issues resolved. I'm able to see the plot and arrow. But when i add text, I'm getting runtime exception. I want to draw "BUY" and "SELL" label below the arrow on chart.

      Runtime Error:- on calling 'OnBarUpdate' method on bar 1: 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.

      //Code snippet

      //Draw Arrow
      Draw.ArrowDown(this,"mytag1"+CurrentBar, true, 0, High[0],Brushes.OrangeRed);
      // Draws text
      Draw.Text(this, "tag1"+CurrentBar, "SELL", 10, 1000, Brushes.OrangeRed);

      Click image for larger version

Name:	chart-arrow-text.png
Views:	301
Size:	71.6 KB
ID:	1183281

      Comment


        #4
        I need help with this error print in log file -

        2021-12-27 14:06:56:861|3|16|Failed to call OnRender() for chart object 'Region': '.IsValidDataPoint cannot be used on a series running with MaximumBarsLookBack.TwoHundredFiftySix.'



        Comment


          #5
          Hello radhmu978,

          If you are trying to draw X number of bars ago, you will need to make sure you have processed that many bars first.

          Making sure there are enough bars in the data series you are referencing - https://ninjatrader.com/support/help...nough_bars.htm

          For example, if you are calling a Drawing method where a line will start 10 bars ago, you will need to make sure you have processed 10 bars first. In other words, you would check if CurrentBar > 10 before calling the drawing method.

          I may suggest also using the Strategy Builder to generate syntax for various drawing methods. Once you set up the draw method and click View Code, you can see the syntax generated by the Strategy Builder, and you can see how CurrentBar checks are added to make sure the script has processed X number of bars, before that number of bars ago is referenced.

          Drawing - https://ninjatrader.com/support/help...ToDrawOnAChart

          As for Region, please first be sure to identify the specific script that triggers the error. Once the script it identified, I suggest changing your usage of Region so you provide Series<double>'s as input that are built with MaximumBarsLookback.Infinite.

          MaximumBarsLookBack - https://ninjatrader.com/support/help...rslookback.htm
          JimNinjaTrader Customer Service

          Comment


            #6
            ok, will check. One more question, my indicator is designed to send LONG and SHORT signal. How to get this boolean BUY & SELL alert from indicator to strategy. Could you please point me some existing examples?

            Comment


              #7
              Hello radhmu978,

              Indicators would communicate with strategies by exposing plots.

              You could consider adding a plot called "BuySignal" that is 0 on all bars, but is set to 1 when the "BUY" signal is triggered in the indicator. The strategy would then set up conditions to check if the "BuySignal" plot is a value of 1 to trigger submitting your order.

              As for examples, there would not be too much else to point out other than the AddPlot documentation on adding plots and assigning plot values.

              If you would like to see how a strategy may reference the indicator plot, you can set up a basic condition with the Strategy Builder:

              Strategy Builder (compare indicator plot values) - https://ninjatrader.com/support/help...lueComparisons

              JimNinjaTrader Customer Service

              Comment


                #8
                Hi,

                I need help with following issues. I keep getting the below warning message in my indicator.

                Issue #1

                2022-01-04 11:53:05:789|3|16|Failed to call OnRender() for chart object 'Region': '.IsValidDataPoint cannot be used on a series running with MaximumBarsLookBack.TwoHundredFiftySix.' - How to get this issue resolved?

                Issue #2
                I don't have any references in my source code to MaximumBarsLookBack.TwoHundredFiftySix.Not sure why I get the following error. I reached out to sharkindicators support team and they suggested me to contact NT8 platform team. Let me know if you have a patch or workaround for this issue.

                2022-01-04 12:14:43:266|3|4|Indicator 'BloodHound Ultimate': Error on calling 'OnBarUpdate' method on bar 2: Tried to see if value exists from indicator: RMheikinashi but couldn't due to a known NinjaTrader limitation.
                This is a known issue: https://www.sharkindicators.com/e256

                .IsValidDataPoint cannot be used on a series running with MaximumBarsLookBack.TwoHundredFiftySix.
                2022-01-04 12:14:43:266|1|16|BloodHound Ultimate v16.44 (OBC NQ 03-22 15 Min Heiken-Ashi, 15 Min Heiken-Ashi): RM-HA-EMA55 [Entry Logic](31765816) was terminated, running Template: RM-HA-EMA55, on NQ 03-22 15 Min Heiken-Ashi chart
                2022-01-04 12:14:46:939|1|16|BloodHound Ultimate v16.44 (OBC NQ 03-22 15 Min Heiken-Ashi, 15 Min Heiken-Ashi): RM-HA-EMA55 [Entry Logic](59864800) started Template: RM-HA-EMA55, on NQ 03-22 15 Min Heiken-Ashi chart
                2022-01-04 12:14:46:966|3|16|BloodHound Ultimate v16.44 (OBC NQ 03-22 15 Min Heiken-Ashi, 15 Min Heiken-Ashi): RM-HA-EMA55 [Entry Logic]: Unhandled ExceptionNinjaTrader.PlatformServices.KnownMaximum LookBack256LimitationException: Tried to see if value exists from indicator: RMheikinashi but couldn't due to a known NinjaTrader limitation.
                This is a known issue: https://www.sharkindicators.com/e256

                .IsValidDataPoint cannot be used on a series running with MaximumBarsLookBack.TwoHundredFiftySix. ---> System.ArgumentException: .IsValidDataPoint cannot be used on a series running with MaximumBarsLookBack.TwoHundredFiftySix.
                at NinjaTrader.NinjaScript.Series`1.IsValidDataPointA t(Int32 barIndex)
                at NinjaTrader.PlatformServices.ReadOnlyBoolToDoubleS eriesConverter.ContainsValueAt(Int32 barIdx)
                --- End of inner exception stack trace ---
                at NinjaTrader.PlatformServices.ReadOnlyBoolToDoubleS eriesConverter.ContainsValueAt(Int32 barIdx)
                at SharkIndicators.Indicators.DataInputComponentProce ssor.SanityCheck(IPlatformServices parent, EMarketDirection direction, DataInputComponent p, Int32 iBarsInProgress, Int32 iBarsAgo, Int32 iBarsBack, Int32 iCurrentBar)
                at SharkIndicators.BloodHound.SelectableDataSolver.On SanityCheck(IPlatformServices parent, Object data, EMarketDirection direction, Int32 iBarsAgo, Int32 iBarsBack)
                at SharkIndicators.BloodHound.DoubleSelectableDataSol ver.OnSanityCheck(IPlatformServices parent, Object data, EMarketDirection direction, Int32 iBarsAgo, Int32 iBarsBack)
                at SharkIndicators.BloodHound.ConfidenceSolver.Calcul ateValue(IPlatformServices parent, EMarketDirection direction, Int32 iBarsAgo)
                at NinjaTrader.NinjaScript.Indicators.SharkIndicators .SiBloodHound.Solve()
                at NinjaTrader.NinjaScript.Indicators.SharkIndicators .SiBloodHound.OnBarUpdate()

                Thankfully,
                Murali

                Comment


                  #9
                  Hello Murali,

                  We can't really help with SharkIndicators products and errors encountered using their products. I can give some general insight on these errors, but from a NinjaScript perspective: to resolve the error, the specific line of code that uses Region and throws the error would need to be found.

                  From what I can guess from the output, issue #1 and issue #2 are the same. The issue you describe with Issue 1 also has further detail when you click the link provided with Issue 2.

                  2022-01-04 11:53:05:789|3|16|Failed to call OnRender() for chart object 'Region': '.IsValidDataPoint cannot be used on a series running with MaximumBarsLookBack.TwoHundredFiftySix.'
                  This is seen when a Region drawing object is was attempted on a Series that uses MaximumBarsLookBack.TwoHundredFiftySix. Somewhere in what you are setting up, a Region is being setup on a some input that does not use MaximumBarsLookBack.Infinite. Checking the source code of what is generated may be necessary to see what is using Region, and then you could see how that Series was created and change it to use MaximumBarsLookBack.Infinite. This could be inside an indicator that you are using.

                  Checking the code and seeing what is using Region would be necessary to see what changes you have to make to avoid that error.







                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Let me send use the source code to platformsupport email address. there is no reference to IsValidDataPoint in my indicator code. I did not see this issue in NT7, only in NT8 logs I see this error.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Option Whisperer, Today, 07:58 PM
                    3 responses
                    12 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by ETFVoyageur, 05-07-2024, 07:05 PM
                    13 responses
                    81 views
                    0 likes
                    Last Post ETFVoyageur  
                    Started by cupir2, Today, 07:44 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post cupir2
                    by cupir2
                     
                    Started by reynoldsn, Today, 07:23 AM
                    6 responses
                    19 views
                    1 like
                    Last Post reynoldsn  
                    Started by reynoldsn, Today, 07:26 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post reynoldsn  
                    Working...
                    X