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 cmoran13, 04-16-2026, 01:02 PM
      0 responses
      43 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      25 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      163 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      98 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      158 views
      2 likes
      Last Post CaptainJack  
      Working...
      X