I am trying to combine these two indicators thru copy and paste but the chart 
is becoming too compressed. I have plotted lines and created clouds for RSI 
values of below 40 and above 65. On the top of this RSI I would like to plot 
the divergence indicator:

1st indicator

_SECTION_BEGIN("Custom RSI");
/*
   Based on the book "Technical Analysis for the Trading Professional
   
    ...
*/
Version(5.00);
SetChartBkGradientFill( ParamColor("Backgroud Top Color",
colorSeaGreen),ParamColor("Background Bottom Color", colorSeaGreen));

periods = Param( "Periods", 14, 1, 200);

Plot( RSI( periods), _DEFAULT_NAME(), ParamColor( "Color", colorDarkBlue ),
ParamStyle("Style")  );

ShowMarket = ParamToggle("Bull Or Bear Market", "Bear|Bull");


Plot(40,"",colorRed,styleLine|styleNoLabel);
Plot(65,"",colorRed,styleLine|styleNoLabel);

_SECTION_END();
r = RSI(14); 
Plot( r, "RSI", colorBlack ); 
PlotOHLC( r,r,50,r, "", IIf( r > 65, colorGreen, IIf (r < 40, colorRed, 
colorBlack )), styleCloud | styleClipMinMax, 40, 65 );


Second indicator

// ********************************************
// 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(14);
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);


Reply via email to