Hybrid AFL ***RSI_Slow Stochastic_**

#1
Can any one please help me to combind two of the afl
// ***RSI_Slow Stochastic_**
_SECTION_BEGIN("Stochastic %K");
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Plot( StochK( periods , Ksmooth), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("Stochastic %D");
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
Plot( StochD( periods , Ksmooth, DSmooth ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("RSI");
SetChartOptions(0,0,chartGrid30|chartGrid70);
periods = Param( "Periods", 15, 1, 200, 1 );
Plot( vrsi = RSI( periods), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );

if( Status("action") == actionCommentary )
{

Buy = Cross( vrsi, 30 );
Sell = Cross( 70, vrsi );

printf( "The current value for the RSI" + periods + " is " + WriteVal( vrsi ) );

printf("\n\nThe RSI, written by J. Welles Wilder in 1978, can be used in several different ways to analyze a chart.\n");

printf("Tops and Bottoms:\n\n");

printf(
WriteIf( vrsi > 70, "The RSI is above 70. This is where it usually tops. The RSI usually forms tops and bottoms before the underlying security.",
WriteIf( vrsi < 30, "The RSI is below 30. This is where it usually bottoms. The RSI usually forms tops and bottoms before the underlying security.",
"The RSI is not currently in a topping (above 70) or bottoming (below 30) range. "
+ WriteIf( Cross( 70, vrsi ), "However, the RSI just crossed below 70 from a topping formation. This is a bearish sign.",
WriteIf( Cross( vrsi, 30 ), "However, the RSI just crossed above 30 from a bottoming formation. This is a bullish sign.", "" ) ) ) ) );

bars30 = BarsSince( Buy );
bars70 = BarsSince( Sell );

printf("\n\nBuy/Sell signals:");
printf("\nA buy or sell signal is generated when the RSI moves out of an overbought/oversold area. \nThe last signal was a "+
WriteIf( bars30 < bars70, "buy", WriteIf( bars30 > bars70, "sell", "" ))+
WriteVal( Min( bars30, bars70 ), 3.0 ) + " period(s) ago.");

printf("\n\nChart Formations:");

printf("\nThe RSI often forms chart patterns (such as head and shoulders or rising wedges) and support/resistance levels that may or may not be visible on the price chart. "+
"Since the analysis of chart patterns/formations is subjective, the automatic interpretator cannot find them. Please visually inspect the chart and look for such patterns.");

printf("\n\nFailure Swings (also known as support or resistance penetrations or breakouts):");
printf(
WriteIf( vrsi >= HHV( vrsi, 14 ), "The RSI has just reached its highest value in the last 14 period(s). This is bullish.",
WriteIf( vrsi <= LLV( vrsi, 14 ), "The RSI has just reached its lowest value in the last 14 period(s). This is bearish.",
"The RSI does not currently show any Failure Swings." ) ) );

printf("\n\nDivergence:\n");
printf(
WriteIf( Close >= HHV( Close, 14 ) AND vrsi < HHV( vrsi, 14 ),
"The security price has set a new 14-day high while the RSI has not. This is a bearish divergence.",
WriteIf( vrsi >= HHV( vrsi, 14 ) AND Close < HHV( Close, 14 ),
"The RSI has set a new 14-day high while the security price has not. This is a bullish divergence.",
WriteIf( Close <= LLV( Close, 14 ) AND vrsi > LLV( vrsi, 14 ),
"The security price has set a new 14-day low while the RSI has not. This is a bullish divergence.",
WriteIf( vrsi <= LLV( vrsi, 14) AND Close > LLV(Close,14),
"The RSI has set a new 14-day low while the security price has not. This is a bearish divergence.",
"The RSI and price are not diverging." ) ) ) ));

printf("\nThis commentary is not a recommendation to buy or sell. Use at your own risk.");
}
_SECTION_END();



// then the other one


_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop", colorWhite),

ParamColor("BgBottom", colorBlack),ParamColor("titleblock",colorDarkTeal ));
_SECTION_END();


_SECTION_BEGIN("NICK MA Swing");
SetBarsRequired(200,0);

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",1,0.25,5,0.25),0.25,5,0.25);
Per= Optimize("atr",Param("atr",4,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel );
j=Haclose;

//=======================================================================================================================
//=========================Indicator==============================================================================================
f=ATR(14);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;
NW[0] = 0;


for(i = 1; i < BarCount; i++)
{
if(Trend[i-1] == 1)
{
if(j < NW[i-1])
{
Trend = -1;
NW = j + Revers;
}
else
{
Trend = 1;
if((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j > NW[i-1])
{
Trend = 1;
NW = j - Revers;
}
else
{
Trend = -1;
if((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = NW[i-1];
}
}
}
}

//===============system================

Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
Buy=Cover=Cross(j,nw);
Sell=Short=Cross(nw,j);
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorWhite)+ "NICK MA Swing System" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();


// How please help
 

Similar threads