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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          161 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          309 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          245 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          349 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          179 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X