I am doing some testing and looking at volume.
The code below is a tiny modification of your example script blockvolume .
private void CalculateMyBlockVolume(bool forceCurrentBar)
{
bool inTransition = State == State.Realtime && BarsArray[1].Count - 1 - CurrentBars[1] > 1;
int whatBar = State == State.Historical || inTransition || Calculate != Calculate.OnBarClose || forceCurrentBar ? CurrentBars[1] : Math.Min(CurrentBars[1] + 1, BarsArray[1].Count - 1);
if ((Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)BarsArra y[1].GetVolume(whatBar)) : BarsArray[1].GetVolume(whatBar)) >= BlockSize)
{
if (!inTransition && hasCarriedOverTransitionTick && !forceCurrentBar && Calculate == Calculate.OnBarClose)
CalculateMyBlockVolume(true);
hasCarriedOverTransitionTick = inTransition;
blockValue += CountType == CountType.Volume ? (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)BarsArra y[1].GetVolume(whatBar)) : BarsArray[1].GetVolume(whatBar)) : 1;
if(Volume[0] != 0)// I tried also changing this to != null
{
mystr = Volume[0].ToString();
mystr.Remove(2);
Print(Volume[0].ToString() + " " + mystr);
}
Error on calling 'OnBarUpdate' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
Can you assist with where I am going wrong with this?
If i change mystr.Remove to (1) - it works but doesn't alter the no of digits in the Print stmt.?
edit - also what is bar -1; I am unsure how that can exist?
Comment