Is it possible to test the Volume Profile?

I would like to simulate shorting above supports with cover in the support, and vice versa for the opposite side.

looking for material to adapt in the forum I found this code which I wanted to use as a starting point

Here is the code

n_day = 39;

//bar_track = Ref( BarIndex(), -n_day );
for( i = 0; i < BarCount ; i++ )
   // if( !IsNull( bar_track[i] ) )
   // {
		//PriceVolDistribution( priceH, priceL, vol, bins, absolute = False, startbar = 0, endbar = -1 ) 
		mx      = PriceVolDistribution( H, L, V, 100, False, i - n_day, i );
		mx_sort = MxSortRows( mx, False, 1 );
		supp_res_price[i] = mx_sort[0][0];
   // }

//Plots the daily support/resistance price for each day based on lookback of last n_days
Plot( supp_res_price, "supp_res_price", colorWhite, styleThick );

I applied the indicator on a chart and it works.
You can see the white line which actually in an intriguing way indicates levels that seem important

At this point in the code I started adding

Buy   = 0;
Sell  = 0; 
BuyPrice   = Open; 
SellPrice  = Open; 

and I launched the first backtest but an error appears that I am not able to understand and therefore to resolve

it's like, for indicator use, it's functional, but for BackTest use, it's not

I then searched if someone had written a code here in the forum that indicated the Volume Profile values, and then simulated them to use them automatically but I couldn't find anything like this. All Volume Profile codes are developed to display the important values on screen. No code, among those evaluated by me, integrates the rules for Backtesting.

Where am I doing wrong ?
I know that Amibroker has no limits, therefore, there must be a logical limit at the base that however escapes me.

my desire would be to simulate, when the price is very far from the support, I would say at least greater than 4%, to open a position and then close it on the support level.

Unfortunately I don't know how to set up this simulation

Could someone please point it out to me?
thank you in advance

PriceVolDistribution should not be placed inside loop that iterates thru bars.
For proper usage see AFL Function Reference - PRICEVOLDISTRIBUTION - it is OUTSIDE the loop.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.