bar.TickVolume != no onTick event is envoked

Created at 28 Jul 2023, 15:12
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid6370363

Joined 28.07.2023

bar.TickVolume != no onTick event is envoked
28 Jul 2023, 15:12


Hi there,

i observed that bar.TickVolume is about 40% higher than the event Action<TicksTickEventArgs> Tick is triggered per period. My understanding so far is that the tickvolume in forex is the number of price changes of an instrument per period, yet OnTick or Calculate show distinctly lower numbers. 

 


protected override void Initialize()
{ 
_Ticks = MarketData.GetTicks(SymbolName);
_Ticks.Tick += OnTick; 
}

private int lastIdx = -1;
private int noTicksCalculate = 0;
private int noTicksOnTick = 0;

public override void Calculate(int index)
{
if (Bars[index].OpenTime > Time.AddMinutes(-6))
if (lastIdx != index)
{
Print(index + " ticksstat: bar.tickvolume: " + Bars.Last(1).TickVolume + "/ calculate:" +
noTicksCalculate + "/ onTick:" + noTicksOnTick);
lastIdx = index;
noTicksCalculate = 0;
noTicksOnTick = 0;
}

noTicksCalculate++;
}

public void OnTick(TicksTickEventArgs Args)
{
noTicksOnTick++;
}

 

Sample output:

28/07/2023 15:01:00.151 | 7177 ticksstat: bar.tickvolume: 182/ calculate:114/ onTick:113

Question: I expect barTickVolume, the number onTick is called, and the number Calculate-1 is called to be equal.. 

Thanks,
Armin


@ctid6370363
Replies

Spotware
31 Jul 2023, 09:27

Dear trader,

What you have observed is an expected behavior. Calculate() and OnTick are triggered whenever new tick data is received. However there are cases where both bid and ask prices are updated simultaneously, increasing the tick volume by 2. Neverheless, the event is triggered only once.

Best regards,

cTrader Team


@Spotware