Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bc Value for Better Volume 3 Indicator is One Bar Late

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

    bc Value for Better Volume 3 Indicator is One Bar Late

    Hello, I created a buffer to call the bc value in the BetterVolume3 indicator in a strategy. The bc value from 0 to 5 determines the volume bar color. My strategy is set for OnBarClose, and this value is always one bar late. bc value should indicate the volume color for Close[0] in the strategy, but it indicates the volume color for Close[1]. I tried enabling and disabling Use2Bars and it didn't make any difference.

    Code:
    // bc = bar color = index number of plot created in Initialize()
    
    bool sameday = eod ? true : (Time[0].Day == Time[1].Day);
    
    bc = 0; // default 0 (normal volume bar)
    
    if (cond1 || (cond11 && sameday))
    {
    bc = 1; //LowVol
    }
    
    if (cond2 || cond3 || cond8 || cond9 || ((cond12 || cond13 || cond18 || cond19) && sameday))
    {
    bc = 2; //ClimaxUp
    }
    
    if (cond4 || cond5 || cond6 || cond7 || ((cond14 || cond15 || cond16 || cond17) && sameday))
    {
    bc = 3; //ClimaxDown
    }
    
    if (cond10 || (cond20 && sameday))
    {
    bc = 4; //Churn
    }
    
    if (bc == 4 && (cond2 || cond3 || cond4 || cond5 || cond6 || cond7 || cond8 || cond9 || (cond12 || cond13
    || cond14 || cond15 || cond16 || cond17 || cond18 || cond19) && sameday))
    {
    bc = 5; //ClimaxChurn
    }
    
    
    // plot stuff
    Values[bc][0] = Volume[0]; //draw the volume bar we found
    
    if (PaintBars && bc > 0)
    {
    BarBrush = Plots[bc].Brush; // paint the price bar
    }
    
    VolEMA[0] = (vwt * (Volume[0] - VolEMA[1]) + VolEMA[1]); // plot average; faster than SMA
    
    } // End OnBarUpdate()
    
    
    #region Properties
    [Browsable(false)]
    [XmlIgnore]
    public double SendVolumeBarType
    {
    get { return bc; }
    }

    #2
    Hello ronaldgreene828,

    Calculate OnBarClose would mean the logic is evaluated when the bar is fully closed. If you were to color a bar, this would be the most recently fully closed bar, not the currently building bar.

    If you want to color the currently building bar, check the logic OnPriceChange or OnEachTick.

    Use TickReplay if this needs to work historically.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    90 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    137 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    120 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    72 views
    0 likes
    Last Post PaulMohn  
    Working...
    X