Inside Day NR4
Author: zarphan
Creation Date: 7/28/2011 4:15 PM
profile picture

zarphan

#1
I’m looking to backtest Inside day NR4 setup.

Setup
Today’s high< Prior day high
Today’s low> Prior day low
Today’s high/low range is the narrowest of the last 4 days. (you’ll see something like this looking at QQQ in late April)

10day average volume > 500K
A composite ATR based on 10 day and 3 day ATR; so ATR(310)= (ATR(10)+ ATR(3))/2
PCLOSE>=$10.00

LONG setup:
Buy stop at Phigh + .001*ATRC(310)
Sell : 50% at 1 ATRC(310), 25% 2 ATRC(310), 25% 4 ATRC (310)
Stop loss: 1st is PLOW- .0005*ATRC(310); once first target is reached, trail to breakeven; 2nd target, trail to 1st entry


SHORT setup:
Sell stop: plow- .001*ATRC (310)
Buy to cover : 50% at 1 ATRC(310), 25% 2 ATRC(310), 25% 4 ATRC (310)
Stop loss: 1st is PLOW- .0005*ATRC(310); once first target is reached, trail to breakeven; 2nd target, trail to 1st entry

Note: it’s important that ATR values do not update, but remain based upon values calculated when the trade is setup, so that position size can be set for pre-determined dollar stop.


It would be helpful if the code provided the ability to optimize for the multipliers of ATRC (310), both on the buy and stop loss sides, for LONG setup.

profile picture

Eugene

#2
It's all yours:
CODE:
Please log in to see this code.


QUOTE:
It would be helpful if the code provided the ability to optimize for the multipliers of ATRC (310), both on the buy and stop loss sides, for LONG setup.

Wow, considering that right after registering, you hit the support portal first for something that our support policy clearly doesn't cover, you're pretty demanding!

I'm leaving this little coding excercise in StrategyParameters up to you.
profile picture

zarphan

#3
Eugene:

As I (appreciatively) awoke to discover the fruits of your timely endeavors, I wondered “demanding?”…Darn, I thought I was in my “maximum begging” posture.

…and, thank you

David
profile picture

zarphan

#4
Eugene:

CODE:
Please log in to see this code.


Once the 2nd target is hit, the trailing stop should be moved up to the 1st target level, not entry price. My mistake.


In reviewing some charts, a few questions are generated, pertaining to Stops and Targets

Targets
IBM
On 3/23, there is an entry at 159.64; on 4/28, there is a partial exit at 171.36. Given the difference ((ATRC *1) = $11.72). I would expect the next sell to occur at 183.08 (entry + 2 *ATRC), with the stop moved up to the first exit price of $171.36.

I’m wondering if atr3 and atr10 are fixed at the time of entering the trade, and not updating daily; if they are updating daily, then it would explain how positions might be selling at other than targets I would expect.

Stops

CODE:
Please log in to see this code.

BRCM
On 2/4, the system generates an entry at $44.24, and sells 50% at first target on 2/7.
At this point, stop loss should be moved to breakeven, rather than staying open and stopping out for a loss on 2/15.


Similar behavior is noted with MCHP on 3/23 entry.


Non-demandingly requesting assistance, if possible


David
profile picture

Eugene

#5
Disregard my previous code, its behavior is erratic. I've rewritten the strategy using a different pattern. Hopefully, this should fix most of the issues and be more clear to read:
CODE:
Please log in to see this code.
profile picture

zarphan

#6
Eugene:

Thank you once again; displaying the price targets on the chart was inspired, and most helpful. The profit targets now appear to be set at time of trade entry

The resetting of the stops, once a profit target has been reached, doesn’t seem to be in synch just yet.

BRCM:
On February 4, there is a long signal; 1st target is reached the next day. At this point, stop should be ratcheted up to breakeven; it seems to remain at initial stop loss level.


MCHP:
On April 5, long is entered at $17.31; the next day, both the first and 2nd targets are attained. Trailing stop should now be raised to 1st target of 17.59, rather than stopping out on 4/15 at $16.98


If the “gilded lily” might be yet served again, displaying the initial stops on the chart would be helpful.

David

PS: I’ve just noted that, on February 4 BRCM trade, system is selling the entire position at 1st target, rather than 50% of position.

Also, if I’m reading BRCM chart correctly, on January 4, system produces 3 stops at $43.03, creating 3 losing trades rather than 1.
profile picture

Eugene

#7
Re: MCHP and BRCM -- where are you getting those prices from? MCHP is ~$38 on 04/05/2011 (not $17) and there were no trade. Same for BRCM, the February 4 BRCM trade is a loser on my Yahoo chart of BRCM, no profit taking.
QUOTE:
Also, if I’m reading BRCM chart correctly, on January 4, system produces 3 stops at $43.03, creating 3 losing trades rather than 1.

This is by design. I'm creating 3 trades at all times for simplicity sake.
profile picture

zarphan

#8
RE: BRCM

My chart displays a 1st target of 45.92, which is reached 1 trading day (Feb 7).

Not sure why we have different readings, as I'm just compiling the code displayed above.

Trailing stop to breakeven after 1st target is reached is not happening just yet

Thanx
profile picture

Eugene

#9
Re: different readings -- we're looking at different data.
QUOTE:
Trailing stop to breakeven after 1st target is reached is not happening just yet

Seems like a little leftover. After...
CODE:
Please log in to see this code.

there is a line that should be replaced...
CODE:
Please log in to see this code.

With this one:
CODE:
Please log in to see this code.

That should do it, the baseline is working, hope that helps. I have a long list of todo items and not enough time for troubleshooting custom solutions.
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).