Buying/Selling at Average Prices
Author: bblidner
Creation Date: 6/23/2009 8:33 AM
profile picture

bblidner

#1
Is it possible to back-test strategies using average prices i.e., either (Open Price + Close Price)/2 or (High Price + Low Price)/2. I've looked thru posts on this site and have searched the WL Users Guide and WealthSript QuickRef with no luck. I have learned that I can plot average prices (not much help) and that there is a "function" called PriceAverageC, which sounds helpful but does not appear to be in WL Users Guide as this term returns no hits when I do an index search.

Would appreciate knowing if this is possible and, if so, being pointed to examples of how to incorporate averages prices into code based strategies that have relatively simple entry and exit rules.

Thanks,
BBB
profile picture

Cone

#2
Hi BBB,
I'm not sure if you posted in the correct forum since you're using the terms PriceAverage and PriceAverageC, which are the Version 4 indicators.

In Version 5 (.NET), to which this forum is dedicated, open the Indicators dialog, find AveragePrice and AveragePriceC in the Standard Indicators section, and click on the bottom for links to documentation and examples in the WL5 Wiki. Also, the WealthScript Programming Guide discusses how to use indicators with many examples.
profile picture

bblidner

#3

Cone,

Sorry, but I still need help.

I'm using Wealth-Lab Pro 5.3.

By "Indicators" dialogue, do you mean the "Technical Indicator" section of this site? If I do a search for "Average Price" or "AveragePriceC" on this site, I get about 20 returns - none of which appears to provide any help with regard to using average prices to back-test strategies.

I have gone to WL5 Wiki and have found Average Price and AveragePriceC in their list of standard indicators. Unfortunately, the examples provided deal with plotting averages prices. This does not help me use average prices, rather than BuyAtMarket & SellAtMarket or BuyAtMarket & SellAtClose, in back-testing.

I can also find Average Price and AveragePriceC information in the WealthScript Programming Guide, however, the examples provided deal with plotting averages prices. Again, this does not help me modify a script to use average prices to back-test strategies.

Can you help?

Thanks,
BBB

profile picture

Cone

#4
BBB, search the User Guide if you're not familiar with the terminology. There are at least 3 ways to open the Indicators Dialog in WLP5, but if you start with the Tools menu, you'll discover 2 of them.

QUOTE:
This does not help me use average prices, rather than BuyAtMarket & SellAtMarket or BuyAtMarket & SellAtClose, in back-testing.
How do you want to use the indicators? Be specific. Very specific.
profile picture

bblidner

#5
Cone,

Sorry if I lack the terminology/programming language skills needed to communicate accurately. Let me try to clarify and be as specific as possible for me.

I don't want to use AveragePrice or AveragePriceC as an indicator in a strategy. I have a strategy in Wealth-Lab Pro 5.3 using other indicators that are generating Buy and Sell signals. I am currently back-testing the performance of this strategy using either 1) BuyAtMarket and SellAtMarket or 2) BuyAtClose and SellAtClose. I don't want to back-test my strategy based on either BuyAtMarket/SellAtMarket or BuyAtClose/SellAtClose. I want to backtest by "buying" at the average price, (Open + Close)/2, for the bar associated with each Buy signal and "selling" at the average price, (Open + Close)/2, for the bar associated with each Sell signal.

Can this be done? If so, please direct me to examples that would allow me to see how I can accomplish this goal.

Thank you for your patience and help.
BBB
profile picture

Eugene

#6
How is it possible to buy at the average price for the bar associated with each signal? The price is simply unknown until the end of the bar.
profile picture

Cone

#7
Well, answering the question, yes, it can be done. As Eugene points out, you can't know the average price to buy until the bar is already complete, therefore creating such a strategy is non-realizable, i.e., it's peeking. You can do it to arrive at theoretical results that are impossible to duplicate in real life.
profile picture

bblidner

#8
Cone,

Thanks for your latest response to my request for assistance.

I do understand using average prices involves peeking.

In my case, I have carefully and extensively examined the daily closing data for the months in which a monthly buy or sell signal is generated. The daily closing data strongly indicates that a buy or a sell signal will probably be generated at the end of the month. This happens early in the month if prices are moving sharply, late in the month if prices are moving slowly and at mid month if prices are moving moderately. I know that there are no guarantees until the end of the month, however, the daily data appears to give an 80 - 90% probability that a monthly signal will occur. My best way of approximating this effect is to use the average price for the month, i.e., (Open + Close)/2 or a potential variant such as ((0.50*Open) + (0.50*Close)) wherein I can modify the weighting between the Open Price and Close Price for the month.

I am, in fact, currently running the monthly data at BuyAtMarket/SellAtMarket and BuyAtClose/SellAtClose in Raw Profit, taking the two set of trades that result in these two runs, copying them into an offline spreadsheet, determining the average price for these transactions using ((0.50*Open) + (0.50*Close)) and then calculating the change in value in a manner similar to WL-Pro 5.3 calculations using Portfolio Simulation @ 100% equity and 2:1 Margin (see my previous post of 6/12/09). The obvious disadvantage of doing things this way is that I then need to do a very detailed set of calculations to determine the effect of 1)interest income on cash when I'm not "invested", 2) dividends during periods when a stock is held and 3)margin costs if I exceed starting capital/available capital.

Given the above, I'd appreciate your help. Please provide me or direct me to examples that would allow me to back-test my strategy by "buying" and "selling" at the average price, (Open + Close)/2 or ((0.50*Open) + (0.50*Close)), for each monthly bar associated with each Buy each Sell signal.

Thank you,

BBB
profile picture

Cone

#9
Very simple. Select a monthly scale and run this.
CODE:
Please log in to see this code.


Eugene, at your convenience, please add these translations for EnterAt/ExitAtPrice to the Community.Components. tia.
profile picture

Eugene

#10
Thank you, they will appear in the upcoming release.
profile picture

bblidner

#11
Cone,

Thank you!!!

BBB
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).