Taking multiple positions at higher prices
Author: topcat77
Creation Date: 11/13/2009 7:39 PM
profile picture

topcat77

#1
1 MULTIPLE POSITIONS AT SEQUENTIALLY HIGHER LEVELS
The Strategy below allows for multiple positions but these sometimes cluster around the same price. How can I add to the code so that each additional position is only entered into if it is higher than the last position by a specified percentage ? So, for example, after the first position is created a second position may be taken only if it is, say, 2% higher in price than the first position; and the third position will need to be 2% higher than the second and so on (these are shorts)

2 MINIMUM NOMINAL VALUE FOR SECURITY

I would like to establish a threshold level for the nominal price of a security below which the strategy cannot enter into a position. For example, disallow trades if the entry -price for the security is less than $15. The strategy points to a data set of some 70 securities ( modified WealthLab100) some of whose values have fluctuated through and then above this cutoff level so it's tedious to keep altering the dataset
CODE:
Please log in to see this code.

profile picture

Eugene

#2
1 - Use the Position.EntryPrice property of the last position. Here's an example that does just that for pyramiding:

"Add to my position every time the price goes up by, say, 10% of the entry price, up to a maximum number of, say, 4 times..."

2 - Specifically for backtesting, you need to use the price at pre-split levels so that price filters are actually valid. Add using WealthLab.Rules; on top of your Strategy, paste this code snippet right after the start of the Execute() method and refer to dsAdjusted instead of the Close price:
CODE:
Please log in to see this code.

e.g. if( dsAdjusted[bar] > 15 )...
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).