Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Script stops plotting after a few days running on historical data

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

    Script stops plotting after a few days running on historical data

    HI All,

    I ran it on playback. Runs for about 9 days then completely stops plotting on lower panel.

    In addition the plot it had created for the past 9 days vanishes too.

    double high0 = High[0];
    double low0 = Low[0];
    double close0 = Close[0];
    double open0 = Open[0];

    double volume0 = Volume[0];


    AD[0]= (((close0 - open0) - (high0 - low0)) / (high0 - low0)) * volume0;

    #2
    Hello rocketstock,

    Do any errors appear?

    The variables appear to be redundant and are be assigned a value that is already accessible. Do you need these variables to create new memory locations?

    AD[0] = (((Close[0] - Open[0]) - (High[0] - Low[0])) / (High[0] - Low[0])) * Volume[0];

    If all logic is removed and you print the time of the bar, do you see the prints continuing to appear?
    https://ninjatrader.com/support/foru...121#post791121

    Are new bars appearing on the chart?

    Is this being tested in a new workspace by itself, with all other workspaces closed, so that no other script could be causing an issue?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for your help.

      1. Coding after 20 years again and new to C#. Like your memory point. changed that.
      2. Learned something new about from the link Thanks. I ran the print statement on strategy as you can notice in screenshot some values are not renderable error is showing up..
      3. Yes only 1 workspace.
      5. The price chart on top continues to show however automatic trading stops after this error.
      6. This indicator by itself vanishes including history of 9 days when it was working fine.
      7. I have another script on this chart but that runs fine. That script is AccumDist from NinjaTrader.

      BTW that other script AccumDist from Ninja Trade download has a line in it and I dont understand the purpose of the initial part .

      "AD[0] = ((CurrentBar == 0 ? 0 : AD[1]) + (high0.ApproxCompare(low0) != 0 ?"

      This above line is part of the other downlaoded script that works fine - AD[0] = ((CurrentBar == 0 ? 0 : AD[1]) + (high0.ApproxCompare(low0) != 0 ? (((close0 - low0) - (high0 - close0)) / (high0 - low0)) * volume0 : 0));

      My script which is just this throws error.

      AD[0] = (((Close[0] - Open[0]) - (High[0] - Low[0])) / (High[0] - Low[0])) * Volume[0];
      Attached Files
      Last edited by rocketstock; 12-20-2020, 10:38 PM.

      Comment


        #4
        Hi Chelsea,

        This fixed the error but I'm not sure if this is the right way to avoid the 0 value divide. your thoughts? Ami still seeing a valid value on chart?

        if ((high0 - low0)>0)
        {
        AD[0] = (((Close[0] - Open[0]) - (High[0] - Low[0])) / (High[0] - Low[0])) * Volume[0];
        }
        else
        {
        AD[0]=0;
        }

        Comment


          #5
          Hello rocketstock,

          I am not familiar with AccumDist.

          I recommend contacting the original author to inquire about their custom code.

          What does this calculation evaluate as before it is assigned to a plot?
          Have you ensured that you are not trying to divide by zero?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hi Chelsea,

            I mentioned the other script as an example. This problem is with my own script that is similar. Sorry for the confusion.

            I did fix the zero value in my script as in previous message. .Wondering is that is the right way to fix this problem.

            Thanks,

            Comment


              #7
              Hello rocketstock,

              That would depend on what the problem is.

              A CalculateMinMax error would mean that a plot has been assigned an invalid value or the MinValue MaxValue has been assigned an invalid value.

              May I have the output from the prints?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                yes below is similar to my last attachment for output window. One error less since i added the divided by zero fix.

                | AD [1] -23955.3 | AD [0] -19159.3666666667
                | AD [1] -19159.3666666667 | AD [0] -27875.7027027027
                | AD [1] -27875.7027027027 | AD [0] -7299.04
                | AD [1] -7299.04 | AD [0] -9294.13333333333
                | AD [1] -9294.13333333333 | AD [0] -13296.6206896552
                | AD [1] -13296.6206896552 | AD [0] -17466.96
                | AD [1] -17466.96 | AD [0] -10809.9473684211
                | AD [1] -10809.9473684211 | AD [0] -12407.0555555556
                | AD [1] -12407.0555555556 | AD [0] -12268.9411764706
                | AD [1] -12268.9411764706 | AD [0] -3422.72727272727
                | AD [1] -3422.72727272727 | AD [0] -10425.3793103448
                | AD [1] -10425.3793103448 | AD [0] -15296.4166666667
                | AD [1] -15296.4166666667 | AD [0] -10315.9444444444
                | AD [1] -10315.9444444444 | AD [0] -16787.4444444444
                | AD [1] -16787.4444444444 | AD [0] -6273
                | AD [1] -6273 | AD [0] -15379.2272727273
                | AD [1] -15379.2272727273 | AD [0] -18647.55
                | AD [1] -18647.55 | AD [0] -55090.3571428571
                | AD [1] -55090.3571428571 | AD [0] -91874.7115384615
                | AD [1] -91874.7115384615 | AD [0] -11088.9696969697
                | AD [1] -11088.9696969697 | AD [0] 0
                | AD [1] 0 | AD [0] -2637.6
                Indicator 'ZMovingAverage': Error on calling 'CalculateMinMax' method on bar 227: The calculation results in unrenderable values.
                Indicator 'ZADist': Error on calling 'CalculateMinMax' method on bar 227: The calculation results in unrenderable values.
                | AD [1] -2637.6 | AD [0] -370.5
                | AD [1] -370.5 | AD [0] -1789.94117647059
                | AD [1] -1789.94117647059 | AD [0] -451.153846153846
                | AD [1] -451.153846153846 | AD [0] -1123
                | AD [1] -1123 | AD [0] -1141
                | AD [1] -1141 | AD [0] -1283.7
                | AD [1] -1283.7 | AD [0] -970.538461538462
                | AD [1] -970.538461538462 | AD [0] -1202.46666666667
                | AD [1] -1202.46666666667 | AD [0] -163.636363636364
                | AD [1] -163.636363636364 | AD [0] -836.307692307692
                | AD [1] -836.307692307692 | AD [0] -858.571428571429
                | AD [1] -858.571428571429 | AD [0] -1856
                | AD [1] -1856 | AD [0] -1566
                | AD [1] -1566 | AD [0] -279
                | AD [1] -279 | AD [0] -2865.43333333333
                | AD [1] -2865.43333333333 | AD [0] -397.222222222222
                | AD [1] -397.222222222222 | AD [0] -198.461538461538
                | AD [1] -198.461538461538 | AD [0] -457
                | AD [1] -457 | AD [0] -773.818181818182
                Last edited by rocketstock; 12-20-2020, 11:15 PM.

                Comment


                  #9
                  Hello rocketstock,

                  To save the output to a text file, right-click the output window select Save As.
                  Then you can attach the text file with your post.

                  Below is a link to a forum post that demonstrates using prints to understand behavior which details this.



                  Are you printing the plot value, or are you printing the calculation before it is assigned to the plot?

                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  576 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  334 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  553 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  551 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X