I've been developing a Strategy that uses Cumulative Delta, but the positions have been made 1 with 1 Bar of Delay, as image shows:
Entries should be done after a negative delta followed by a positive delta, but it's been taking place 1 bar late after the confirmation.
The code:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "Delta01Test";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
}
else if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Tick, 1);
}
else if (State == State.DataLoaded)
{
VolumeDelta1 = VolumeDelta(Close, Brushes.Red, Brushes.LimeGreen, Brushes.Black, 1, false, 0, false);
VolumeDelta1.Plots[0].Brush = Brushes.Transparent;
VolumeDelta1.Plots[1].Brush = Brushes.Transparent;
VolumeDelta1.Plots[2].Brush = Brushes.Transparent;
VolumeDelta1.Plots[3].Brush = Brushes.Orange;
AddChartIndicator(VolumeDelta1);
MySeriesDeltaL = new Series<double>(this);
MySeriesDeltaS = new Series<double>(this);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 2)
return;
// Set Delta 1 (Long)
if ((IsFirstTickOfBar)
&& (Times[0][0].TimeOfDay >= Hora_Inicio.TimeOfDay)
&& (Times[0][0].TimeOfDay < Hora_Fin.TimeOfDay)
// && (Position.MarketPosition == MarketPosition.Flat)
)
{ MySeriesDeltaL[1] = VolumeDelta1.DeltaClose[1];
if ( MYCONTIDIONS1)
{ ACTIONS1}
else if (MYCONDITIONS2)
{ EnterLong(NumContracts);
Print("Long Position Delta");
}
else
{ ACTIONS3}
What must I done to solve it?
Thanks in advance

Comment