Login Page - Create Account

Support Board


Date/Time: Thu, 16 May 2024 02:27:52 +0000



[Programming Help] - How to get summation delta for each price for N consecutive bars

View Count: 787

[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 - 197 views
imageNot backtest normal.png / V - Attached On 2021-07-03 17:23:38 UTC - Size: 127.12 KB - 184 views
[2021-07-08 18:52:06]
sushant - Posts: 32
???

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account