Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bollinger value is not refreshed

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

    Bollinger value is not refreshed

    Hi,

    In the following script the last vaue of myDataSeries is refreshed within the for-loop. I can see by Print commands that this works. But the calculation of the Bollinger band value for the changed myDataSeries is not recalculated; it is always given the value for n=0.
    What can I do to get a new calculation of Bollinger?

    Thanks

    ==========================

    protected override void OnBarUpdate()
    {
    if (Historical)
    {
    myDataSeries.Set(Close[0]);
    Print(Close[0]);
    return;
    }
    for (int n=0;n<200;n++)
    {
    ttt=Close[1]-n*TickSize;
    myDataSeries.Set(ttt);
    Print(n);
    Print(myDataSeries[0]);
    Print(Bollinger(myDataSeries,2,25).Lower[0]);
    Print(Bollinger(2,25).Lower[0]); // just for comparison
    ....
    }
    }

    #2
    andorre, so would the two Bollingers values you print then be the same? Do you see the same behavior with and without Historical being used?

    Comment


      #3
      This is an example with Historical:
      ===================
      0
      1544,9
      1533,73397881237
      1533,58824025343
      1
      1544,8
      1533,73397881237
      1533,58824025343
      2
      1544,7
      1533,73397881237
      1533,58824025343
      ...
      109
      1534
      1533,73397881237
      1533,58824025343
      ==========================
      Hence, the Bollinger values are different, and they never change!

      Without Historical I get:
      =============================
      **NT** Enabling NinjaScript strategy
      You have reached the maximum threshold of the Output window. Some of your output messages have been surpressed.
      162
      1533,7
      -1626,32065955684
      1531,79271487837
      =============================
      Hence, I cannot see the beginning. The result is not ok.


      My impression is that the new value for myDataSeries is not used in the calculation of the Bollinger band.

      Comment


        #4
        Thanks, I see what you're saying, would you mind attaching the script in full or sending to support at ninjatrader dot com so I could give it a run?

        Thanks,

        Comment


          #5
          I have just mailed you the script.

          Comment


            #6
            From your mail I notice that you see the problem now as well.

            But why does NT not change the myDataSeries value each time it is tried to change within the for loop?

            Comment


              #7
              You recommend that I should simplify my code: But I do have already the most simplified situation:

              For n=0

              myDataSeries[0] is set

              and then

              Bollinger(myDataSeries,2,25).Lower[0]

              is calculated.

              Then, for n=1 a new value for

              myDataSeries[0] is set

              so that a DIFFERENT value for

              Bollinger(myDataSeries,2,25).Lower[0]

              should be calculated. But instead NT delivers the same one!! This is obviously wrong.

              Comment


                #8
                andorre,

                You likely cannot do it this way. The myDataSeries is already held in memory and is not called anew just because you are looping like that.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks, Josh

                  Could one solve the problem within the NT software?
                  What else could I do?

                  Comment


                    #10
                    andorre, I will have either Josh or Bertrand get back to you on Monday.
                    AustinNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    647 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    369 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    108 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    572 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    573 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X