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 sjsj2732, Yesterday, 04:31 AM
      0 responses
      28 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      284 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      281 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      132 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      90 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X