Exploration required from this afl-RSI Divergence

#1
Hi, I need help in adding exploration capabilities to the attached afl (courtsey marketcalls.in). Would appreciate any gurus help:

-----------------

_SECTION_BEGIN("RSI Divergence");
//------------------------------------------------------------------------------
//
// Formula Name: RSI divergence
// Author: Rajandran R
// Url: www.marketcalls.in
// Formula URL:
// Details URL:
//
//------------------------------------------------------------------------------
//
// + scanner
//
//------------------------------------------------------------------------------

/*---------------------------------------------------
RSI Divergence
--------------------------------------------------------*/

GraphXSpace=7;
//n=Param("% Reverse ",12,0,100,1);
n=Optimize("ZIG",9,5,50,1);
per=Optimize("rsi",28,5,50,1);
Buy=Sell=0;
Var = Zig(RSI(per), n);
t= Trough(RSI(per), n, 1);
p= Peak(RSI(per), n, 1);
x[0] =Var[0];
price[0] = C[0];
j=0;

// bearish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == p)
{

j++;
x[j] =Var;
price[j] =C;
if(x[j] <x[j-1] && price[j-1]< price[j])
Sell =1;
}
}

// bullish divergence
for ( i=0; i<BarCount; i++)
{
if(Var == t)
{
j++;
x[j] =Var;
price[j] =C;
if(x[j] >x[j-1] && price[j]<price[j-1])
Buy =1;
}
}
Short=Sell;
Cover=Buy;

Plot(Var, "", 39);
PlotShapes ( IIf(Sell, shapeSmallCircle, shapeNone), colorRed, 0 , Var,0);
PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone), colorBrightGreen, 0, Var,0);

Title ="RSI Divergence" ;
_SECTION_END();

_SECTION_BEGIN("TEMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( TEMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
--------------------

regards
 
#2
Just to clarify, i seek the exploration of Buy and sell signals (plotted as dots). Below is the screen of the afl. Would really appreciate the help from fellow boarders.

These signals are not frequent but when they appear, they are worth considering.
 

Attachments

amitrandive

Well-Known Member
#3
Just to clarify, i seek the exploration of Buy and sell signals (plotted as dots). Below is the screen of the afl. Would really appreciate the help from fellow boarders.

These signals are not frequent but when they appear, they are worth considering.
Exploration Added

Code:
_SECTION_BEGIN("RSI Divergence");
//------------------------------------------------------------------------------
//
// Formula Name: RSI divergence
// Author: Rajandran R
// Url: www.marketcalls.in
// Formula URL:
// Details URL:
//
//------------------------------------------------------------------------------
//
// + scanner
//
//------------------------------------------------------------------------------

/*---------------------------------------------------
RSI Divergence
--------------------------------------------------------*/

GraphXSpace=7;
//n=Param("% Reverse ",12,0,100,1);
n=Optimize("ZIG",9,5,50,1);
per=Optimize("rsi",28,5,50,1);
Buy=Sell=0;
Var = Zig(RSI(per), n);
t= Trough(RSI(per), n, 1);
p= Peak(RSI(per), n, 1);
x[0] =Var[0];
price[0] = C[0];
j=0;

// bearish divergence
for ( i=0; i<BarCount; i++)
{
if(Var[i] == p[i])
{

j++;
x[j] =Var[i];
price[j] =C[i];
if(x[j] <x[j-1] && price[j-1]< price[j])
Sell[i] =1;
}
}

// bullish divergence
for ( i=0; i<BarCount; i++)
{
if(Var[i] == t[i])
{
j++;
x[j] =Var[i];
price[j] =C[i];
if(x[j] >x[j-1] && price[j]<price[j-1])
Buy[i] =1;
}
}
Short=Sell;
Cover=Buy;

Plot(Var, "", 39);
PlotShapes ( IIf(Sell, shapeSmallCircle, shapeNone), colorRed, 0 , Var,0);
PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone), colorBrightGreen, 0, Var,0);

Title ="RSI Divergence" ;
_SECTION_END();

_SECTION_BEGIN("TEMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( TEMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
Filter=Buy OR Sell; 
 
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);
 

Similar threads