Average Daily Price
Author: StreetSmart
Creation Date: 7/2/2009 6:56 PM
profile picture

StreetSmart

#1
Has anybody created a code or extension for calculating Average Daily Price (rather than it's being limited to closing price) for backtesting. I'm using it on Parabolic SAR. My purpose is to get an average price rather than chasing nickels and dimes in intraday pricing.

Second question: In order to do this, whould it be necessary to download the daily data on 15 minute (or so) bars which would take a looooong time with the number of equities I'm tracking.

Thanks,
profile picture

Eugene

#2
Have you seen AveragePrice on the Indicators list?
profile picture

Cone

#3
QUOTE:
Second question: In order to do this, whould it be necessary to download the daily data on 15 minute (or so) bars
See SetScaleDaily() in the QuickRef for creating daily indicators in intraday charts.
profile picture

StreetSmart

#4
QUOTE:
Have you seen AveragePrice on the Indicators list?


Yes. And thats fine for charting. But there's still the limitation in backtesting a strategy based on Average (daily) Price because the rules-based strategy (Parabolic SAR) is limited to Market/Limit/Close.

Therefore, the backtest is based on the Close Price for the day which could be substantially different than the Average Price for the day. As the result, I'm not getting a true reflection of pricing for the purposes of backtesting over a period of several months.

This can also trigger a "false" alert (or action) by a radical move at the end of the day. Again, not reflective of the equity's true intraday price.
profile picture

Cone

#5
QUOTE:
But there's still the limitation in backtesting a strategy based on Average (daily) Price because the rules-based strategy (Parabolic SAR) is limited to Market/Limit/Close.
I'm not sure what you mean by "Market/Limit/Close" (order types), but of course there are limitations with rule-based strategies. When you run into such a limitation, that's when you need to break away from the Strategy Builder and edit the code yourself. At that point, you can program without limitations. If all you need to do is replace one indicator with another, substitution is a simple task for even a non-programmer to do.
profile picture

StreetSmart

#6
Sorry. That was a bad example I gave.

What I'm trying to do is have the back test based on the Average Daily Price (rather than on the closing price).

Any way to accomplish that?

Thanks.

And if there is a way, is it Open+High+Low+Close/4 based on a single daily bar? Or would be be the cumlative total of all bars (closing price)for that day (26 for 15 minute bars)and divided by the number of bars for the day?
profile picture

Eugene

#7
QUOTE:
What I'm trying to do is have the back test based on the Average Daily Price (rather than on the closing price).

As Robert said above, it's easily can be done in code even for a non-programmer if you open the generated code in a new window and substitute the Close with AveragePrice (or AveragePriceC).

QUOTE:
is it Open+High+Low+Close/4 based on a single daily bar?

The indicator will be based on the underlying bar scale. For daily data, it will be based on a single daily bar, except that the formula is different. See the indicator documentation in our WL5 Wiki: AveragePrice

However, the other idea can also be programmed but will require intraday data.
profile picture

Cone

#8
QUOTE:
What I'm trying to do is have the back test based on the Average Daily Price (rather than on the closing price).
What does "based on" mean to you, precisely? Considering that the calculation of the Parabolic does not even use the close - only the high and low values - what do you want to apply AveragePrice to?

I'm asking because now I feel like you're thinking about something that we aren't - especially because you asked the question if AveragePrice is based on a single bar or not. I ask you, if AveragePrice weren't based on a single bar, what would it be based on?
profile picture

StreetSmart

#9
Eugene: Perfect! I'll replace Close with AveragePrice. That should accomplish my goal. However, I'm not exactly sure where/how to access the generated code. Could you give me a little direction on that? Thanks.

Cone: You're right. It will average the price on the bar. In thinking it through I realize, if the scale is at 15 minutes, it will gave a daily average based on 26 bars (probably a more accurate reflection of the intraday pricing). If the scale is Daily, it would give an average daily price based on that single bar for the day (not necessarly an accurate average daily price if there was a large swing or tick during the day).

Either way though, for the purposes of back testing, an average daily intraday price is better for my strategy than using the closing daily price. Average intraday price allows a little more "range" for Buy/Sell signals on the day they are alerted -- especially in the case when there's a wildly volatile price move at the end of the day. Thanks.
profile picture

Eugene

#10
To access the generated rule-based code, click the button called "Open Code in new Strategy Window".
profile picture

StreetSmart

#11
When I click "Open Code in New Strategy Window" It opens up a chart and then gives me a pop up error message saying "Unhandled exception has occured in your application... Index was out of range. Must be non-negative and less than the size of collection".

In fact, I get that error pop up when opening a NEW strategy always. Usually I can just click continue and open a DIFFERENT strategy (which is just re-opening the original one).

However in this case -- "Open Code in new Strategy Window" -- clicking continue just makes the pop up go away and I still can't enter into the code window.
profile picture

Eugene

#12
Error in Strategy editor is a known bug of version 5.3. Upgrade to version 5.4 to fix it.
profile picture

StreetSmart

#13
I'm using v. 5.4.20.0

Still can't open the strategy editor without error message
profile picture

Eugene

#14
Sorry for the inconvenience. Probably the error occurred first before upgrading to 5.4. This solution is going to help you:
Strategy editor does not function
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).