This Traders’ Tip is based on “The Degree Of Complexity” by Oscar Cagigas in the February issue of Stocks & Commodities.
The five Donchian breakout systems described by Cagigas in his article are coded using the following rules:
System | Entry rule | Exit rule | Entry price formula | Exit price formula |
2 Param-Long | Buy2P | ExitBuy2P | Buy2Ppr | ExitBuy2Ppr |
2 Param-Short | Sell2P | ExitSell2P | Sell2Ppr | ExitSell2Ppr |
4 Param-Long | Buy4P | ExitBuy4P | Buy4Ppr | ExitBuy4Ppr |
4 Param-Short | Sell4P | ExitSell4P | ell4Ppr | ExitSell4Ppr |
6 Param-Long | Buy6P | ExitBuy6P | Buy6Ppr | ExitBuy6Ppr |
6 Param-Short | Sell6P | ExitSell6P | Sell6Ppr | ExitSell6Ppr |
8 Param-Long | Buy8P | ExitBuy8P | Buy8Ppr | ExitBuy8Ppr |
8 Param-Short | Sell8P | ExitSell8P | Sell8Ppr | ExitSell8Ppr |
9 Param-Long | Buy9P | ExitBuy9P | Buy9Ppr | ExitBuy9Ppr |
9 Param-Short | Sell9P | ExitSell9P | Sell9Ppr | ExitSell9Ppr |
The EDS code file has the backtests already set up for all of these long and short rules. In Figure 5, I show a typical setup for the pricing. In Figure 6, I show a typical setup for the exit rule.

FIGURE 5: AIQ. Here is a typical setup for the pricing portion of the backtests.

