Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by gentlebenthebear, Today, 01:30 AM
      2 responses
      13 views
      0 likes
      Last Post gentlebenthebear  
      Started by Kaledus, Today, 01:29 PM
      2 responses
      7 views
      0 likes
      Last Post Kaledus
      by Kaledus
       
      Started by frankthearm, Yesterday, 09:08 AM
      13 responses
      45 views
      0 likes
      Last Post frankthearm  
      Started by PaulMohn, Today, 12:36 PM
      2 responses
      16 views
      0 likes
      Last Post PaulMohn  
      Started by Conceptzx, 10-11-2022, 06:38 AM
      2 responses
      56 views
      0 likes
      Last Post PhillT
      by PhillT
       
      Working...
      X