The variable Trades is set when the strategy is started. If it's started in the middle of a bar being created, it just assigns the first trade to whatever is going on in that volumetric bar.
What I need is for the below code to start counting when the first tick of the new bar is registered, and not when the strategy is started. Hope that makes sense!
==========
Hi there!
I have IWM loaded up on a 20 tick volumetric chart, and it doesn't seem to sync with the IsFirstTickOfBar part of my code. When the chart creates a new 20 tick bar, the 'Trades' variable is at 10. (barsType.Volumes[CurrentBar].Trades)
Here's the code I took from the Guide to see the available variables produced by the volumetric bars. For reference, volCount is a local variable I created to verify that the script is not starting at the proper Trade count when a new bar is created in the chart:
protected override void OnBarUpdate() { if (Bars == null) return; // This sample assumes the Volumetric series is the primary DataSeries on the chart, if you would want to add a Volumetric series to a // script, you could call AddVolumetric() in State.Configure and then for example use // NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as // NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe; NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe; if (IsFirstTickOfBar) // If this is the first tick of a new bar, start all this material { volCount = 1; } // End of First Tick of Bar Print("=========================================== =============================="); Print("VolCount = " + volCount); Print("Bar: " + CurrentBar); Print("Trades: " + barsType.Volumes[CurrentBar].Trades); Print("Total Volume: " + barsType.Volumes[CurrentBar].TotalVolume); Print("Total Buying Volume: " + barsType.Volumes[CurrentBar].TotalBuyingVolume); Print("Total Selling Volume: " + barsType.Volumes[CurrentBar].TotalSellingVolume); Print("Delta for bar: " + barsType.Volumes[CurrentBar].BarDelta); Print("Delta for bar (%): " + barsType.Volumes[CurrentBar].GetDeltaPercent()); Print("Delta for Close: " + barsType.Volumes[CurrentBar].GetDeltaForPrice(Close[0])); Print("Ask for Close: " + barsType.Volumes[CurrentBar].GetAskVolumeForPrice(Close[0])); Print("Bid for Close: " + barsType.Volumes[CurrentBar].GetBidVolumeForPrice(Close[0])); Print("Volume for Close: " + barsType.Volumes[CurrentBar].GetTotalVolumeForPrice(Close[0])); Print("Maximum Ask: " + barsType.Volumes[CurrentBar].GetMaximumVolume(true, out price) + " at price: " + price); Print("Maximum Bid: " + barsType.Volumes[CurrentBar].GetMaximumVolume(false, out price) + " at price: " + price); Print("Maximum Combined: " + barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price) + " at price: " + price); Print("Maximum Positive Delta: " + barsType.Volumes[CurrentBar].GetMaximumPositiveDelta()); Print("Maximum Negative Delta: " + barsType.Volumes[CurrentBar].GetMaximumNegativeDelta()); Print("Max seen delta (bar): " + barsType.Volumes[CurrentBar].MaxSeenDelta); Print("Min seen delta (bar): " + barsType.Volumes[CurrentBar].MinSeenDelta); Print("Cumulative delta (bar): " + barsType.Volumes[CurrentBar].CumulativeDelta); volCount++; }
Hope this is clear, but let me know if you have any questions.
Comment