FIGURE 6: AIQ. Here is a typical setup for the exit portion of the backtests.
The AIQ code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm, and is also shown below.
!THE DEGREE OF COMPLEXITY !Author: Oscar G. Cagigas, TASC Feb 2014 !Coded by Richard Denning 12/7/13 !www.TradersEdgeSystems.com ! CODING ABBREVIATIONS: C is [close]. H is [high]. L is [low]. O is [open]. PEP is {position entry price}. PD is {position days}. ! PARAMETERS: donLen1 is 40. donLen2 is 15. atrLen is 20. atrMult is 1.0. atrStop is 4.0. maLen1 is 10. maLen2 is 100. rsiLen is 14. rsiUpper is 70. rsiLower is 30. atrMult2 is 0.6. minMov is 0.01. !------------------------------------------------------------------ ! AVERAGE TRUE RANGE (AS DEFINED BY WELLS WILDER) WWE is 2*(atrLen-1). TR is Max(H - L,max(abs(valresult(C,1) - L),abs(valresult(C,1)- H))). ATR is expAvg(TR,WWE). ATR1 is valresult(ATR,1). !------------------------------------------------------------------ !! RSI WILDER !To convert Wilder Averaging to Exponential Averaging use this formula: !ExponentialPeriods = 2 * WilderPeriod - 1. U is C-valresult(C,1). D is valresult(C,1)-C. eLen is 2 * rsiLen - 1. AvgU is ExpAvg(iff(U>0,U,0),eLen). AvgD is ExpAvg(iff(D>=0,D,0),eLen). rsi is 100-(100/(1+(AvgU/AvgD))). !---------------------------------------------------------------- !BASIC SYSTEM 2P (2 parameters): HHdL1 is highresult(H,donLen1,1). HHdL2 is highresult(H,donLen2,1). LLdL1 is lowresult(L,donLen1,1). LLdL2 is lowresult(L,donLen2,1). Buy2P if H > HHdL1. ExitBuy2P if L < LLdL2. Sell2P if L < LLdL1. ExitSell2P if H > HHdL2. Buy2Ppr is max(O,HHdL1 + minMov). ExitBuy2Ppr is iff(ExitBuy2P,min(O,LLdL2 - minMov),C). Sell2Ppr is min(O,LLdL1 - minMov). ExitSell2Ppr is max(O,HHdL2 + minMov). !----------------------------------------------------------------- !FOUR PARAMETER SYSTEM 4P: Buy4P if H > HHdL1 and valrule(TR < atrMult*ATR,1). EB4P1 if L < LLdL2. EB4Pval is PEP - atrStop*valresult(ATR,PD). EB4P2 if L < valresult(EB4Pval,1). ExitBuy4P if EB4P1 or EB4P2. Sell4P if L < LLdL1 and valrule(TR < atrMult*ATR,1). ES4Pval is PEP + atrStop*valresult(ATR,PD) . ES4P1 if H > HHdL2. ES4P2 if H > valresult(ES4Pval,1). ExitSell4P if ES4P1 or ES4P2. Buy4Ppr is max(O,HHdL1 + minMov). ExitBuy4Ppr is iff(EB4P1,min(O,LLdL2 - minMov), iff(EB4P2,min(O,valresult(EB4Pval - minMov,1)),-99)). Sell4Ppr is min(O,LLdL1 - minMov). ExitSell4Ppr is iff(ES4P1,max(O,HHdL2 + minMov), iff(ES4P2,max(O,valresult(ES4Pval + minMov,1)),-99)). !---------------------------------------------------------------- !SIX PARAMETER SYSTEM 6P: SMA1 is simpleavg(C,maLen1). SMA2 is simpleavg(C,maLen2). Buy6P if H > HHdL1 and valrule(TR < atrMult*ATR,1) and valrule(SMA1 > SMA2,1). EB6P1 if L < LLdL2. EB6Pval is PEP - atrStop*valresult(ATR,PD). EB6P2 if L < valresult(EB6Pval,1). ExitBuy6P if EB6P1 or EB6P2. Sell6P if L < LLdL1 and valrule(TR < atrMult*ATR,1) and valrule(SMA1 < SMA2,1). ES6Pval is PEP + atrStop*valresult(ATR,PD) . ES6P1 if H > HHdL2. ES6P2 if H > valresult(ES6Pval,1). ExitSell6P if ES6P1 or ES6P2. Buy6Ppr is max(O,HHdL1 + minMov). ExitBuy6Ppr is iff(EB6P1,min(O,LLdL2 - minMov), iff(EB6P2,min(O,valresult(EB6Pval - minMov,1)),-99)). Sell6Ppr is min(O,LLdL1 - minMov). ExitSell6Ppr is iff(ES6P1,max(O,HHdL2 + minMov), iff(ES6P2,max(O,valresult(ES6Pval + minMov,1)),-99)). !--------------------------------------------------------------- !EIGHT PARAMETER SYSTEM 8P: Buy8P if H > HHdL1 and valrule(TR < atrMult*ATR,1) and valrule(SMA1 > SMA2,1) and valrule(RSI >= rsiUpper,1). EB8P1 if L < LLdL2. EB8Pval is PEP - atrStop*valresult(ATR,PD). EB8P2 if L < valresult(EB8Pval,1). ExitBuy8P if EB8P1 or EB8P2. Sell8P if L < LLdL1 and valrule(TR < atrMult*ATR,1) and valrule(SMA1 < SMA2,1) and valrule(RSI <= rsiLower,1). ES8Pval is PEP + atrStop*valresult(ATR,PD) . ES8P1 if H > HHdL2. ES8P2 if H > valresult(ES8Pval,1). ExitSell8P if ES8P1 or ES8P2. Buy8Ppr is max(O,HHdL1 + minMov). ExitBuy8Ppr is iff(EB8P1,min(O,LLdL2 - minMov), iff(EB8P2,min(O,valresult(EB8Pval - minMov,1)),-99)). Sell8Ppr is min(O,LLdL1 - minMov). ExitSell8Ppr is iff(ES8P1,max(O,HHdL2 + minMov), iff(ES8P2,max(O,valresult(ES8Pval + minMov,1)),-99)). !---------------------------------------------------------------- !NINE PARAMETER SYSTEM 9P: Buy9P if H > HHdL1 and valrule(TR < atrMult*ATR,1) and valrule(SMA1 > SMA2,1) and valrule(RSI >= rsiUpper,1) and valrule(TR > atrmult2*ATR,1) . EB9P1 if L < LLdL2. EB9Pval is PEP - atrStop*valresult(ATR,PD). EB9P2 if L < valresult(EB9Pval,1). ExitBuy9P if EB9P1 or EB9P2. Sell9P if L < LLdL1 and valrule(TR < atrMult*ATR,1) and valrule(SMA1 < SMA2,1) and valrule(RSI <= rsiLower,1) and valrule(TR > atrmult2*ATR,1) . ES9Pval is PEP + atrStop*valresult(ATR,PD) . ES9P1 if H > HHdL2. ES9P2 if H > valresult(ES9Pval,1). ExitSell9P if ES9P1 or ES9P2. Buy9Ppr is max(O,HHdL1 + minMov). ExitBuy9Ppr is iff(EB9P1,min(O,LLdL2 - minMov), iff(EB9P2,min(O,valresult(EB9Pval - minMov,1)),-99)). Sell9Ppr is min(O,LLdL1 - minMov). ExitSell9Ppr is iff(ES9P1,max(O,HHdL2 + minMov), iff(ES9P2,max(O,valresult(ES9Pval + minMov,1)),-99)). !----------------------------------------------------------------