Hi Buwa84. In Amibroker 60 day historical volatility is written as: //60 day Volatility// HV = StDev(ln(Close/Ref(Close,-1)), 60)*100*sqrt(252); To illustrate I have run some tests for you...the following strategy was tested on all of the stocks that currently populate the NYSE. Test runs between 01/01/2004 and 28/02/13. As i mentioned in an earlier post, big volume, HV filter and market environment filter can be combined for nice results. To answer another earlier question...I have added a rule that only trades breakouts when the volume is at least 3 times greater than the 20 day Volume average. 1) The market environment filter can prevent buying during bear markets or when the borad markets are already overbought. 2) The HV filter and large breakout volume are one way of coding a stock that has been relatively benign and then BOOMSHAKKALAKA, we have a sudden jump in volume as well as new highs. I wouldn't trade the system, but it should illustrate that filters can greatly enhance the breakout performance. 50 open positions were allowed at a time, so the sample of breakouts we are testing is significant. All breakouts were held for 10 days. Tests will show us the average 10 day % gain/loss of all breakout positions entered. Note that I have included a market environment filter by stipulating that breakout signals are only valid if the SPY has a 20 day MA above a 50 day MA and a RSI that isn't already overbought. The example strategy is: /////////////////////////////////////////////////////////// SetOption ("MaxOpenPositions" , 50 ); SetPositionSize (2, spsPercentOfEquity ); Index = Foreign ("SPY","C",True); Indexfastma = MA (Index,20); Indexslowma = MA (Index,50); RSIlength = 8; HV = StDev(ln(Close/Ref(Close,-1)), 60)*100*sqrt(252); VolVAl= 40; INDEXRSI = RSIa(Index,RSIlength); Buy = Close > 5 AND Volume > 3 * MA( Volume , 20 ) //test with&without this line// AND MA(Volume,20) > 100000 AND Indexfastma > Indexslowma AND HV < Volval //test with&without this line// AND MA( Close , 40 ) > MA( Close , 120 ) AND C>Ref(HHV(H,40),-1) AND IndexRSI < 65; Sell = 0; ApplyStop (stopTypeNBar,stopModeBars,10,0,False,3) PS=Optimize("position score",1,1,50,1); PositionScore = Random()*PS; ////////////////////////////////////////////////////////////////// Average 10 day return without HV and 3 * VolumeMA filters = 0.07% Average 10 day return with HV and 3 * VolumeMA filters = 0.18% Finally, when keeping our HV and Volume filters but ignoring our market environment filter. E.G. //////////////////////////////////////////////// Buy = Close > 5 AND Volume > 3 * MA( Volume , 20 ) AND MA(Volume,20) > 100000 AND HV < Volval AND MA( Close , 40 ) > MA( Close , 120 ) AND C>Ref(HHV(H,40),-1); ////////////////////////////////////////////// We have have these results... Average 10 day return with no market environment filter = (-0.01)% If you intend on trading stocks as part of a trend following strategy, a market environment filter is the best filter you can add in my opinion. Also be conscious that barely 50% of breakouts in these tests were profitable, regardless of the filter employed. Hope this helps. Regards, Llewelyn
For breakout trades, every dollar I risk brings me 4.7 dollars in return, on average . More than 72% of the trades I place reach at least the first profit target, and then I move the stop to break-even.
Hi Llewelyn, Thanks for your reply and running the test and results. With 50% of the results being not profitable am i chasing the wrong strategy. Also i use finviz to screen but i'm with IB as a broker. I've havent played much with IB screener but on finviz i wasnt able to find HV filter. I also wanted to ask you where do you run the backtest. I would like to run some backtesting on some of there... In your opinoin whats a good place to run backtesting. I do not have any programming language other than some basic VBA skills i use at work... Thanks.
50% not being profitable based on a fixed target or variable target? And what I mean by that is there's more to explore obviously and there's plenty of ways to skin a cat. Whipsaws are inevitable. You simply have to trade through them or develop an additional strategy to compensate. Just my .02
Absolutely. The test I ran was simply to determine how much profit an average stock will return 10 days after a 40 day breakout....it is not a trading strategy. To make my code an actual strategy that returns a 15% + CAR, get rid of the 10 day holding period. Apply a 6 x ATR trailing stop-loss and reduce the max positions to 20. All positions 5% of account equity. There are many breakout strategies that make mega moolah...but I wanted to illustrate that breakouts are not a high win percentage trading strategy in my experience. Other I'm sure will disagree.
Hi again, I use Amibroker for strategy creation and testing. I'm the first to admit that I am no coding expert....but I find Amibroker is relatively intuitive. I suggest books by Howard Bandy for a great place to learn.
I wont trade breakouts. It might mean that market is going in that direction but it wont go straight away. Thats y i goes sideway. Normally i would wait for price tu retrace and i'll use fibs and snr levels to find the best entry in the direction of the breakouts