This is read-only version of AFL library entry. Ability to add user formulas
and comment is only available from members-only area.
Details:
Formula name:
Divergence indicator
Author/Uploader:
M.Lauronen - pipseeker [at] yahoo.com
Date/Time added:
2004-07-30 11:50:32
Origin:
Keywords:
Level:
medium
Flags:
indicator
DISCLAIMER: Most formulas present in AFL on-line library are submitted
by the users and are provided here on an "as is" and "as available" basis.
AmiBroker.com
makes no representations or warranties of any kind to the contents or the operation
of material presented here. We do not maintain nor provide technical support
for 3rd party formulas. Description:
Here is an indicator which calculates divergencies between the price and RSI.
You can use another strenght/momentum indicator simple by changing one line of code.
Remember to tune the 'period' and 'numChg'
Indicator gives you the buy/sell signal when you see green/red vertical line on the panel.
Formula:
// ********************************************
// INDICATOR :DIVERGENCE
// DATE :07-30-04
// PROGRAMMER :M.Lauronen
// COPYRIGHTS :Public Domain
// ********************************************
// --------------------------------------------
// Recommended AmiBroker indicator settings:
// Level 0
// Percent
// Middle
// Scaling: Custom 0 - 100
// --------------------------------------------
// Adjust the following parameters to suit your needs
period = 5;
numChg = 0.001;
// --------------------------------------------
// Divergence for LONG
// --------------------------------------------
trendMom = RSI(period);
trendZig = Zig(L, numChg);
f = trendZig > Ref(trendZig, -1) AND Ref(trendZig, -1) < Ref(trendZig, -2);
p1 = ValueWhen(f, Ref(trendZig, -1), 1);
p2 = ValueWhen(f, Ref(trendZig, -1), 2);
r1 = ValueWhen(f, Ref(trendMom,-1), 1);
r2 = ValueWhen(f, Ref(trendMom,-1), 2);
f = r1 > r2 AND p1 < p2;
sig = f AND NOT Ref(f, -1) AND trendMom > Ref(trendMom, -1);
_N(str = "(" + period + ")");
Plot(trendMom, "RSI" + str, colorWhite);
Plot(sig * 100, "Sig", colorGreen, styleHistogram + styleThick +
styleNoLabel);
// --------------------------------------------
// Divergence for SHORT
// --------------------------------------------
trendZig2 = Zig(H, numChg);
f = trendZig2 < Ref(trendZig2, -1) AND Ref(trendZig2, -1) > Ref(trendZig2,
-2);
p1 = ValueWhen(f, Ref(trendZig2, -1), 1);
p2 = ValueWhen(f, Ref(trendZig2, -1), 2);
r1 = ValueWhen(f, Ref(trendMom,-1), 1);
r2 = ValueWhen(f, Ref(trendMom,-1), 2);
f = r1 < r2 AND p1 > p2;
sig = f AND NOT Ref(f, -1) AND trendMom < Ref(trendMom, -1);
_N(str = "(" + period + ")");
Plot(sig * 100, "Sig", colorRed, styleHistogram + styleThick + styleNoLabel);
Comments:
Brian Elijah cadvantag [at] goldengate.net 2004-08-01 01:17:21
That is a very good indicator. Why not list it separately? Certainly deserves its own entry in the library.
Bob J.
2004-08-04 23:05:41
Hi noname,
Nice indicator! Can you re-create it for a black background? I tried but I am not that good at program language.
Thanks for a nice indicator!
noname
2004-08-05 17:54:17
2 Lal
This string make color RSI line.
Col = IIf(Div == 1, 4, IIf(Div == -1, 5, 1));
Col = IIf(Div == 1, 4 //color up divergence(Red)
, IIf(Div == -1, 5 //color down divergence(Green)
, 1 //default color(Black)
));
You can change color index.
Al al_hobino [at] yahoo.com 2004-11-14 14:45:25
How can I convert this indicator into a scan or exploration? How can I add the buy and sell clauses (buy when green and sell when red)? Thanks.
Hi Noname,
Can we add yet another kind of divergence in this indicator? I am referring to the book \\\"Technical analysis for the trading professional\\\" by constance brown. If current RSI trough is at a new low while price is not, then its a bullish signal. Same way, if RSI make a new peak while price does not, then its a negative reversal. Thanks.
Raj rajiv1 [at] gmail.com 2010-02-06 22:32:56
Hi Noname:
How can I convert this indicator into a scan or exploration and backtest it? Thanks.