Advertisement
saisri

main afl (t3 afl required)

Nov 3rd, 2012
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.87 KB | None | 0 0
  1. ///////////////////////////////////
  2. SetChartOptions(0,chartShowArrows|chartShowDates);
  3. SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
  4.  
  5. Title =
  6. EncodeColor(colorWhite)+ Title = Name () + " | "
  7. +EncodeColor(colorYellow) + Date() +" | " + Interval( 2 )+ " | "
  8. +EncodeColor(colorTurquoise)+ "Op : "+ EncodeColor(colorLightGrey)+ O + " | "
  9. +EncodeColor(colorTurquoise)+ "Hi : "+ EncodeColor(colorLightGrey)+ H + " | "
  10. +EncodeColor(colorTurquoise)+ "Lo : "+ EncodeColor(colorLightGrey)+ L + " | "
  11. +EncodeColor(colorTurquoise)+ "Cls : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
  12. +EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
  13. +EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
  14. +EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1);
  15.  
  16. _SECTION_END();
  17.  
  18. _SECTION_BEGIN("Heiken Ashi Smoothed");
  19. SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorBlack ));
  20. SetChartOptions(0,chartShowArrows|chartShowDates);
  21. GraphXSpace=5;
  22. p=Param("Period",8,2,30,1);
  23. Om=MA(O,p);
  24. hm=MA(H,p);
  25. lm=MA(L,p);
  26. Cm=MA(C,p);
  27. HACLOSE=(Om+Hm+Lm+Cm)/4;
  28. HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  29. HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
  30. HaLow = Min( Lm, Min( HaClose, HaOpen ) );
  31. PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorWhite, styleCandle | styleNoLabel );
  32. _SECTION_END();
  33. a=LinearReg(HaClose, 5 ) ;
  34. b=LinearReg( HaClose, 5 ) ;
  35.  
  36. Plot( IIf(HaHigh>HaOpen,a,b), _DEFAULT_NAME(), colorRed, ParamStyle("Style") );
  37.  
  38. Plot( LinearReg( HaOpen, 5 ), _DEFAULT_NAME(), colorWhite, ParamStyle("Style") );
  39.  
  40. _SECTION_BEGIN("kgs 12 26 ma buy sell");
  41.  
  42.  
  43. a=MA(C,3) ;
  44. b=MA(C,15) ;
  45.  
  46. Buy = Cross( a,b );
  47. Sell = Cross( b,a );
  48. //Short = Sell;
  49. //Cover = Buy;
  50.  
  51. //AlertIf( Buy, "", "MA cross BUY", 1,1+2 );
  52.  
  53. //AlertIf( Sell, "", "MA cross SELL", 2 ,1+2)
  54. AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  55. AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  56.  
  57.  
  58. _SECTION_END();
  59. _SECTION_BEGIN("TSKPMoMo");
  60.  
  61.  
  62. blsLong = 0;
  63.  
  64.  
  65.  
  66. KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
  67. // tskp_upsell, tskp_triggerline, tskp_triggerlinevma
  68. sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
  69. KPTriggerLine = tskp_triggerline;
  70. KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
  71. //tskp_fast2val1, tskp_fast2val2
  72. dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
  73. KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1);
  74.  
  75.  
  76.  
  77. Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
  78. sctotal = 0;
  79. sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
  80. sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
  81. sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
  82. sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
  83. sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
  84. sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
  85. sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
  86. sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
  87. sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);
  88.  
  89. // tskp_mediumma,tskp_mediumup,tskp_mediumdown
  90. dummy = E_TSKPMEDIUM(Close);
  91. KPMediumUP = tskp_mediumup;
  92. KPMediumDwn = tskp_mediumdown;
  93. KPMediumMA = tskp_mediumma;
  94.  
  95. // -- Create 0-initialized arrays the size of barcount
  96. aHPivs = H - H;
  97. aLPivs = L - L;
  98. aHiVal = H - H;
  99. aLoVal = L - L;
  100.  
  101.  
  102. for (curBar=5; curBar < BarCount-1; curBar++)
  103. {
  104.  
  105.  
  106. if( (blsLong == -1) OR (blsLong == 0))
  107. {
  108. if ((sctotal[CurBar] >= 5) AND (KPMediumUP[CurBar] > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == 1) AND
  109. (KPFast2Val[CurBar] == 1) AND (KPTriggerLine[CurBar] >= KPStopLine[CurBar] ))
  110. {
  111. blsLong = 1;
  112. aLPivs[CurBar] = 1;
  113. aLoVal[CurBar] = Low[CurBar];
  114. }
  115. }
  116.  
  117. if( (blsLong == 1) OR (blsLong == 0))
  118. {
  119. if ((sctotal[CurBar] <= -5) AND (KPMediumDwn[CurBar] < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == -1) AND
  120. (KPFast2Val[CurBar] == -1) AND (KPTriggerLine[CurBar] <= KPStopLine[CurBar] ))
  121. {
  122. blsLong = -1;
  123. aHPivs[Curbar] = 1;
  124. aHiVal[Curbar] = High[Curbar];
  125. }
  126. }
  127.  
  128. if ((blsLong == 1) AND ((sctotal[CurBar] < 5) OR (KPMediumUP[CurBar] < KPMediumMA[CurBar] ) OR
  129. (KPFast2Val[CurBar] < 1) OR (KPFast3Val[CurBar] < 1) OR (KPTriggerLine[CurBar] < KPStopLine[CurBar] )) )
  130. {
  131. blsLong= 0;
  132. }
  133.  
  134. if ((blsLong == -1) AND ((sctotal[CurBar] > -5) OR (KPMediumDwn[CurBar] > KPMediumMA[CurBar] ) OR
  135. (KPFast2Val[CurBar] > -1) OR (KPFast3Val[CurBar] > -1) OR
  136. (KPTriggerLine[CurBar] > KPStopLine[CurBar] )) )
  137. {
  138. blsLong = 0;
  139. }
  140. }
  141.  
  142.  
  143. PlotShapes (IIf(aHPivs == 1, shapeSmallCircle, shapeNone) ,colorRed, layer = 0, yposition = haHigh, offset = 17 );
  144. PlotShapes (IIf(aLPivs == 1, shapeSmallCircle, shapeNone) ,colorGreen, layer = 0, yposition = haLow, offset = -8 );
  145. AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  146. AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  147.  
  148. _SECTION_END();
  149.  
  150. _SECTION_BEGIN("Isfandi Technical Viewer");
  151. //Plot(C,"",ParamColor( "Color", colorBlue ),ParamStyle("Style") );
  152. //---- pivot points
  153. GfxSetBkColor(colorBlack);
  154. GfxSetTextColor( colorGrey50 );
  155. GfxSelectFont("Edwardian Script ITC", 25, 500, True );
  156. DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
  157. DayL = TimeFrameGetPrice("L", inDaily, -1);//low
  158. DayC = TimeFrameGetPrice("C", inDaily, -1);//close
  159. DayO = TimeFrameGetPrice("O", inDaily);// current day open
  160. HiDay = TimeFrameGetPrice("H", inDaily);
  161. LoDay = TimeFrameGetPrice("L", inDaily);
  162. PP = (DayH + DayL + DayO + DayO) / 4 ;
  163. R1 = (2 * PP) - DayL;
  164. S1 = (2 * PP) - DayH;
  165. R2 = PP + R1 - S1;
  166. S2 = PP + S1 - R1;
  167. R3 = R2 + (R1 - PP);
  168. S3 = S2 - (PP - S1);
  169.  
  170. radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
  171. textoffset = 0.1 * radius;
  172.  
  173. //====================
  174. GfxSetOverlayMode(0);
  175.  
  176. //-Paint Background
  177.  
  178. GfxSelectSolidBrush( colorBlack);
  179. GfxSelectPen( colorPink);
  180. GfxRoundRect( 2, 15, 109, 259, 132, 32 );
  181. GfxSetBkMode( 1 );
  182.  
  183. GfxSelectFont("Arial", 8, 900);
  184.  
  185.  
  186. // OTHER INDICATOR
  187. MOMETUM =RSI(14);
  188. radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
  189. textoffset = 0.1 * radius;
  190. GfxSelectFont("Arial", 9, 500, True );
  191. GfxSelectFont("Arial", 9 );
  192. GfxSetTextColor( colorLime);
  193. GfxTextOut( "R1 =" + R1, textoffset + 1, 170 );
  194. GfxSetTextColor( colorLime );
  195. GfxTextOut( "R2 = " +R2, textoffset + 1, 150 );
  196. GfxSetTextColor( colorWhite );
  197. GfxTextOut( "PP = " +PP, textoffset + 1, 190 );
  198. GfxSetTextColor( colorOrange );
  199. GfxTextOut( "S1 = " +S1, textoffset + 1, 210 );
  200. GfxSetTextColor( colorRed );
  201. GfxTextOut( "S2 = " +S2, textoffset + 1, 230 );
  202. GfxSelectFont("Arial", 9 );
  203. _SECTION_END();
  204. //////////////////////////////////////////////////////////////////////
  205. _SECTION_BEGIN("Elder Impulse");
  206. GfxSelectFont("Arial", 9, 500, True );
  207. ///////////////////////////////////////////////////
  208. SetChartOptions(0,chartShowArrows|chartShowDates);
  209. EnableTextOutput(False);
  210. // User-defined parameter for EMA periods
  211. EMA_Type = Param("EMA-1, TEMA-2, JMA-3", 2, 1, 3, 1);
  212. EMA_prds = Param("EMA_periods", 7, 1, 30, 1);
  213. Std_MACD = Param("Standard MACD? No-0, Yes-1", 1, 0, 1, 1);
  214. Plot_fashion = Param("Bar+Arrows-1, Impulse Bars-2", 2, 1, 2, 1);
  215. // Allow user to define Weekly and Monthly Ribbon Location and Height
  216. WR_P1 = Param("Weekly Ribbon Location", 5.2, -1000, 1000, 0.1);
  217. WR_P2 = Param("Weekly Ribbon Height", 199, -0.001, 500, 0.1);
  218. //MR_P1 = Param("Monthly Ribbon Location", 5.2, -1000, 1000, 0.1);
  219. //MR_P2 = Param("Monthly Ribbon Height", 199, -0.001, 500, 0.1);
  220. // Compute EMA and MACD Histogram
  221. if(EMA_Type == 1)
  222. {
  223. DayEMA = EMA(Close, EMA_prds);
  224. }
  225. if (EMA_Type == 2)
  226. {
  227. DayEMA = TEMA(Close, EMA_prds);
  228. }
  229. Histogram = MACD() - Signal();
  230. // Determine if we have an Impulse UP, DOWN or None
  231. Impulse_Up = DayEMA > Ref(DayEMA, -1) AND Histogram > Ref(Histogram, -1);
  232. Impulse_Down = DayEMA < Ref(DayEMA, -1) AND Histogram < Ref(Histogram, -1);
  233. Impulse_None = (NOT Impulse_UP) AND (NOT Impulse_Down);
  234. // Compute Weekly MACD and determine whether rising or falling
  235. TimeFrameSet(inWeekly);
  236. if (Std_MACD == 0)
  237. {
  238. MACD_val = MACD(5, Cool);
  239. Signal_val = Signal(5, 8, 5);
  240. }
  241. else
  242. {
  243. MACD_val = MACD(12, 26);
  244. Signal_val = Signal(12, 26, 9);
  245. }
  246. Hist_in_w = MACD_val - Signal_val;
  247. wh_rising = Hist_in_w > Ref(Hist_in_w, -1);
  248. wh_falling = Hist_in_w < Ref(Hist_in_w, -1);
  249. wh_none = (NOT wh_rising) AND (NOT wh_falling);
  250. TimeFrameRestore();
  251. // Now get Monthly MACD Histogram....
  252. TimeFrameSet(inMonthly);
  253. MACD_val = MACD(5, 8);
  254. Signal_val = Signal(5, 8, 5);
  255. Hist_in_m = MACD_val - Signal_val;
  256. mh_rising = Hist_in_m > Ref(Hist_in_m, -1);
  257. mh_falling = Hist_in_m < Ref(Hist_in_m, -1);
  258. TimeFrameRestore();
  259. wh_rising = TimeFrameExpand( wh_rising, inWeekly, expandLast );
  260. wh_falling = TimeFrameExpand( wh_falling, inWeekly, expandLast);
  261. wh_none = TimeFrameExpand( wh_none, inWeekly, expandLast);
  262. mh_rising = TimeFrameExpand(mh_rising, inMonthly, expandLast);
  263. mh_falling = TimeFrameExpand(mh_falling, inMonthly, expandLast);
  264. kol = IIf( wh_rising, colorBrightGreen, IIf(wh_falling, colorRed, IIf(wh_none, colorCustom11, colorLightGrey)));
  265. mkol = IIf( mh_rising, colorBlue, IIf(mh_falling, colorYellow, colorLightGrey));
  266. if (Plot_fashion == 1)
  267. {
  268. }
  269. else
  270. {
  271. bar_kol = IIf(impulse_UP, colorBrightGreen, IIf(impulse_Down, colorRed, colorCustom11));
  272. }
  273. Impulse_State = WriteIf(Impulse_Up, "Bulllish", WriteIf(Impulse_Down, "Bearish", "Neutral"));
  274. GfxSetTextColor( colorYellow );
  275. GfxTextOut( "IMPULSE STATE = " +Impulse_State, textoffset + 162, 45 );
  276. // Set the background color for Impulse Status Column
  277. Impulse_Col = IIf(Impulse_Up, colorGreen, IIf(Impulse_Down, colorRed, colorGrey40));
  278. // Determine Weekly Trend. Display as Text Column
  279. Weekly_Trend = WriteIf(wh_rising, "Rising", WriteIf(wh_falling, "Falling", "Flat!"));
  280. Weekly_Col = IIf(wh_rising, colorGreen, IIf(wh_falling, colorRed, colorLightGrey));
  281. GfxSetTextColor( colorPink );
  282. GfxTextOut( "WEEKLT TREND = " +Weekly_Trend, textoffset + 162, 60 );
  283. // Determine Monthly Trend. Display as Text Column
  284. Monthly_Trend = WriteIf(mh_rising, "Rising", WriteIf(mh_falling, "Falling", "Flat!"));
  285. Monthly_Col = IIf(mh_rising, colorGreen, IIf(mh_falling, colorRed, colorLightGrey));
  286. GfxSetTextColor( colorOrange );
  287. GfxTextOut( "MONTHLY TREND = " +Monthly_Trend, textoffset + 151, 75 );
  288. // Determine how many bars has the current state existed
  289. bars_in_bull = Min(BarsSince(impulse_none), BarsSince(impulse_down));
  290. bars_in_bear = Min(BarsSince(impulse_up), BarsSince(impulse_none));
  291. bars_in_neut = Min(BarsSince(impulse_down), BarsSince(impulse_up));
  292. // Set a single variable to show number of bars in current state depending upon
  293. // actual Impulse Status - Bullish, Bearish or Neutral
  294. bars_in_state = IIf(Impulse_Up, bars_in_bull, IIf(Impulse_down, bars_in_bear, bars_in_neut));
  295. //weekly pivot
  296. k1=-1;
  297. SetChartBkColor(16 ) ;
  298. k=IIf(ParamList("select type","daily|next day")=="daily",-1,0);
  299. k1=-1;
  300. TimeFrameSet(inDaily);
  301. day_h= LastValue(Ref(H,K));
  302. day_l= LastValue(Ref(L,K));
  303. day_c= LastValue(Ref(C,K));
  304. TimeFrameRestore();
  305. // day
  306. DH=Day_h;
  307. DL=Day_L;
  308. DC=Day_C;
  309. // DAY PIVOT Calculation
  310. pd = ( DH+ DL + DC )/3;
  311. sd1 = (2*pd)-DH;
  312. sd2 = pd -(DH - DL);
  313. sd3 = Sd1 - (DH-DL);
  314. rd1 = (2*pd)-DL;
  315. rd2 = pd +(DH -DL);
  316. rd3 = rd1 +(DH-DL);
  317. WriteVal( StochK(39) - StochK(12) );
  318. GfxSelectFont("Arial", 8 );
  319. _SECTION_END();
  320.  
  321. _SECTION_BEGIN("STOCHASTIC");
  322. GfxSelectFont("Arial", 9, 500, True );
  323. periods = Param( "Periods", 15, 1, 200, 1 );
  324. Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
  325. a = StochK( periods , Ksmooth);
  326. Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
  327. b = StochD( periods , Ksmooth, DSmooth );
  328. Buy = Cross( a, b );
  329. Sell = Cross( b, a );
  330. STOCH =WriteIf(a>b , "Up","Down");
  331. GfxSetTextColor( colorYellow );
  332. GfxTextOut( "Stochastic = " +STOCH, textoffset + 200, 30 );
  333. GfxSelectFont("Arial", 8 );
  334. _SECTION_BEGIN("Van K Tharp Efficient Stocks");
  335. // Mark Keitel 12-05
  336. // Van K Tharp Efficient Stocks
  337. GfxSelectFont("Arial", 9, 500, True );
  338. ATRD180 = ATR(180);
  339. ATRD90 = ATR(90);
  340. ATRD45 = ATR(45);
  341. ATRD20 = ATR(20);
  342. ATRD5 = ATR(5);
  343. DifferenceD180 = Close - Ref(Close,-180);
  344. DifferenceD90 = Close - Ref(Close,-90);
  345. DifferenceD45 = Close - Ref(Close,-45);
  346. DifferenceD20 = Close - Ref(Close,-20);
  347. DifferenceD5 = Close - Ref(Close,-5);
  348. EfficiencyD180 = IIf(ATRD180!=0,DifferenceD180/ATRD180,1);
  349. EfficiencyD90 = IIf(ATRD90!=0,DifferenceD90/ATRD90,1);
  350. EfficiencyD45 = IIf(ATRD45!=0,DifferenceD45/ATRD45,1);
  351. EfficiencyD20 = IIf(ATRD20!=0,DifferenceD20/ATRD20,1);
  352. EfficiencyD5 = IIf(ATRD5!=0,DifferenceD5/ATRD5,1);
  353. Averageeff = (EfficiencyD180 + EfficiencyD90 + EfficiencyD45 +
  354. EfficiencyD20 ) / 4;
  355. //Plot( averageeff, "AvgEff", colorLightBlue, styleLine );
  356. x = Param ( "Add Results to a Watchlist? Yes = 1, No = 2" , 2 , 1 , 2 , 1 ) ; // select whether to add results to watchlist or not
  357. y = Param("Set Watchlist Number", 25, 2, 60,1); // sets the watchlist number, but reserves the first 2 and last 4 watchlists
  358. // -------- Parameter Variables for Exploration --------------------------------
  359. TCH = Param("High close value ", 20, 5, 300, 0.5);
  360. TCL = Param("Low close value " , 5, 1, 10, 0.25);
  361. AVP = Param("Period for Avg Vol " , 21, 10, 240, 1);
  362. SV = Param("Stock minimum Avg Vol " , 125000, 50000, 1000000, 500000);
  363. // -------------- Organize the exploration results ------------------------------------
  364. P = Param("Period for Price Delta Comparisons", 1, 1, 120, 1);
  365. P1 = Param("Period for Other Delta Comparisons", 3, 1, 120, 1);
  366. PATR = Param("Period for ATR", 5,1,21,1);
  367. PADX = Param("Period for ADX", 14, 3, 34,1);
  368. PRSI = Param("Period for RSI", 13, 3, 34,1);
  369. ADX_TREND =WriteIf(PDI(PADX)>MDI(PADX),"_ TREND UP","_TREND DOWN");
  370. GfxSetTextColor( colorYellow );
  371. GfxTextOut( "RSI(14) = " + MOMETUM + ADX_TREND , textoffset + 650,30);
  372. ADX_14 = ADX(14);
  373. GfxSetTextColor( colorYellow );
  374. GfxTextOut( "ADX_TREND = " +ADX_14+ ADX_TREND, textoffset + 380, 30 );
  375. _SECTION_END();
  376.  
  377.  
  378. _SECTION_BEGIN("Price Line");
  379.  
  380. PriceLineColor=ParamColor("PriceLineColor",colorRed);
  381. PriceLevel = ParamField("PriceField", field = 3 );
  382.  
  383. Daysback = Param("Bars Back",500,10,900,1);
  384. FirstBar = BarCount - DaysBack;
  385. YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);
  386.  
  387. Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll));
  388.  
  389. side = Param("side",1,1,1000,2);
  390.  
  391. dist = 0;
  392.  
  393. for( i = 0; i < BarCount; i++ )
  394. {
  395. if(i+side== BarCount) PlotText( "\n " + PriceLevel[ i ], i, YY[ i ]-dist[i], colorRed );
  396. }
  397.  
  398. _SECTION_END();
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405. _SECTION_BEGIN("Ribbon");
  406. uptrend=PDI()>MDI()AND Signal()<MACD();
  407. downtrend=MDI()>PDI()AND Signal()>MACD();
  408. Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
  409. IIf( uptrend, colorLime, IIf( downtrend, colorRed,IIf(Signal()<MACD(), colorWhite, colorWhite ))), /* choose color */
  410. styleOwnScale|styleArea|styleNoLabel, -0, 20 );
  411. _SECTION_END();
  412.  
  413.  
  414. // Supertrend - Translated from Kolier MQ4
  415. // see: http://kolier.li/indicator/kolier-supertrend-indi
  416. // translation in Amibroker AFL code by E.M.Pottasch, 2011
  417.  
  418. procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
  419. {
  420. global buffer_line_down;
  421. global buffer_line_up;
  422. buffer_line_down = Null;
  423. buffer_line_up = Null;
  424.  
  425. PHASE_NONE = 0;
  426. PHASE_BUY = 1;
  427. PHASE_SELL = -1;
  428.  
  429. phase=PHASE_NONE;
  430. band_upper = 0;
  431. band_lower = 0;
  432.  
  433. for(i = ATR_Period + 1; i < BarCount; i++)
  434. {
  435. band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
  436. band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
  437.  
  438. if(phase==PHASE_NONE)
  439. {
  440. buffer_line_up[i] = CalcPrice[i];
  441. buffer_line_down[i] = CalcPrice[i];
  442. }
  443. if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
  444. {
  445. phase = PHASE_BUY;
  446. buffer_line_up[i] = band_lower;
  447. buffer_line_up[i-1] = buffer_line_down[i-1];
  448. }
  449. if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
  450. {
  451. phase = PHASE_SELL;
  452. buffer_line_down[i] = band_upper;
  453. buffer_line_down[i-1] = buffer_line_up[i-1];
  454. }
  455. if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
  456. {
  457. if(band_lower>buffer_line_up[i-1])
  458. {
  459. buffer_line_up[i] = band_lower;
  460. }
  461. else
  462. {
  463. buffer_line_up[i] = buffer_line_up[i-1];
  464. }
  465. }
  466. if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
  467. {
  468. if(band_upper<buffer_line_down[i-1])
  469. {
  470. buffer_line_down[i] = band_upper;
  471. }
  472. else
  473. {
  474. buffer_line_down[i] = buffer_line_down[i-1];
  475. }
  476. }
  477. }
  478. }
  479.  
  480. SetBarsRequired(sbrAll,sbrAll);
  481.  
  482. TrendMode = ParamToggle("TrendMode","Off|On",0);
  483. ATR_Multiplier = Param("ATR_Multiplier",3,0.1,10,0.1);
  484. ATR_Period = Param( "ATR_Period",5,1,20,1);
  485. tr = ATR(ATR_Period);
  486.  
  487. CalcPrice = (H+L)/2;
  488. calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);
  489.  
  490. SetChartOptions(0,chartShowDates);
  491.  
  492. Plot( 2,"",IIf(buffer_line_up,colorBrightGreen,colorRed),styleOwnScale|styleArea|styleNoLabel, -10, 100 );
  493. Plot( 4,"",IIf(buffer_line_down,colorRed,colorBrightGreen),styleOwnScale|styleArea|styleNoLabel, -5, 100 );
  494.  
  495. #include <T3_include.AFL>;
  496.  
  497. //************************************************** ********************************
  498. // Plot price horizontal line *
  499. //************************************************** ********************************/
  500.  
  501. ///********************************************//
  502.  
  503. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  504. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  505. Temp = Max(High, flowerOpen);
  506. flowerHigh = EMA(Max(Temp, flowerClose),3);
  507. Temp = Min(Low,flowerOpen);
  508. flowerLow = EMA(Min(Temp, flowerClose),3);
  509.  
  510. //------------//
  511.  
  512.  
  513.  
  514. //#include <T3.AFL>;
  515.  
  516. _SECTION_BEGIN("Trendslong");
  517.  
  518. //CT=ParamColor("CT", colorRed );
  519.  
  520. UpTrendCond3 = Cross ( T3( flowerclose, 7), T3( flowerclose, 9) );
  521. dnTrendCond3 = Cross ( T3( flowerclose, 9),T3( flowerclose, 7) );
  522.  
  523.  
  524. upt3= T3( flowerclose, 7)> T3( flowerclose, 9) ;
  525. dnTrend3 = T3( flowerclose, 9)>T3( flowerclose, 7) ;
  526.  
  527.  
  528. //for Trend1
  529.  
  530. Trendslongup= WriteIf(upt3,"trendlongup", "");
  531. Trendslongdown= WriteIf( dnTrend3,"trendlongdn", "");
  532. //Trendslongcon= WriteIf( UpTrendCond3,"trendlongcon", "");
  533.  
  534. if ( Trendslongup =="trendlongup")
  535. {
  536. GfxSelectSolidBrush(34 ); //ColorRGB(0,90,0)
  537.  
  538. }
  539. else
  540.  
  541. if (Trendslongdown =="trendlongdn")
  542.  
  543. {
  544. GfxSelectSolidBrush(25 ); //ColorRGB(90,0,0)
  545.  
  546. }
  547.  
  548. else
  549.  
  550. if (Trendslongdown =="")
  551.  
  552. {
  553. GfxSelectSolidBrush( colorYellow );
  554.  
  555. }
  556.  
  557. GfxSelectFont( "Arial", 10, 100 );
  558. GfxSetBkMode( 1 );
  559. GfxSetTextColor( colorBlack );
  560.  
  561. GfxSelectPen( colorBlack, 1 ); // broader color
  562. GfxRectangle( 15,109,95,119 );
  563.  
  564.  
  565.  
  566.  
  567. _SECTION_END();
  568.  
  569.  
  570.  
  571.  
  572. _SECTION_BEGIN("Trendsmid");
  573.  
  574. //DT=ParamColor("DT", colorRed );
  575.  
  576. UpTrendCond2 = Cross ( T3( flowerclose, 5), T3( flowerclose, 7) );
  577. dnTrendCond2 = Cross (T3( flowerclose, 7), T3( flowerclose, 5) );
  578. upt2= T3( flowerclose, 5)> T3( flowerclose, 7) ;
  579. dnTrend2 = T3( flowerclose, 7)>T3( flowerclose, 5) ;
  580.  
  581.  
  582.  
  583. //for trend2
  584.  
  585. Trendmidup= WriteIf(upt2,"trendmidup", "");
  586. Trendmiddown= WriteIf( dnTrend2,"trendmiddn", "");
  587. Trendmidcon= WriteIf( UpTrendCond2,"trendmidcon", "");
  588.  
  589. if ( Trendmidup =="trendmidup")
  590. {
  591. GfxSelectSolidBrush( 34 ); //ColorRGB(0,120,0)
  592.  
  593. }
  594. else
  595.  
  596. if (Trendmiddown =="trendmiddn")
  597.  
  598. {
  599. GfxSelectSolidBrush(25 ); //ColorRGB(120,0,0)
  600.  
  601. }
  602.  
  603. else
  604.  
  605. if (Trendmidcon =="trendmidcon")
  606.  
  607. {
  608. GfxSelectSolidBrush( 14 ); //colorYellow
  609.  
  610. }
  611.  
  612. GfxSelectFont( "Arial", 10, 100 );
  613. GfxSetBkMode( 1 );
  614. GfxSetTextColor( colorBlack );
  615.  
  616. GfxSelectPen( colorBlack, 1 ); // broader color
  617. GfxRectangle( 15,97,95,107 );
  618.  
  619. _SECTION_END();
  620.  
  621. _SECTION_BEGIN("Trendsshort");
  622.  
  623. //ET=ParamColor("ET", colorRed );
  624.  
  625. UpTrendCond1 = Cross( flowerClose, T3( flowerClose, 5 ) );
  626. dnTrendCond1 = Cross( T3( flowerClose, 5 ),flowerClose );
  627. upt1=flowerClose > T3( flowerClose, 5 ) ;
  628. dnTrend1 = flowerClose< T3( flowerClose, 5 );
  629.  
  630.  
  631.  
  632. //for Trend1
  633.  
  634. Trendshortup= WriteIf(upt1,"trendup", "");
  635. Trendshortdown= WriteIf( dnTrend1,"trenddn", "");
  636. Trendshortcon= WriteIf( UpTrendCond1,"trendcon", "");
  637.  
  638. if ( Trendshortup =="trendup")
  639. {
  640. GfxSelectSolidBrush( 34 ); //ColorRGB(0,150,0)
  641.  
  642. }
  643. else
  644.  
  645. if (Trendshortdown =="trenddn")
  646.  
  647. {
  648. GfxSelectSolidBrush(25 ); //ColorRGB(150,0,0)
  649.  
  650. }
  651.  
  652. else
  653.  
  654. if (Trendshortcon =="trendcon")
  655.  
  656. {
  657. GfxSelectSolidBrush( colorYellow );
  658.  
  659. }
  660.  
  661. GfxSelectFont( "Arial", 10, 100 );
  662. GfxSetBkMode( 1 );
  663. GfxSetTextColor( colorBlack );
  664.  
  665. GfxSelectPen( colorBlack, 1 ); // broader color
  666. GfxRectangle( 15,85,95,95 );
  667.  
  668.  
  669.  
  670.  
  671. _SECTION_END();
  672.  
  673.  
  674.  
  675. _SECTION_BEGIN("Rays");
  676.  
  677. //FT=ParamColor("FT", colorRed );
  678.  
  679. Pp1=3;
  680. Pp2=2;
  681.  
  682. CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4);
  683. CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5);
  684.  
  685. AtrupTrendCond1 = flowerClose> CS33 ;
  686. AtrdnTrendCond1 =CS33>flowerClose ;
  687.  
  688.  
  689. ATRup = WriteIf(AtrupTrendCond1,"atrup", "");
  690. ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", "");
  691.  
  692. if ( ATRup =="atrup")
  693. {
  694. GfxSelectSolidBrush( 34 ); //ColorRGB(0,180,0)
  695.  
  696. }
  697. else
  698.  
  699. if (ATRdown =="atrdn")
  700.  
  701. {
  702. GfxSelectSolidBrush( 25); //ColorRGB(180,0,0)
  703.  
  704. }
  705.  
  706. else
  707.  
  708. if ( ATRdown =="")
  709.  
  710. {
  711. GfxSelectSolidBrush( colorGrey40 );
  712.  
  713. }
  714.  
  715. GfxSelectFont( "Arial", 10, 100 );
  716. GfxSetBkMode( 1 );
  717. GfxSetTextColor( colorBlack );
  718.  
  719. GfxSelectPen( colorBlack, 1 ); // broader color
  720. GfxRectangle( 15,73,95,83 );
  721.  
  722. _SECTION_END();
  723.  
  724.  
  725. _SECTION_BEGIN("Exit_Beast-3");
  726.  
  727. //GT=ParamColor("GT", colorRed );
  728.  
  729. EntrylookbackPeriod=10;
  730. EntryATRperiod=1.9;
  731. EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
  732. ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );
  733.  
  734.  
  735. RequestTimedRefresh( 0 );
  736. GfxSelectFont( "Tahoma", 12, 100 );
  737. GfxSetBkMode( 1 );
  738. GfxSetTextColor( colorWhite );
  739.  
  740. EntryB = WriteIf( EntrySig,"eu", "");
  741. ExitB = WriteIf( ExitSig,"ed", "");
  742.  
  743. if ( EntryB =="eu")
  744. {
  745. GfxSelectSolidBrush( 34 ); //ColorRGB(0,210,0)
  746.  
  747. }
  748. else
  749.  
  750. if ( ExitB =="ed")
  751.  
  752. {
  753. GfxSelectSolidBrush( 25); //ColorRGB(210,0,0)
  754.  
  755. }
  756.  
  757. else
  758.  
  759. if ( ExitB =="")
  760.  
  761. {
  762. GfxSelectSolidBrush( colorGrey40 );
  763.  
  764. }
  765.  
  766. GfxSelectFont( "Arial", 10, 100 );
  767. GfxSetBkMode( 1 );
  768. GfxSetTextColor( colorBlack );
  769.  
  770. GfxSelectPen( colorBlack, 1 ); // broader color
  771. GfxRectangle( 15,61,95,71 );// changing the value of x,y,rad x-70, y-90, rad-24
  772.  
  773. _SECTION_END();
  774.  
  775.  
  776.  
  777. _SECTION_BEGIN("CCI9-2");
  778.  
  779. //HT=ParamColor("HT", colorRed );
  780.  
  781. ccidn=CCI(8) < 0;
  782. cciup=CCI(9) > 0;
  783.  
  784.  
  785. ccresult1 = WriteIf( cciup,"cu", "");
  786. ccresult2 = WriteIf( ccidn,"cd", "");
  787.  
  788.  
  789.  
  790.  
  791. RequestTimedRefresh( 0 );
  792. GfxSelectFont( "Tahoma", 12, 100 );
  793. GfxSetBkMode( 1 );
  794. GfxSetTextColor( colorWhite );
  795.  
  796. if ( ccresult1 =="cu")
  797. {
  798. GfxSelectSolidBrush( 34 ); //ColorRGB(0,240,0)
  799.  
  800. }
  801. else
  802.  
  803. if ( ccresult2 =="cd")
  804.  
  805. {
  806. GfxSelectSolidBrush(25 ); //
  807.  
  808. }
  809.  
  810. else
  811.  
  812. if ( ccresult2 =="")
  813.  
  814. {
  815. GfxSelectSolidBrush( colorGrey40 );
  816.  
  817. }
  818.  
  819. GfxSelectFont( "Arial", 10, 100 );
  820. GfxSetBkMode( 1 );
  821. GfxSetTextColor( colorBlack );
  822.  
  823. GfxSelectPen( colorBlack, 1 ); // broader color
  824. GfxRectangle( 15,49,95,59 );
  825.  
  826.  
  827.  
  828.  
  829. _SECTION_END();
  830.  
  831.  
  832.  
  833.  
  834. _SECTION_BEGIN("%BB7-1");
  835.  
  836. //IT=ParamColor("IT", colorRed );
  837. p=7;
  838. x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
  839. bbdown= x < 40;
  840. bbup= x > 40;
  841.  
  842. bbresult1 = WriteIf( bbup,"bu", "");
  843. bbresult2 = WriteIf( bbdown,"bd", "");
  844. bbresult3 = WriteIf( C,"bearishrevers", "");
  845.  
  846.  
  847.  
  848. RequestTimedRefresh( 0 );
  849. GfxSelectFont( "Tahoma", 12, 100 );
  850. GfxSetBkMode( 1 );
  851. GfxSetTextColor( colorWhite );
  852.  
  853. if ( bbresult1 =="bu")
  854. {
  855. GfxSelectSolidBrush(34 ); //ColorRGB(62,255,62)
  856.  
  857. }
  858. else
  859.  
  860. if ( bbresult2 =="bd")
  861.  
  862. {
  863. GfxSelectSolidBrush(25 ); //ColorRGB(255,62,62)
  864.  
  865. }
  866.  
  867. else
  868.  
  869. if ( bbresult2 =="")
  870.  
  871. {
  872. GfxSelectSolidBrush( colorGrey40 );
  873.  
  874. }
  875.  
  876. GfxSelectFont( "Arial", 10, 100 );
  877. GfxSetBkMode( 1 );
  878. GfxSetTextColor( colorBlack );
  879.  
  880. GfxSelectPen( colorBlack, 1 ); // broader color
  881. GfxRectangle( 15,37,95,47 );//
  882.  
  883.  
  884. _SECTION_END();
  885.  
  886.  
  887. _SECTION_BEGIN("Fast_trend");
  888. //JT=ParamColor("JT", colorRed );
  889.  
  890. Prd3=5; //Param("Daily_Period1",8,1,200,1);
  891. Prd4=8; //Param("Daily_Period2",15,1,200,1);
  892. TimeFrameSet (inDaily);
  893.  
  894.  
  895. TM3 = T3 ( C , Prd3) ;
  896. TM4 = T3 ( C , Prd4) ;
  897.  
  898. TimeFrameRestore();
  899.  
  900. A=C>TM3 AND C<TM4;
  901. B=C>TM3 AND C>TM4;
  902. C=C<TM3 AND C>TM4;
  903. D=C<TM3 AND C<TM4;
  904.  
  905. result1 = WriteIf( A,"bullrevers", "");
  906. result2 = WriteIf( B,"bull", "");
  907. result3 = WriteIf( C,"bearishrevers", "");
  908. result4 = WriteIf( D,"bear", "");
  909.  
  910.  
  911. RequestTimedRefresh( 0 );
  912. GfxSelectFont( "Tahoma", 12, 100 );
  913. GfxSetBkMode( 1 );
  914. GfxSetTextColor( colorWhite );
  915.  
  916. if ( result1 =="bullrevers")
  917. {
  918. GfxSelectSolidBrush( 17 ); // colorwhite
  919.  
  920. }
  921. else
  922.  
  923. if ( result2 =="bull")
  924.  
  925. {
  926. GfxSelectSolidBrush( 34 ); //ColorRGB(113,255,113)
  927.  
  928. }
  929.  
  930. else
  931.  
  932. if ( result3 =="bearishrevers")
  933.  
  934. {
  935. GfxSelectSolidBrush( 36 ); // colorGrey40
  936.  
  937. }
  938.  
  939. else
  940.  
  941. if ( result4 =="bear")
  942.  
  943. {
  944. GfxSelectSolidBrush( 25 ); //ColorRGB(255,113,113)
  945. OP = "M";
  946.  
  947. }
  948.  
  949. GfxSelectFont( "Arial", 10, 100 );
  950. GfxSetBkMode( 1 );
  951. GfxSetTextColor( colorWhite );//text color black to white
  952.  
  953. GfxSelectPen( colorBlack,1); // broader color
  954. GfxRectangle( 15,25,95,35 );// rectangle instead circle
  955.  
  956. //GfxTextOut( OP ,92,235) ;// this line added
  957.  
  958. _SECTION_END();
  959.  
  960.  
  961.  
  962. _SECTION_BEGIN("system Ticker");
  963. function GetSecondNum()
  964. {
  965. Time = Now( 4 );
  966. Seconds = int( Time % 100 );
  967. Minutes = int( Time / 100 % 100 );
  968. Hours = int( Time / 10000 % 100 );
  969. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  970. return SecondNum;
  971. }
  972. RequestTimedRefresh( 1 );
  973. //----------------------------------------------------------------------------
  974. //----------------------------------------------------------------------------
  975. TimeFrame = Interval();
  976. SecNumber = GetSecondNum();
  977. Newperiod = SecNumber % TimeFrame == 0;
  978. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  979. SecsToGo = TimeFrame - SecsLeft;
  980.  
  981. x=Param(" xposn",880,100,1000,1000);
  982. y=Param(" yposn",0,40,1000,1);
  983.  
  984. GfxSelectSolidBrush( colorPink );
  985. GfxSelectPen( colorBlack, 2 );
  986. if ( NewPeriod )
  987. {
  988. GfxSelectSolidBrush( colorBlack );
  989. GfxSelectPen( colorBlack, 2 );
  990. Say( "New candle" );
  991. }
  992. GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
  993. GfxSetBkMode(1);
  994. GfxSelectFont( "Arial", 9, 700, False );
  995. GfxSetTextColor( colorBlack );
  996. GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
  997. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement