Login Page - Create Account

Support Board


Date/Time: Thu, 31 Oct 2024 23:25:43 +0000



Post From: How to get summation delta for each price for N consecutive bars

[2021-07-03 17:25:10]
sushant - Posts: 32
using volumeatpriceforbars on this link ACSIL Interface Members - Variables and Arrays: sc.VolumeAtPriceForBars

I wrote the following code

map<float , int> Delta; //mp[price] = vol

s_VolumeAtPriceV2 *p_VolumeAtPrice=NULL;

for(int barIndex = sc.Index; barIndex > max(0 , sc.Index - periodLookback.GetInt()) ; barIndex--)
{
int VAPSizeAtBarIndex = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(barIndex);
for (int VAPIndex = 0; VAPIndex < VAPSizeAtBarIndex; VAPIndex++)
{
if (!sc.VolumeAtPriceForBars->GetVAPElementAtIndex(barIndex, VAPIndex, &p_VolumeAtPrice))
continue;


//Calculate the price. This requires multiplying p_VolumeAtPrice->PriceInTicks by the tick size
float Price = ((float)p_VolumeAtPrice->PriceInTicks) * sc.TickSize;
//Other members available:
int AskVolume = (int)p_VolumeAtPrice->AskVolume;
int BidVolume = (int)p_VolumeAtPrice->BidVolume;
Delta[Price]+= (AskVolume - BidVolume);

}
}


But this is not working at all.
Delta = askvol - bidvol
periodLookBack() = N bars


This code is similar to the code provided but doesn't work

This gives different result during chart replay and normally when applied on chart as it can be shown in the picture attached
imageBacktest.png / V - Attached On 2021-07-03 17:23:34 UTC - Size: 115.91 KB - 213 views
imageNot backtest normal.png / V - Attached On 2021-07-03 17:23:38 UTC - Size: 127.12 KB - 198 views