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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X