Advertisement
saisri

oct 21 with heikin

Oct 22nd, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. _SECTION_BEGIN("Chart Settings");
  2. SetChartOptions(0,chartShowArrows|chartShowDates);
  3. SetChartBkColor(ParamColor("Outer Panel",colorBlack));
  4. SetChartBkGradientFill(ParamColor("Upper Chart",colorBlack),ParamColor("Lower Chart",colorBlack));
  5. GraphXSpace=Param("GraphXSpace",10,0,100,1);
  6. dec = (Param("Decimals",2,0,7,1)/10)+1;
  7. bi = BarIndex();
  8. Lbi = LastValue(BarIndex());
  9. sbi = SelectedValue(bi);
  10. x1= BarCount-1;
  11. Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(32) + Date() +
  12. " " + EncodeColor(5) + "{{INTERVAL}} " +
  13. EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) +
  14. EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
  15. EncodeColor(55)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) +
  16. EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
  17. EncodeColor(55)+ " Volume = "+ EncodeColor(52)+ WriteVal(V,1);
  18. _SECTION_END();
  19.  
  20. _SECTION_BEGIN("Heiken Ashi Smoothed");
  21. SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorBlack ));
  22. SetChartOptions(0,chartShowArrows|chartShowDates);
  23. GraphXSpace=5;
  24. p=Param("Period",6,2,30,1);
  25. Om=MA(O,p);
  26. hm=MA(H,p);
  27. lm=MA(L,p);
  28. Cm=MA(C,p);
  29. HACLOSE=(Om+Hm+Lm+Cm)/4;
  30. HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  31. HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
  32. HaLow = Min( Lm, Min( HaClose, HaOpen ) );
  33. PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorWhite, styleCandle | styleNoLabel );
  34. _SECTION_END();
  35.  
  36. _SECTION_BEGIN("Ribbon");
  37. uptrend=PDI()>MDI()AND Signal()<MACD();
  38. downtrend=MDI()>PDI()AND Signal()>MACD();
  39. Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
  40. IIf( uptrend, colorLime, IIf( downtrend, colorRed,IIf(Signal()<MACD(), colorWhite, colorWhite ))), /* choose color */
  41. styleOwnScale|styleArea|styleNoLabel, -0, 20 );
  42. _SECTION_END();
  43.  
  44.  
  45. // Supertrend - Translated from Kolier MQ4
  46. // see: http://kolier.li/indicator/kolier-supertrend-indi
  47. // translation in Amibroker AFL code by E.M.Pottasch, 2011
  48.  
  49. procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
  50. {
  51. global buffer_line_down;
  52. global buffer_line_up;
  53. buffer_line_down = Null;
  54. buffer_line_up = Null;
  55.  
  56. PHASE_NONE = 0;
  57. PHASE_BUY = 1;
  58. PHASE_SELL = -1;
  59.  
  60. phase=PHASE_NONE;
  61. band_upper = 0;
  62. band_lower = 0;
  63.  
  64. for(i = ATR_Period + 1; i < BarCount; i++)
  65. {
  66. band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
  67. band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
  68.  
  69. if(phase==PHASE_NONE)
  70. {
  71. buffer_line_up[i] = CalcPrice[i];
  72. buffer_line_down[i] = CalcPrice[i];
  73. }
  74. if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
  75. {
  76. phase = PHASE_BUY;
  77. buffer_line_up[i] = band_lower;
  78. buffer_line_up[i-1] = buffer_line_down[i-1];
  79. }
  80. if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
  81. {
  82. phase = PHASE_SELL;
  83. buffer_line_down[i] = band_upper;
  84. buffer_line_down[i-1] = buffer_line_up[i-1];
  85. }
  86. if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
  87. {
  88. if(band_lower>buffer_line_up[i-1])
  89. {
  90. buffer_line_up[i] = band_lower;
  91. }
  92. else
  93. {
  94. buffer_line_up[i] = buffer_line_up[i-1];
  95. }
  96. }
  97. if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
  98. {
  99. if(band_upper<buffer_line_down[i-1])
  100. {
  101. buffer_line_down[i] = band_upper;
  102. }
  103. else
  104. {
  105. buffer_line_down[i] = buffer_line_down[i-1];
  106. }
  107. }
  108. }
  109. }
  110.  
  111. SetBarsRequired(sbrAll,sbrAll);
  112.  
  113. TrendMode = ParamToggle("TrendMode","Off|On",1);
  114. ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
  115. ATR_Period = Param( "ATR_Period",5,1,20,1);
  116. tr = ATR(ATR_Period);
  117.  
  118. CalcPrice = (H+L)/2;
  119. calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);
  120.  
  121. SetChartOptions(0,chartShowDates);
  122.  
  123. Plot( 2,"",IIf(buffer_line_up,colorBrightGreen,colorRed),styleOwnScale|styleArea|styleNoLabel, -10, 100 );
  124. Plot( 4,"",IIf(buffer_line_down,colorRed,colorBrightGreen),styleOwnScale|styleArea|styleNoLabel, -5, 100 );
  125. _SECTION_BEGIN("system Ticker");
  126. function GetSecondNum()
  127. {
  128. Time = Now( 4 );
  129. Seconds = int( Time % 100 );
  130. Minutes = int( Time / 100 % 100 );
  131. Hours = int( Time / 10000 % 100 );
  132. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  133. return SecondNum;
  134. }
  135. RequestTimedRefresh( 1 );
  136. //----------------------------------------------------------------------------
  137. //----------------------------------------------------------------------------
  138. TimeFrame = Interval();
  139. SecNumber = GetSecondNum();
  140. Newperiod = SecNumber % TimeFrame == 0;
  141. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  142. SecsToGo = TimeFrame - SecsLeft;
  143.  
  144. x=Param(" xposn",850,100,1000,1000);
  145. y=Param(" yposn",0,40,1000,1);
  146.  
  147. GfxSelectSolidBrush( colorPink );
  148. GfxSelectPen( colorBlack, 2 );
  149. if ( NewPeriod )
  150. {
  151. GfxSelectSolidBrush( colorBlack );
  152. GfxSelectPen( colorBlack, 2 );
  153. Say( "New candle" );
  154. }
  155. GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
  156. GfxSetBkMode(1);
  157. GfxSelectFont( "Arial", 9, 700, False );
  158. GfxSetTextColor( colorBlack );
  159. GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
  160. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement