1 RSI STOCH - Amibroker AFL

| Thursday, 4 April 2013


_SECTION_BEGIN("Stochastic %D");
periods = Param( "Periods", 6, 1, 200, 1 );
Ksmooth = Param( "%K avg", 2, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
Plot( StochD( periods , Ksmooth, DSmooth ), _DEFAULT_NAME(), ParamColor( "Blue", colorCycle ), ParamStyle("StyleDashed", styleDashed | styleThick | styleOwnScale) );
_SECTION_END();

_SECTION_BEGIN("Stochastic %K");
periods = Param( "Periods", 7, 1, 200, 1 );
Ksmooth = Param( "%K avg", 29, 1, 200, 1 );
Plot( StochK( periods , Ksmooth), _DEFAULT_NAME(), ParamColor( "Red", colorCycle ), ParamStyle("Style",  styleThick | styleOwnScale | stylehidden));
_SECTION_END();

/* Turbo_JRSX : a better RSI ?
Ported from Metatrader.
Original source code : http://codebase.mql4.com/source/6182 */

SetChartOptions (0, 0, chartGrid20 | chartGrid50 | chartGrid80);
  
Len = Param ( "Periods", 12, 1, 200, 1 );
  
  
function JRSX ( Period )
{
  
    f88 = 0; f90 = 0; f0 = 0; v4 = 0;   v8 = 0; vC = 0; v10 = 0; v14 = 0; v18 = 0; v20 = 0;
    f8 = 0; f10 = 0; f18 = 0; f20 = 0; f28 = 0; f30 = 0; f38 = 0; f48 = 0; v1C = 0;
    f50 = 0; f58 = 0; f60 = 0; f68 = 0; f70 = 0; f78 = 0; f80 = 0; f40 = 0;
  
    f90 = 1.0;
    f0  = 0.0;
  
    if ( Period-1 >= 5 )
        f88 = Period-1.0;
    else
        f88 = 5.0;
  
    f8 = 100.0 * ((H[0]+L[0]+Close[0])/3);
    f18 = 3.0 / (Period + 2.0);
    f20 = 1.0 - f18;
  
   for ( i = 1; i < BarCount; i++ )
    {
        if (f88 <= f90) f90 = f88 + 1; else f90 = f90 + 1;
        f10 = f8;
 //    f8 = 100*Close[i];
        f8 = 100.0*((H[i]+L[i]+C[i])/3);
        v8 = f8 - f10;
        f28 = f20 * f28 + f18 * v8;
        f30 = f18 * f28 + f20 * f30;
        vC = f28 * 1.5 - f30 * 0.5;
        f38 = f20 * f38 + f18 * vC;
        f40 = f18 * f38 + f20 * f40;
        v10 = f38 * 1.5 - f40 * 0.5;
        f48 = f20 * f48 + f18 * v10;
        f50 = f18 * f48 + f20 * f50;
        v14 = f48 * 1.5 - f50 * 0.5;
        f58 = f20 * f58 + f18 * abs (v8);
        f60 = f18 * f58 + f20 * f60;
        v18 = f58 * 1.5 - f60 * 0.5;
        f68 = f20 * f68 + f18 * v18;
  
        f70 = f18 * f68 + f20 * f70;
        v1C = f68 * 1.5 - f70 * 0.5;
        f78 = f20 * f78 + f18 * v1C;
        f80 = f18 * f78 + f20 * f80;
        v20 = f78 * 1.5 - f80 * 0.5;
  
        if ((f88 >= f90) && (f8 != f10)) f0 = 1.0;
        if ((f88 == f90) && (f0 == 0.0)) f90 = 0.0;
        if ((f88 < f90) && (v20 > 0.0000000001))
        {
            v4 = (v14 / v20 + 1.0) * 50.0;
            if (v4 > 100.0) v4 = 100.0;
            if (v4 < 0.0) v4 = 0.0;
        }
        else
        {
            v4 = 50.0;
        }
        rsx[i] = v4;
    }
    return rsx;
}
Plot ( JRSX(Len), "Turbo JRSX", ParamColor ( "Color", colorCycle ), ParamStyle ("Style" ,  styleDashed), 0, 100 );

_SECTION_BEGIN("linia");
Plot(100,"30 LINE",colorRed,styleThick,styleDashed,styleOwnScale);
Plot(80,"30 LINE",colorLightBlue,styleThick);
Plot(70,"30 LINE",colorRed,styleDashed);
Plot(50,"30 LINE",colorBlack,styleThick,styleDashed,styleOwnScale);
Plot(30,"30 LINE",colorRed,styleDashed, styleThick);
Plot(20,"30 LINE",colorLightBlue,styleThick);
Plot(0,"30 LINE",colorGreen,styleThick,styleDashed,styleOwnScale);
_SECTION_END();

1 comments :

  1. While am try to use this AFL code am getting error like unexcepeted identifier how can i fix this sir?

    ReplyDelete

▲Top▲