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 NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X