Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding multiple statement for values

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

    Adding multiple statement for values

    My description in title likely not correct

    I am trying to modify a indicator I have the has bools to create true or false

    I wish to add several calculations to insert into the bools to make the condition set for the bool simpler to write

    private Series<double> ER0, ER1, ER2, ER3;


    in OnBarUpdate region


    /// Define ER0, ER1, ER2, ER3
    ER3[0] = (High[3] - Low[3]);/// Range High to Low
    ER2[0] = (High[2] - Low[2]);
    ER1[0] = (High[1] - Low[1]);
    ER0[0] = (High[0] - Low[0]);​

    I can compile but I get error when apply to chart - I had working indicator prior to adding these items

    Error states

    Indicator 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

    Thanks

    #2
    Hello DTSSTS,

    In the code you provided you are missing the State.DataLoaded code, are you creating the series in State.DataLoaded?



    Alternatively do you have a currentbar check before this code?

    if(CurrentBar < 3) return;

    Comment


      #3
      OK I have working after several attempts and after reading the help guide link you provided

      FOR THOSE reading this at another time information this is what and where I placed code

      UPPER REGIOIN

      private Series<double> ER0, ER1, ER2, ER3;

      (State == State.DataLoaded) REGION

      ER3 = new Series<double>(this, MaximumBarsLookBack.Infinite);
      ER2 = new Series<double>(this, MaximumBarsLookBack.Infinite);
      ER1 = new Series<double>(this, MaximumBarsLookBack.Infinite);
      ER0 = new Series<double>(this, MaximumBarsLookBack.Infinite);​

      protected override void OnBarUpdate() REGION

      AFTER currentbar check if(CurrentBar < 5) return;

      /// Define ER0, ER1, ER2, ER3
      ER3[0] = (High[3] - Low[3]);/// Range High to Low
      ER2[0] = (High[2] - Low[2]);
      ER1[0] = (High[1] - Low[1]);
      ER0[0] = (High[0] - Low[0]);


      Thanks Jesse​

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      220 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      135 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      150 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      235 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      193 views
      0 likes
      Last Post CarlTrading  
      Working...
      X