Hi @Komakino,
I think your code looks ok, though I haven’t used the OrderFlowVolumeProfile.Update() function in my use.
One thing to check is to make sure your TradingHours parameter value of the volume profile in your code matches the value used on the indicator or whatever you are using to validate. For example, I set my volume profile indicator to RTH hours rather than the data series default, so I need to make sure in code I do the same.
Here’s an example code snippet (almost same as your code) and results I tested on a 1 minute chart. I briefly switched to a 5 minute chart and got correct values there as well.
----- Via values: CB: [5519] -- POC: [7193.25] -- VAH:[7199.75] -- VAL:[7163.25]
----- Via names: CB: [5519] -- POC: [7193.25] -- VAH:[7199.75] -- VAL:[7163.25] -- DevPOC:[7193.25] -- DevVAH:[7199.75] -- DevVAL:[7163.25]
namespace NinjaTrader.NinjaScript.Indicators
{
public class ExampleVP : Indicator
{
private OrderFlowVolumeProfile ofvp;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "ExampleVP";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Tick, 1);
AddDataSeries(Data.BarsPeriodType.Minute, 1);
}
else if (State == State.DataLoaded)
{
ofvp = OrderFlowVolumeProfile(
MarketProfileType.Volume, // ProfileType
MarketProfilePeriod.Sessions, // ProfilePeriod
1, // SessionsToLoad
Bars.TradingHours, // TradingHours
MarketProfileResolution.Minute, // ProfileResolution
68, // ValueAreaPercentage
60 // InitialBalanceMinutes
);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBar < 20)
return;
Print(string.Format("----- Via values: CB: [{0}] -- POC: [{1}] -- VAH:[{2}] -- VAL:[{3}]",
CurrentBar,
ofvp.Values[0][0],
ofvp.Values[1][0],
ofvp.Values[2][0]
));
Print(string.Format("----- Via names: CB: [{0}] -- POC: [{1}] -- VAH:[{2}] -- VAL:[{3}] -- DevPOC:[{4}] -- DevVAH:[{5}] -- DevVAL:[{6}]",
CurrentBar,
ofvp.Poc,
ofvp.ValueAreaHigh,
ofvp.ValueAreaLow,
ofvp.DevelopingPoc[0],
ofvp.DevelopingValueAreaHigh[0],
ofvp.DevelopingValueAreaLow[0]
));
}
}
}
