I’m trying to test a 3-series code in which the 3rd series (BarsPeriodType.Volume, Value=100) will call the “OrderFlowCumulativeDelta” indicator. My idea is to compose a buy condition in which the candle for the cumulative delta for series3 will be green (as part of my buy condition). So, here’s my trial:
private OrderFlowCumulativeDelta CumulativeDelta100buy;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
//(then typical description)
FirstSeries = new BarsPeriod(){BarsPeriodType=BarsPeriodType.Volume, Value=3000};
SecondSeries = new BarsPeriod(){BarsPeriodType=BarsPeriodType.Volume, Value=500};
ThirdSeries = new BarsPeriod(){BarsPeriodType=BarsPeriodType.Volume, Value=100};
}
else if (State == State.Configure)
{
AddDataSeries(FirstSeries);
AddDataSeries(SecondSeries);
AddDataSeries(ThirdSeries);
AddDataSeries(Data.BarsPeriodType.Tick, 1); // not quite sure about this step
}
else if (State == State.DataLoaded)
{
Brush1 = new SolidColorBrush((Color)ColorConverter.ConvertFromS tring("#FFCCCCCC"));
Brush1.Freeze();
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[1] < BarsRequiredToTrade)
return;
if (CurrentBars[2] < BarsRequiredToTrade)
return;
if (CurrentBars[3] < BarsRequiredToTrade)
return;
bool buy_condition_for_seires_1 // easy
bool buy_condition_for_seires_2 // easy
bool buy_condition_for_seires_3 // this is where your kind help is graciously needed
// Here is how I tried to describe buy_condition_for_seires_3
//
bool CumulativeDelta100buy = ((OrderFlowCumulativeDelta(BarsArray[3], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaClose[0]) > (OrderFlowCumulativeDelta(BarsArray[3], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaOpen[0]));
//
bool buy = buy_condition_for_seires_1 && buy_condition_for_seires_2 && buy_condition_for_seires_3;
if (buy)
{
EnterLong(ContractSize);
SetStopLoss("", CalculationMode.Ticks, StopLoss, false);
SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);
}
My problem seems to be that, for condition#3, it’s not accurate so far where it sometimes forms a red candle (on the cumulative delta on series3) where I need it to be only green ones. Any idea how to rectify this simply?
Thank you..

Comment