Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Summation of previous bars

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

    Summation of previous bars

    Can someone point me in the right direction to learn how to create a loop (or whatever is necessary) to do the following:

    While a certain condition is met, add the result of an indicator (such as volume) on each successive bar and store it as a double or int that can be plotted.

    Thank you for any tips.

    #2
    Originally posted by jmflukeiii View Post
    Can someone point me in the right direction to learn how to create a loop (or whatever is necessary) to do the following:

    While a certain condition is met, add the result of an indicator (such as volume) on each successive bar and store it as a double or int that can be plotted.

    Thank you for any tips.
    Though you could use a loop, that looks like a straight accumulation scheme is what you need: loops are generally inefficient, and I avoid them if I can find another method.

    Code:
     
    private double TotalSum = 0;
    Code:
     
    bool ConditionMet = false;
     
    // code to evaluate and set ConditionMet goes here
     
    if (ConditionMet)  TotalSum += Volume[0];
    else TotalSum = 0;
    For Volume, you probably do want to use int: double is just a more general illustration of the principle.

    Comment


      #3
      koganam, as always, thank you for your help

      Comment


        #4
        If I have an indicator that plots both in a separate indicator panel (using plots) and then places lines on the chart, how do I set this up in the script?

        Thank you

        EDIT: With a quick search, it looks like that is not possible. I'll create two indicators
        Last edited by jmflukeiii; 07-07-2012, 01:16 PM.

        Comment


          #5
          Originally posted by jmflukeiii View Post
          If I have an indicator that plots both in a separate indicator panel (using plots) and then places lines on the chart, how do I set this up in the script?

          Thank you

          EDIT: With a quick search, it looks like that is not possible. I'll create two indicators
          Look up DrawOnPricePanel.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          599 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          344 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          558 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          557 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X