Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Total Volume for the day indicator

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

    Total Volume for the day indicator

    Hello, I created an indicator that calculates the sum of bars volume for a period of bars. (See code below) I need help converting the period from a hard number to the number of bars since open (9:30AM ET) This would be plotted in a one minute chart. Any suggestions welcomed. Thanks.

    Code:
    protected override void OnBarUpdate()
            {
    
                //Add your custom indicator logic here.
    
                Value[0] = 0;
                if (CurrentBar < Period) return;
    
    
    
                double totalVolume = 0;
                for(int i = 0; i <= Period; i++)
                {
                    totalVolume += Volume[i];
    
                }
    
                TotalVol[0] = totalVolume;
    
            }​

    #2
    Hello designer01,

    Thanks for your post.

    Something you could consider is creating a Time Comparison condition that checks if the Time is 9:30AM and save the CurrentBar value to an int variable named something like CurBarAt930.

    Then, create a condition that checks if CurrentBar > CurBarAt930 and save the CurrentBar - CurBarAt930 to an int variable named something like BarsSince930 to get the number of bars that have passed since 930AM.

    I have attached a simple example script demonstrating this concept. The indicator prints out the number of bars that have processed since 930AM to the Output window as well as the CurrentBar value and CurrentBar value at 9:30AM (CurBarAt930) so you could compare them to the BarsSince930.

    Creating Time Comparisons: https://ninjatrader.com/support/help..._builder.htm#H owToCreateTimeComparisons
    CurrentBar: https://ninjatrader.com/support/help...currentbar.htm

    Please let me know if I may assist further.​
    Attached Files
    Last edited by NinjaTrader_BrandonH; 03-05-2023, 08:16 PM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    232 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    150 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    161 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    243 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    198 views
    0 likes
    Last Post CarlTrading  
    Working...
    X