Advertisement
saisri

oct21 with bb

Oct 22nd, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 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("RSI BB");
  21. A1=EMA(RSI(5),21);
  22. BBtop=BBandTop(A1,9,.5);
  23. BBbot=BBandBot(A1,9,.5);
  24. Color=IIf(a1 > bbtop, colorBlue,IIf(a1 < bbbot, colorRed,colorYellow));
  25. bbtop_col = IIf (BBtop > Ref(BBtop,-1),colorBlue,colorRed);
  26. bbbot_col = IIf (BBbot > Ref(BBbot,-1),colorBlue,colorRed);
  27. Plot(a1,"",color,styleDots);
  28. Plot(BBtop,"",BBtop_col,styleDots);
  29. Plot(BBbot,"",BBbot_col,styleDots);
  30. Plot(50,"",31,1);
  31. Buy = a1 > bbtop;
  32. Sell = a1 < bbbot;
  33. Buy = ExRem(Buy,Sell);
  34. Sell = ExRem(Sell,Buy);
  35.  
  36. PlotShapes(Buy*shapeHollowSmallUpTriangle,colorYellow);
  37. PlotShapes(Sell*shapeHollowSmallDownTriangle,colorYellow);
  38. _SECTION_END();
  39.  
  40.  
  41. _SECTION_BEGIN("Ribbon");
  42. uptrend=PDI()>MDI()AND Signal()<MACD();
  43. downtrend=MDI()>PDI()AND Signal()>MACD();
  44. Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
  45. IIf( uptrend, colorLime, IIf( downtrend, colorRed,IIf(Signal()<MACD(), colorWhite, colorWhite ))), /* choose color */
  46. styleOwnScale|styleArea|styleNoLabel, -0, 20 );
  47. _SECTION_END();
  48.  
  49.  
  50. // Supertrend - Translated from Kolier MQ4
  51. // see: http://kolier.li/indicator/kolier-supertrend-indi
  52. // translation in Amibroker AFL code by E.M.Pottasch, 2011
  53.  
  54. procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
  55. {
  56. global buffer_line_down;
  57. global buffer_line_up;
  58. buffer_line_down = Null;
  59. buffer_line_up = Null;
  60.  
  61. PHASE_NONE = 0;
  62. PHASE_BUY = 1;
  63. PHASE_SELL = -1;
  64.  
  65. phase=PHASE_NONE;
  66. band_upper = 0;
  67. band_lower = 0;
  68.  
  69. for(i = ATR_Period + 1; i < BarCount; i++)
  70. {
  71. band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
  72. band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
  73.  
  74. if(phase==PHASE_NONE)
  75. {
  76. buffer_line_up[i] = CalcPrice[i];
  77. buffer_line_down[i] = CalcPrice[i];
  78. }
  79. if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
  80. {
  81. phase = PHASE_BUY;
  82. buffer_line_up[i] = band_lower;
  83. buffer_line_up[i-1] = buffer_line_down[i-1];
  84. }
  85. if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
  86. {
  87. phase = PHASE_SELL;
  88. buffer_line_down[i] = band_upper;
  89. buffer_line_down[i-1] = buffer_line_up[i-1];
  90. }
  91. if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
  92. {
  93. if(band_lower>buffer_line_up[i-1])
  94. {
  95. buffer_line_up[i] = band_lower;
  96. }
  97. else
  98. {
  99. buffer_line_up[i] = buffer_line_up[i-1];
  100. }
  101. }
  102. if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
  103. {
  104. if(band_upper<buffer_line_down[i-1])
  105. {
  106. buffer_line_down[i] = band_upper;
  107. }
  108. else
  109. {
  110. buffer_line_down[i] = buffer_line_down[i-1];
  111. }
  112. }
  113. }
  114. }
  115.  
  116. SetBarsRequired(sbrAll,sbrAll);
  117.  
  118. TrendMode = ParamToggle("TrendMode","Off|On",1);
  119. ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
  120. ATR_Period = Param( "ATR_Period",5,1,20,1);
  121. tr = ATR(ATR_Period);
  122.  
  123. CalcPrice = (H+L)/2;
  124. calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);
  125.  
  126. SetChartOptions(0,chartShowDates);
  127.  
  128. Plot( 2,"",IIf(buffer_line_up,colorBrightGreen,colorRed),styleOwnScale|styleArea|styleNoLabel, -10, 100 );
  129. Plot( 4,"",IIf(buffer_line_down,colorRed,colorBrightGreen),styleOwnScale|styleArea|styleNoLabel, -5, 100 );
  130. _SECTION_BEGIN("system Ticker");
  131. function GetSecondNum()
  132. {
  133. Time = Now( 4 );
  134. Seconds = int( Time % 100 );
  135. Minutes = int( Time / 100 % 100 );
  136. Hours = int( Time / 10000 % 100 );
  137. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  138. return SecondNum;
  139. }
  140. RequestTimedRefresh( 1 );
  141. //----------------------------------------------------------------------------
  142. //----------------------------------------------------------------------------
  143. TimeFrame = Interval();
  144. SecNumber = GetSecondNum();
  145. Newperiod = SecNumber % TimeFrame == 0;
  146. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  147. SecsToGo = TimeFrame - SecsLeft;
  148.  
  149. x=Param(" xposn",850,100,1000,1000);
  150. y=Param(" yposn",0,40,1000,1);
  151.  
  152. GfxSelectSolidBrush( colorPink );
  153. GfxSelectPen( colorBlack, 2 );
  154. if ( NewPeriod )
  155. {
  156. GfxSelectSolidBrush( colorBlack );
  157. GfxSelectPen( colorBlack, 2 );
  158. Say( "New candle" );
  159. }
  160. GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
  161. GfxSetBkMode(1);
  162. GfxSelectFont( "Arial", 9, 700, False );
  163. GfxSetTextColor( colorBlack );
  164. GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
  165. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement