Sunday, May 13, 2018

Ichimoku Kinko Hyo (Tenkan Sen Kijun Sen Cross Over Amibroker Scanner)

Tenkan Sen Kijun Sen Cross Over Amibroker Scanner
Buy Tenkan Sen > Kijun Sen
Sell Tenkan Sen < Kijun Sen


AFL Code Below:

//Disclaimer:
//All the AFL’s posted in this section are for learning purpose.
//I do not necessarily own these AFL’s and I don’t have any intellectual property rights on them. I might copy useful AFL’s from public forums 
//and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. 
//If you find any misleading or non-reproducible content then please disregard this AFL_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 10 );
_SECTION_END();

_SECTION_BEGIN("Ichimoku");
/* ICHIMOKU CHART */ 
n1 = Param("Tenkan-Sen",9,1,200,1); 
n2 = Param("Kijun-Sen",26,1,400,1); 
n3 = Param("Senkou Span",52,1,600,1); 

TenkanSen   =(HHV(H,n1)+LLV(L,n1))/2;            // Tenkan-sen (Òåíêàí-ñåí) – ýòî ñðåäíåå çíà÷åíèå öåíû çà ïåðâûé ïðîìåæóòîê âðåìåíè (ðàâíà (high+low)/2, ãäå high è low – ìàêñèìóì è ìèíèìóì çà ïåðèîä). 
KijunSen    =(HHV(H,n2)+LLV(L,n2))/2;            // Kijun-sen (Êèäæóí-ñåí) – ýòî ñðåäíåå çíà÷åíèå öåíû çà âòîðîé ïðîìåæóòîê. 
ChinkouSpan =Ref(C,-n2);                          // Chinkou Span (×èêîó ñïåí) - öåíà çàêðûòèÿ òåêóùåãî áàðà, ñäâèíóòàÿ íàçàä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà. 
Cks         = Close;                             // Ãðàôè÷åñêèé Chinkou Span, ñäâèã íàçàä çàñ÷åò îòðèñîâêè. 
SenkouSpanA =Ref((KijunSen+TenkanSen)/2,-n2);    // Senkou Span A (Ñåíêîó ñïåí À) / Up Kumo - ñåðåäèíà ðàññòîÿíèÿ ìåæäó Tenkan-sen è Kijun-sen, ñäâèíóòîå âïåðåä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà. 
SpA         =(KijunSen+TenkanSen)/2;             // Ãðàôè÷åñêèé Senkou Span A , ñäâèã âïåðåä çàñ÷åò îòðèñîâêè. 
SenkouSpanB =Ref((HHV(H,n3)+LLV(L,n3))/2,-n2);   // Senkou Span B (Ñåíêîó ñïåí Â) / Down Kumo - ñðåäíåå çíà÷åíèå öåíû çà òðåòèé âðåìåííîé èíòåðâàë, ñäâèíóòîå âïåðåä íà âåëè÷èíó âòîðîãî âðåìåííîãî èíòåðâàëà. 
SpB         =(HHV(H,n3)+LLV(L,n3))/2;            // Ãðàôè÷åñêèé Senkou Span B, ñäâèã âïåðåä çàñ÷åò îòðèñîâêè. 
DL = Ref( C, 25 );


Cond1 =  Ref(Close > Max(SenkouSpanA,SenkouSpanB),-1);  //öåíà âûøå îáëàêà  -- áû÷üå íàñòðîåíèå 
Cond2 =  Ref(Close < Min(SenkouSpanA,SenkouSpanB),-1);  //öåíà íèæå îáëàêà  -- ìåäâåæüå íàñòðîåíèå 
Cond3 =  Ref(Cross(TenkanSen,KijunSen),-1);  //ïåðåñå÷åíèå Òåíêàí è Êèäæóí -- ñèãíàë íà ïîêóïêó 
Cond4 =  Ref(Cross(KijunSen,TenkanSen),-1);  //ïåðåñå÷åíèå Òåíêàí è Êèäæóí -- ñèãíàë íà ïðîäàæó 
Cond5 =  Ref(Cross(Close,ChinkouSpan ),-1);  //ïåðåñå÷åíèå ×èêîó è öåíû 
Cond6 =  Ref(Cross(ChinkouSpan ,Close),-1);  //ïåðåñå÷åíèå ×èêîó è öåíû 
Cond7 =  Ref(Cross (Close , Max(SenkouSpanA,SenkouSpanB)),-1);  //öåíà âûõîäèò ââåðõ èç îáëàêà  -- ñèãíàë íà ïîêóïêó 
Cond8 =  Ref(Cross ( Min(SenkouSpanA,SenkouSpanB), Close),-1);  //öåíà âûõîäèò âíèç  èç îáëàêà  -- ñèãíàë íà ïðîäàæó 
Cond9 = Close > TenkanSen AND TenkanSen > KijunSen AND KijunSen > Max(SenkouSpanA,SenkouSpanB); // ñèãíàë òðåõ ëèíèé ââåðõ 
Cond10= Close < TenkanSen AND TenkanSen < KijunSen AND KijunSen < Min(SenkouSpanA,SenkouSpanB); // ñèãíàë òðåõ ëèíèé âíèç 
RemCond9=ExRem(Cond9,NOT Cond9);                  
RemCond10=ExRem(Cond10,NOT Cond10); 

ColSenk =IIf (Cond1,colorGreen, IIf(Cond2,colorRed,colorLightGrey)); // çàäàåò öâåò, åñëè öåíà âûøå/íèæå/âíóòðè îáëàêà. 
Flat  =  TenkanSen == Ref(TenkanSen,-1) OR (NOT(Cond1) AND NOT(Cond2)) ; 

