The Dip Trader Strategy as in the Fidelity Trading Strategies website
Author: pete201
Creation Date: 5/11/2012 2:53 PM
profile picture

pete201

#1
Newbie to wealthlab pro 6.3.

In the Fidelity.com site under Research > Backtesting, there is a Dip Trader Strategy (within Dip Buyer category). It has 3 parameters** (Daily dip %, Days Held, Profit Target %). Tried to copy the available DipBuyer strategy, to add these 2 parameters. Not very confident of what I did so far.

I would appreciate if someone can point me to where this may available in this forum, perhaps under different name.

Thank you in advance.
Pete

** Parameter Description (from Fidelity research)
The Daily Dip % is the amount below the prior day’s close at which you want to buy a specific stock.
Days Held is the number of days you want to hold the stock before selling it.
Profit Target % is the percentage amount for the stock to rise before selling it.
profile picture

Cone

#2
Welcome Pete. If this looks good to you, I could add it to the Strategy library for download. Note that you can get a bunch more scripts by opening the Strategy Explorer (Ctrl+O) and using the Download.. feature in the toolbar.

CODE:
Please log in to see this code.
Note that when backtesting with daily bars, it's not possible to test if you reach the profit target on the same bar as the trade was entered. If this is required, you must use intraday data to test this strategy and modify the script for that.

Also, see the comments at the end of the script and see the wiki link.
profile picture

pete201

#3
Cone,
Thank you for your help! I took your code and added some stmts for intraday trades. Here it is. There is likely a simpler approach, but I enjoyed learning the coding technique. Have not looked at your links on priority trades yet. I am trying another variation of this, where an optional trailing stop trade is also placed using a 4th parameter.
Pete

CODE:
Please log in to see this code.

profile picture

Cone

#4
That's a good try, but you shouldn't ever assume that there are 390 1-minute bars in a day, or 78 5-minute bars, etc. Basically, if no trades occur during an interval, no bar will appear for it. This can happen, for example, at the beginning of the day during the NYSE staggered openings or even more often for illiquid stocks.

Let me get back to you on this after I check something during market hours.
profile picture

Cone

#5
For intraday help, be sure to check out the Community.Components extension's Intraday Support Functions. Once you install the Extension (get it from Extensions in the menu above), this version of the script will be more robust.

But heck, Community.Components.Utility.DaysInPosition isn't working like I expected (even though I wrote the method), so we should add the overloaded method shown below. There are two ways to look at DaysInPosition. The way it's currently written in Community.Components toggles the day on the first bar of the day, but I dislike how it returns '2' on the bar on which the Position is entered.

With the method below, if you pass "false" to countByLastBarOfDay it will return '1' on the first bar of the next day, '2' on the first bar of the second day after the Position was entered, etc.

If you pass "true" to countByLastBarOfDay it returns '1' on the last bar of the same day the Position was entered, '2' on the last bar of the next day, etc. This is more useful to trigger an exit on the first bar of the next day.

(Note for Eugene: You could add this new overload without changing the other methods so as not to break clients.)

CODE:
Please log in to see this code.
profile picture

Eugene

#6
Thanks, the new overload will be available in C.Components next month.
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).