LDL2 strategy
Author: jsinjur
Creation Date: 9/13/2011 9:06 AM
profile picture

jsinjur

#1
I have a question on exiting the LDL2 strategy at a profit. I have found little discussion on the strategy. Using the trade history for JAZZ. As an example the default profit target is 3% but looking at the history, many profits were higher and some lower. What was used to establish targets? Thanks
profile picture

Eugene

#2
A look at the code reveals the following simple logic: if the Close price is higher than the profit target, the position is sold with an AtMarket order next day (i.e. at open).
profile picture

jsinjur

#3
Thanks. I blank out when I read code but as soon as I saw your explanation and went back to the code I saw the answer. Thanks again.
profile picture

jsinjur

#4
I know the basic formula for the entry price (low+close)/2*.94. I cannot arrive at the correct entry using that formula.

After reading on the subject, I have come across a disclaimer that the formula is based on whole numbers only. That still does not give me the correct entry.

If I use WealthLab toi calculate the entry, I can only duplicate that price to the penny if I use the multiplier .96 not .94.

If we use VRUS for today the low was 71.93, the close 74.08. That would compute to 68.63, yet Wealth Lab is showing 70.04. If I use .96 I can arrive at 70.08 (within pennies).

What am I doing wrong?

Thanks
profile picture

Eugene

#5
You're not doing anything wrong but the saved parameter makes it confusing. The LDL2 strategy has a saved Parameter value for the Limit Multiplier of 0.96. This is what you can see at the bottom of the screen.

If a parameter value has been altered by Save Parameters once (and in fact it was - the Limit Multiplier was overridden to be 0.96), then Reset will honor that change and ignore the default value in Strategy code. (You're not alone, I was also confused by the design here.)

To fix, make "Limit Multiplier" a 0.94, click "Save Parameters". Then the strategy will be executing with its true default multiplier (0.94) when re-opened.

P.S. I think we need to upload a new revision of LDL2 to the website and/or fix that annoyance in the bundled strategy code itself.
profile picture

nnecula

#6
I would like to understand why it is necessary to perform this "if" before buying:

CODE:
Please log in to see this code.


Thanks
profile picture

Eugene

#7
To exclude penny stocks below $5.
profile picture

Cone

#8
I always cringe when I see price tested this way in a script because it's peeking! It's too bad that LDL2 had that rule, but whenever you test historical price values like this you need to reverse the "future" splits. Here's the Execute method for LDL2 with a couple edits, showing how to come up with the reverse split Close series.

Run it on NKE, for example, and notice the "ds" prices before the 12/26/2012 split. This is the actual price level that NKE traded. If you go back before 1995, split-adjusted NKE was trading below 5 and therefore would be incorrectly excluded from the backtest. In reality, NKE never closed below $10 since at least 1987!

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

Eugene

#9
Good point Robert. I've just uploaded the revised LDL2 strategy.
profile picture

eralbanese

#10
Hello,

Is it possible to help me modify the code of the LDL2 strategy (or any similar dip buying / multiple limit strategy ) to only take the first 5 trades as they occurred in a day in backtesting (assuming 20%/5 pos sizing)?

Secondarily, would it be possible to optimize that code to look for hour blocks of time that would produce the best trade windows for those types of strategies? I have one modified version of ldl2 running and another multiple limit strategy with 80+ trades a day on average which has triggers typically all day.

Thank you
Eric
profile picture

Eugene

#11
Eric,

No modification required. The Position Options PosSizer from our PosSizer library is an universal solution that doesn't require coding. Click the button to activate "Max pos. per day" and enter 5 in the input field on the right.

Your other question re: "optimize for hour blocks" looks beyond the scope of this topic (more general). Anyway we've been busy with WL7 launch so please forgive any latency.
profile picture

eralbanese

#12
Eugene,

Thanks for the response. What I am after is only the first 5 limit hits of the day (assuming more than 5 limits were hit that day), not just 5 trades in a day total.

I will open a new thread for the hour blocks, no rush.

Thanks,
Eric
profile picture

Eugene

#13
If it's about sizing Alerts for live trading I don't think it can be approached due to a live bug (#62853 Candidate collection empty for Alert sizing). Otherwise I'm not seeing the difference.
profile picture

eralbanese

#14
Eugene,

I am wanting to look at this approach from a backtesting standpoint only, not live trading. Is that possible?

Thanks,
Eric
profile picture

Eugene

#15
Eric, please clarify what is required from me? I believe you've got all the tooling.
profile picture

eralbanese

#16
Eugene,

When I backtest LDL2, for example, it will randomize the first 5 trades (assuming 20/5) taken on a given day in the backtest period. If I run this backtest over and over it will create a new list of trades on each day that hit the limit value. I want to be able to backtest to only take the first 5 trades as they actually happened on each day during the backtest and disregard all other limit trades that may have hit later in the day. Does that make sense?

Thanks,
Eric
profile picture

Eugene

#17
Your question is not LDL2 specific. Alert randomization takes place when the captial is not insufficient to take all trades. You can turn it off by assigning a Position.Priority or opting for 'Worst-case Portfolio Simulation' in WL's Preferences > Backtest Settings.
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).