Hello everyone,
Today I'm trying to calculate my Delta since the SDK doesn't allow it directly. I'm able to get close to reality, but I still have some discrepancies when there are a lot of trades. During calm phases, I manage to obtain the correct Delta, but sometimes when the market speeds up, my Delta is no longer accurate (even though it remains relatively consistent, I would like to get the exact value). Below, I'm sharing the code and a screenshot to illustrate this.
Thanks to anyone who can help me!
pastebin.com

@Override
public void onBarClose(DataContext ctx) {
getDelta(ctx);
}
private void convert(long time) {
long timestamp = time;
Date date = new Date(timestamp);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
debug("Date et heure correspondantes : " + sdf.format(date));
}
private void getDelta(DataContext ctx) {
Instrument instrument = ctx.getInstrument();
if (instrument == null) return;
long startTime = ctx.getDataSeries().getStartTime();
long endTime = ctx.getDataSeries().getEndTime();
List<Tick> ticks = instrument.getTicks(startTime, endTime);
int bidCount = 0;
int askCount = 0;
for (Tick tick : ticks) {
if (tick.isAskTick()) {
askCount++;
}
else{
bidCount++;
}
}
debug("Nombre de ticks Bid: " + bidCount);
debug("Nombre de ticks Ask: " + askCount);
debug("Delta : "+ (askCount-bidCount));
debug("Volume :"+ ctx.getDataSeries().getVolume());
convert(startTime);
convert(endTime);
debug("////////////////////////////////////////////////////////////////////////");
}
Today I'm trying to calculate my Delta since the SDK doesn't allow it directly. I'm able to get close to reality, but I still have some discrepancies when there are a lot of trades. During calm phases, I manage to obtain the correct Delta, but sometimes when the market speeds up, my Delta is no longer accurate (even though it remains relatively consistent, I would like to get the exact value). Below, I'm sharing the code and a screenshot to illustrate this.
Thanks to anyone who can help me!

@Override public void onBarClose(DataContext ctx) { getDelta(ctx); - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

@Override
public void onBarClose(DataContext ctx) {
getDelta(ctx);
}
private void convert(long time) {
long timestamp = time;
Date date = new Date(timestamp);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
debug("Date et heure correspondantes : " + sdf.format(date));
}
private void getDelta(DataContext ctx) {
Instrument instrument = ctx.getInstrument();
if (instrument == null) return;
long startTime = ctx.getDataSeries().getStartTime();
long endTime = ctx.getDataSeries().getEndTime();
List<Tick> ticks = instrument.getTicks(startTime, endTime);
int bidCount = 0;
int askCount = 0;
for (Tick tick : ticks) {
if (tick.isAskTick()) {
askCount++;
}
else{
bidCount++;
}
}
debug("Nombre de ticks Bid: " + bidCount);
debug("Nombre de ticks Ask: " + askCount);
debug("Delta : "+ (askCount-bidCount));
debug("Volume :"+ ctx.getDataSeries().getVolume());
convert(startTime);
convert(endTime);
debug("////////////////////////////////////////////////////////////////////////");
}