As volumetric are not the main dataseries, I added the following line where I specified a different Trading Hours template.
AddVolumetric(null, BarsPeriodType.Day, 1, VolumetricDeltaType.BidAsk, 1, "CME US Index Futures RTH",true);
I don't know what could be wrong. Any ideas?
Thank you!
This is my code:
public class POCdeOF : Strategy
{
private double price;
private double price0=0;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "POCdeOF";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
AddVolumetric(null, BarsPeriodType.Day, 1, VolumetricDeltaType.BidAsk, 1, "CME US Index Futures RTH",true);
}
}
protected override void OnBarUpdate()
{
if (Bars == null)
return;
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
if (barsType == null)
return;
if (BarsInProgress == 1)
{
if(price0 !=barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price))
{
Print("Maximum Combined: " + barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price) + " at price: " + price);
price0=barsType.Volumes[CurrentBar].GetMaximumVolume(null, out price);
}
}
Comment