Problems with volume when Pad and Align

Hi, I am implementing a strategy in Australian All Stocks that has a turnover filter

to_filter = Median(Volume, 50) * Close >= to_avg_param;

The issue is that for the stocks with data holes, if I check the Pad and Aling setting (with $XAO.au index), the volume will be filled with previous observation, assuming a volume that was not realized and affecting the calculation for the turnover filter. But if I don't check Pad and Align, the backtest will asume that we do not data holes, use older observations, and still passing the turnover filter. I am getting into very iliquid trades/symbols in my backtest, wich obviusly affects the indicators and the measure of the market impact of my strategy. My goal is to set the volume to 0 in those days that I don't have register for each stock. I've tried using Foreign/SetForeign and calling the same symbol being analized (which does not make sense, but I was looking for getting and processing the volume in a different way) with fixed up parameter set to 0 or 1, but volume series is still filled with the previous observation when Pad and Align is ON. When I run the strategy in one symbol and reference with Foreign another symbol that I know that has data holes, the holes are efectively filled with 0, but this is not possible to implement because I am running the strategy in a whole universe. Thank you in advance.

You could try something like this:

isFilledBar =	O == Ref(O,-1) AND
				H == Ref(H,-1) AND
				L == Ref(L,-1) AND
				C == Ref(C,-1) AND
				V == Ref(V,-1);
				
actualVolume = IIf(isFilledBar, 0, V);				

// Show the filled bar and the bar previous to it for comparison				
Filter =	isFilledBar OR
			Ref(isFilledBar,1);
		
AddColumn(O, "Open");		
AddColumn(H, "High");		
AddColumn(L, "Low");		
AddColumn(C, "Close");		
AddColumn(V, "Volume");		
AddColumn(actualVolume, "Actual Volume");	
1 Like

Hi Esteban,

Instead of using AmiBroker's Pad & Align which exhibits the "repeat of the previous bar, including volume" you could simply use the Date Padding of the Norgate Data plugin configuration within File -> Database -> Configure, as shown:

If using a multi-market approach, where holidays will be different from country-to-country you might want to use "All Weekdays"

To determine whether any given bar has been padded, you can reference this indicator:
https://norgatedata.com/amibroker-usage.php#paddeddate

When Norgate Data pads a bar, OHLC are set to the previous close and Volume & Turnover (aux1) are set zero since no trades occurred during that (padded) day.

2 Likes

Please note that padding is tricky. Padding one way or another has different side effects. For example if you trade with ONE BAR delay (say trade on next bar open which is frequent setup), you would use previous bar data to perform your say position sizing calculations or ranking (position score) or entry signals (like using OBV indicator that includes volume). Now if you use volume in your calculations setting it to zero might have undesirable consequences for next bar (non-padded bar). Also if you use any volatility based indicators based on High and Lows (like ATR for example) padding high and low with close would affect their values as well (artificially decrease volatility even though volatility didn't decrease).

1 Like