I am working on a strategy that works with cumulative delta. The code from my perspective looks fine but there is some issue that stops it from entering into a new position. If anyone can see an issue with these few lines of code and point it out it would be greatly appreciated.
protected override void OnBarUpdate()
{
if (CurrentBars[0] <= BarsRequiredToPlot || CurrentBars[1] <= BarsRequiredToPlot)
return;
// Set 1
if ((TriggerState >= 2)
&& (Position.MarketPosition == MarketPosition.Flat))
{
TriggerState = 0;
}
if (Close[1] > Open[1] && OrderFlowCumulativeDelta(CumulativeDeltaType.BidAs k, CumulativeDeltaPeriod.Bar, 1)[1] < 0 && Position.MarketPosition == MarketPosition.Flat)
{
TriggerState = 1;
EnterLong(Quantity, "long");
SetProfitTarget(CalculationMode.Ticks, BuyProfit);
}
else if (Close[1] < Open[1] && OrderFlowCumulativeDelta(CumulativeDeltaType.BidAs k, CumulativeDeltaPeriod.Bar, 1)[1] > 0 && Position.MarketPosition == MarketPosition.Flat)
{
TriggerState = 1;
SetProfitTarget(CalculationMode.Ticks, SellProfit);
EnterShort(Quantity, "short");
}
Thanks in advance!
Comment