Tuesday, 12 March 2013

Stochastic Oscillator - Amibroker AFL



AFL for Amibroker
===================================================
_SECTION_BEGIN("BACK COLR");
_SECTION_BEGIN("PRASAD SYSTEMS");
Param("DEDICATED TO MY FATHER",5);
_SECTION_END();
GfxSetOverlayMode(1); 
SetChartBkColor( ParamColor("Chart Color", colorBlack));
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/20 ); /* Up down name*/
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor("Text Color", ColorHSB( 42, 42, 42 ) ));
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/7);
GfxSelectFont("Tahoma", Status("pxheight")/30 );
GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/5 );  /* Up Down Sector*/

GfxSelectFont("Tahoma", Status("pxheight")/40 );
GfxTextOut( "Feedback prasad9rao@gmail.com", Status("pxwidth")/2, Status("pxheight")/4);
GfxSelectFont("Tahoma", Status("pxheight")/20 );
GfxTextOut( " BALKRISHNA STOCHASTICS CHARTS ", Status("pxwidth")/2, Status("pxheight")/15 );

_SECTION_END();
  
/*************** remove all above lines for Amibroker 5.00 or less than 5
  
/**************************************************
                Stochastics
***************************************************/

SP = Param( "Periods", 10, 1, 200, 1 );
Ksmooth = Param( "%K avg", 5, 1, 200, 1 );
Dsmooth = Param( "%D avg", 5, 1, 200, 1 );
StochDval = StochD( SP , Ksmooth, DSmooth );
StochKval = StochK( SP , Ksmooth);

Overbought = 80;
Oversold = 20;
  
mycolorst =IIf(Stochkval- Stochdval<0,ColorRGB(248,18,25),IIf(Stochkval- Stochdval>0,ColorRGB(51,122,51),ColorRGB(125,84,11)));
  
Plot(Stochkval- Stochdval ,"",mycolorst ,styleHistogram);
Plot( Stochkval- Stochdval, "Premier", colorWhite, styleThick );

StochBuy = Cross(StochK(SP,Ksmooth), StochD(SP,Ksmooth, DSmooth)) AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
StochSell = Cross (StochD(SP,Ksmooth, DSmooth), StochK(SP,Ksmooth)) AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
StochStrongBuy = Cross(StochK(SP,Ksmooth),StochD(SP,Ksmooth, DSmooth)) AND
(StochD(SP,Ksmooth, DSmooth) < 20) AND (StochK(SP,Ksmooth) < 20) ;
StochStrongSell = Cross (StochD(SP,Ksmooth,DSmooth), StochK(SP , Ksmooth));
(StochD(SP,Ksmooth, DSmooth) > 80) AND (StochK(SP,Ksmooth) > 80);

//****************** BULLISH / BEARISH *******************/
StochBull = StochK(SP , Ksmooth)>StochD(SP , Ksmooth, DSmooth) AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
StochBear = StochK(SP , Ksmooth)<StochD(SP , Ksmooth, DSmooth)AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
StochOB = (StochD(SP,Ksmooth, DSmooth) > 80) AND (StochK(SP,Ksmooth) > 80);
StochOS = (StochD(SP,Ksmooth, DSmooth) < 20) AND (StochK(SP,Ksmooth) < 20) ;
Title = EncodeColor(colorYellow)+  Title = Name() + "    " + EncodeColor(2) + Date()  + "    "
  
/********************STOChASTICS*********************/

+EncodeColor(colorWhite)+"Signal(Stochastics) "+EncodeColor(colorWhite)+"Period = "+"["+SP+"]"+"      %K = "+"["+Ksmooth+"]"+ "      %D = "+"["+Dsmooth+"]"+"   ::::   "
 + WriteIf(StochBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(StochSell,EncodeColor(colorRed)+"Sell",
WriteIf(StochStrongBuy,EncodeColor(colorBrightGreen)+"Strong Buy",WriteIf(StochStrongSell,EncodeColor(colorRed)+"Strong Sell","Neutral"))))
+EncodeColor(colorWhite)+ "    " + "Stochastics Trend  = "
+WriteIf(StochBull,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(StochBear,EncodeColor(colorRed)+"Bearish",
WriteIf(StochOS,EncodeColor(colorBrightGreen)+"OverSold",WriteIf(StochOB,EncodeColor(colorRed)+"OverBrought","Neutral"))));

7 comments:

  1. I tried it gives syntax error at WriteIf(StochStrongBuy,EncodeColor(colorBrightGreen)+"Strong Buy",WriteIf(StochStrongSell,EncodeColor(colorRed)+"Strong Sell","Neutral")))) --- I tried putting semi column but didnt work

    ReplyDelete
  2. sorry... i tried again... it worked.

    ReplyDelete
  3. MR. PRASADSIR,

    FIRST OF ALL HATS OFF YOU FOR CREATING & HELPING THIS MUCH OF PEOPLE OUT HERE...

    YOU DECIDED NOT TO PROVIDE YOUR HOLY GRAIL TO PUBLIC AFTER WISESTOCKTRADER INCIDENT, BUT SIR I LOOKED EVERY POST OF YOUR BLOG WHERE PEOPLE BEGGING FOR THAT HOLY GRAIL,

    SIR I REQUEST YOU MAY NOT PUBLIC THAT AFL BUT PLEASE PLEASE DO FEVER TO PROVIDE THAT ON EMAILS...

    PEOPLE ARE BEGGING BECAUSE THEY SOMEWHERE LOOSING UP OR WIPED OUT THEIR ACCOUNTS SO MANY TIMES, I AM ONE OF THEM.

    SIR NOW ONLY YOU & YOU CAN SAVE US.....


    MAY BE WE ARE NOT DESERVE THIS THINGS, BUY SIR WE OWE YOU IF YOU HELP US, WE OWE YOU SIR....


    THE HOPE :----

    MY EMAIL ID

    shah.abhishek7271@gmail.com

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Hi Prasad
    I have been a Big fan on Amibroker for years from the 5.00 version till the current 6.28.0.
    One good thing i came across is your HOLY GRAIL Charts which are very nice and colourful.
    I have searched every search engine for this particular masterpiece but to no Avail until i went through the formula and got your email.
    Please i need to ask.
    Is the AFL something you will like to share or is it for SALE??

    Your reply will be highly appreciated
    Thanks

    AbdulRasheed Momoh

    ReplyDelete

/* begin page number */