Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intraday Cumulative Values

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

    Intraday Cumulative Values

    I am attempting to create an intraday indicator that will zero out at the beginning of each day and then plot a cumulative total of (High+Low+Close)/3. The following code plots the correct (High+Low+Close)/3, but it does not plot a cumulative sum. Can anyone help me figure out what I am doing wrong?


    double cumulative=0;

    if (Bars.FirstBarOfSession && FirstTickOfBar)
    cumulative = 0;

    cumulative=cumulative+(High[0]+Low[0]+Close[0])/3;

    Plot0.Set(cumulative);


    Thanks in advance.

    Bob

    #2
    If all of that code is inside a single function, then "cumulative" is a local variable, getting set to zero each time the function is called. Try making it either static or a class variable.

    --EV

    Comment


      #3
      Hello,

      If ETF idea does work, I would need to see your entire code block.

      For example not sure what

      double cumulative=0;


      This is doing, Is this inside OnBarUpdate() (If So its the problem)or are you just showing my how you decared it in the variable section?

      I look forward to assisting you further.
      BrettNinjaTrader Product Management

      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