[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Please Help A Novice With This Dual Triggers Problem



PureBytes Links

Trading Reference Links

At 02:19 PM 8/19/2006, you wrote:
>Hi friends,
>Please help me... I'm a novice user and having a hard time coding
>this Backtest using AFL.
>
>I've been struggling with this, going through the help files,
>searching this forum... this is probably not a complicated problem
>for veteran users, I just simply don't know how to do this.
>
>My trading idea is:
>
>COVER and BUY when StochK(39) crosses above 20, and the RSI and CCI
>are confirming, and SELL and go SHORT when the StochK(39) crosses
>below 80, again with RSI and CCI confirmation.  So this study is
>always be in the market.
>
>My problem is I get multiple trigger signals when the StochK first
>crosses above the 20, but doesn't make it to 80 and reverses back
>below the 20 line only to recross it from below again, triggering
>another buy.  Same problem at the 80 line.  I've changed the settings
>to have only one open position, without effect.
>
>What I really need is a stop and reverse code when the StochK dives
>below the 20 after the BUY trigger, or back above 80 after a SHORT
>trigger.  I can't figure this out.
>
>This is the simple part I've got so far.
>
>Buy = Cross ( StochK(39), 20 ) AND RSI(5) > 30 AND CCI(20) > -150;
>Sell = Cross ( 80, StochK(39) ) AND RSI(5) < 70 AND CCI(20) < 150;
>Short = Sell;
>Cover = Buy;
>
>I sure would appreciate someone looking at this for me and showing me
>how to add the necessary lines.  Thank you!

This sort of thing is a common problem that happens when using Stochastic 
or RSI and other indicators that tend to wander up and down.
You identified two cases. Stoc *Xover 20 but doesn't get to 80 and Stoc 
Xunder 80 but never gets to 20.  One way to handle this is the brute force 
approach with several trigger levels.  Possibilities might include......

1. sto xover 20:     enter
2. sto xover 20 and then xunder 20:     exit
3. sto xover 50:    enter
4. sto xover  50 and then xunder 40:     exit
5. sto xover 50 then xunder 50, holds above 40 and then xover 50 
again:     re-enter or add to position at sto > 60
6. you get tired of watching sto bounce around in the middle ground and you 
exit after x days

Similar thinking can be applied to sells.

Cheers
Sid