for( i = 0; i < BarCount; i++ ) //ðàñêðàøèâàåò ñðåäíþþ ëèíèþ èíäèêàòîðà ïî âçàèìîðàñïîëîæåíèþ è íàïðàâëåíèÿ äâèæåíèÿ TenkanSen, öåíû è îáëàêà. 
   if (Flat[i]) 
      ColTenk[i] = colorLightGrey; 
   else 
   { 
if (Cond1[i] AND TenkanSen[i] > TenkanSen[i-1]) 
     ColTenk[i] = colorGreen; 
if (Cond1[i] AND TenkanSen[i] < TenkanSen[i-1]) 
     ColTenk[i] = colorRed; 
if (Cond2[i] AND TenkanSen[i] < TenkanSen[i-1]) 
     ColTenk[i] = colorRed; 
if (Cond2[i] AND TenkanSen[i] > TenkanSen[i-1]) 
     ColTenk[i] = colorGreen; 
   } 


AlertIf( Cond3 OR Cond4, "SOUND c:/WINDOWS/Media/notify.wav", "ïåðåñå÷åíèå Òåíêàí è Êèäæóí",0,1+2+4+8); 
AlertIf( Cond5 OR Cond6, "SOUND c:/WINDOWS/Media/notify.wav", "ïåðåñå÷åíèå ×èêîó è öåíû",0,1+2+4+8); 
AlertIf( Cond7 OR Cond8, "SOUND c:/WINDOWS/Media/notify.wav", "öåíà âûõîäèò  èç îáëàêà",0,1+2+4+8); 
AlertIf( RemCond9 OR RemCond10, "SOUND c:/WINDOWS/Media/notify.wav", "ñèãíàë òðåõ ëèíèé",0,1+2+4+8); 

//PlotShapes(IIf(Cond7, shapeSmallUpTriangle ,shapeNone),colorGreen,0,H,10);              
//PlotShapes(IIf(Cond8, shapeSmallDownTriangle ,shapeNone),colorRed,0,L,10); 
//PlotShapes(IIf(Cond3, shapeHollowSmallUpTriangle,shapeNone),colorGreen,0,H,12);              
//PlotShapes(IIf(Cond4, shapeHollowSmallDownTriangle ,shapeNone),colorRed,0,L,12); 
//PlotShapes(IIf(Cond5, shapeSmallCircle ,shapeNone),colorGreen,0,H,4);              
//PlotShapes(IIf(Cond6, shapeSmallCircle + shapePositionAbove ,shapeNone),colorRed,0,L,4); 
//PlotShapes(IIf(RemCond9 , shapeHollowSquare ,shapeNone),colorGreen,0,H,18);              
//PlotShapes(IIf(RemCond10, shapeHollowSquare + shapePositionAbove ,shapeNone),colorRed,0,L,18); 

//Plot (C,"Close",colorBlack,styleThick); 
Plot (C,"Bars",colorBlack,styleCandle); 
Plot (TenkanSen,"Tenkan-sen",colorRed); 
Plot (KijunSen, "Kijun-sen", colorBlue); 
Plot (Cks,"Chinkou Span",colorLime, style = styleLine,0,0,-n2); 
Plot (SpA,"SenkouSpanA",colorBrown,styleNoLine,0,0,n2); 
Plot (SpB,"SenkouSpanB",colorBlack,styleNoLine,0,0,n2); 
PlotOHLC (SpA,SpA,SpB,SpB,"Cloud",IIf (SpA > SpB,colorGreen,colorLightOrange),styleCloud, 10, 10, n2 ); 
above = IIf(KijunSen>SenkouSpanA AND TenkanSen>SenkouSpanB,1,0);
within = IIf(KijunSen>SenkouSpanA AND TenkanSen<SenkouSpanB,1,0);
below = IIf(TenkanSen<SenkouSpanA AND TenkanSen<SenkouSpanB,1,0);
Buy = Cross(TenkanSen,KijunSen) AND (DL>Close);
Sell = Cross(KijunSen,TenkanSen) AND (DL<KijunSen);
StrongBuy = Buy AND above;
MediumBuy = Buy AND within;
WeakBuy = Buy AND below;
StrongSell = Sell AND below;
MediumSell = Sell AND within;
WeakSell = Sell AND above;

/*IIf( (StrongBuy),PlotShapes(shapeUpTriangle*StrongBuy,colorGreen),2);
IIf( (MediumBuy),PlotShapes(shapeUpArrow*MediumBuy,colorGreen),2);
IIf( (WeakBuy),PlotShapes(shapeHollowUpArrow*WeakBuy,colorIndigo),2);
IIf( (StrongSell),PlotShapes(shapeDownTriangle*StrongSell,colorRed),2);
IIf( (MediumSell),PlotShapes(shapeDownArrow*MediumSell,colorRed),2);
IIf( (WeakSell),PlotShapes(shapeHollowDownArrow*WeakSell,colorBrown),2);
*/

// Ãîðèçîíòàëüíàÿ öâåòíàÿ èíäèêàòîðíàÿ ïîëîñà (ïðèìåð). 


// Plot( 1, "Ribbon", ColTenk, styleOwnScale|styleArea|styleNoLabel, -2, 200 );   // èíäèöèðóåò ôëýò íà TenkanSen. 
// Plot( 4, "Ribbon", ColSenk, styleOwnScale|styleArea|styleNoLabel, -1, 200 );   // èíäèöèðóåò ïîëîæåíèå öåíû îòíîñèòåëüíî îáëàêà
_SECTION_END();

Technical Analysis For Forex, Cryptocurrency and Stocks.
No Hype...No Tsismis... No Drama.... Just Chart!!!!



No comments:

Post a Comment