Advertisement
a1b1trader

75830

Nov 6th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. _SECTION_BEGIN("Price Chart");
  2. bgTop = ParamColor("BgTop", colorBlack);
  3. bgBot = ParamColor("BgBottom", colorBlack);
  4. SetChartBkGradientFill( bgTop ,bgBot, colorLightGrey);
  5.  
  6. pStyle = ParamList("Price Style", "Candle|Solid Candle|Bar|Line|Heikin-Ashi",2);
  7. cBull = ParamColor("Price Bull", colorLime);
  8. CBear = ParamColor("Price Bear", colorRed);
  9. cLine = ParamColor("Price Line", colorWhite);
  10.  
  11.  
  12. SetChartOptions(0,chartShowArrows|chartShowDates);
  13. _N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
  14.  
  15. ThisStyle = styleCandle;
  16. ThisTitle = "";
  17.  
  18. _O=O; _C=C; _H=H; _L=L;
  19.  
  20. ThisColor = IIf( _C>_O, cBull, IIf(_C<_O, CBear, CLine));
  21.  
  22.  
  23. switch (pStyle )
  24. {
  25.  
  26. case "Solid Candle":
  27. SetBarFillColor( ThisColor );
  28. break;
  29.  
  30.  
  31. case "Bar":
  32. ThisStyle = styleBar;
  33. break;
  34.  
  35. case "Line":
  36. ThisStyle = styleLine;
  37. ThisColor = cLine;
  38. break;
  39.  
  40.  
  41. case "Heikin-Ashi":
  42. _C = (O+H+L+C)/4;
  43. _O = AMA( Ref( _C, -1 ), 0.5 );
  44. _H = Max( H, Max( _C, _O ) );
  45. _L = Min( L, Min( _C, _O ) );
  46.  
  47. ThisColor = IIf(_C >= _O,CBull, CBear);
  48. SetBarFillColor( ThisColor );
  49.  
  50. ThisColor = IIf(_C >= _O,cLine, cLine);
  51. ThisTitle = "Heikin-Ashi";
  52. break;
  53.  
  54. default:
  55. SetBarFillColor( ThisColor );
  56. ThisColor = cLine;
  57.  
  58. break;
  59.  
  60. }
  61.  
  62. PlotOHLC( _O, _H, _L, _C, ThisTitle, ThisColor, ThisStyle);
  63. GraphXSpace = 8;
  64.  
  65. _SECTION_END();
  66.  
  67.  
  68. _SECTION_BEGIN("BandStop");
  69. /* Done by Rajandran R */
  70. /* Author of www.marketcalls.in */
  71. // BBands_Stop_v1.mq4 by igorad2004@list.ru
  72. // translation in Amibroker AFL, E.M.Pottasch, 2011
  73.  
  74. // Modified By KelvinHand
  75.  
  76. Length=Param("Length",20, 2); // Bollinger Bands Period
  77. Deviation=Param("Deviation",2);
  78. // Deviation was 2
  79. MoneyRisk=Param("Money Risk", 1);
  80.  
  81. LineStyle=ParamToggle("Display line mode", "No|Yes", 1); // Display line mode: 0-no,1-yes
  82. cUpTrendLine = ParamColor("UpTrendLine", ColorRGB(65,105,225));
  83. cDnTrendLine = ParamColor("DownTrendLine", colorRed);
  84.  
  85.  
  86.  
  87.  
  88.  
  89. // Offset Factor
  90. TurnedUp=Nz(StaticVarGet("TurnedUp"));
  91. TurnedDown=Nz(StaticVarGet("TurnedDown"));
  92. SoundON = ParamToggle("Sound","Off|On",1);
  93.  
  94.  
  95. procedure CalcTrend_proc(bbtop,bbbot,Length,MoneyRisk,SoundON,TurnedUp,TurnedDown)
  96. {
  97. global UpTrendLine;
  98. global DownTrendLine;
  99. global smax;
  100. global smin;
  101.  
  102. UpTrendLine=Null;
  103. DownTrendLine=Null;
  104. smax=Null;
  105. smin=Null;
  106. trend=0;
  107.  
  108.  
  109. for (i=Length+1; i<BarCount; i++)
  110. {
  111. smax[i]=bbtop[i];
  112. smin[i]=bbbot[i];
  113. if (C[i]>smax[i-1]) trend=1;
  114. if (C[i]<smin[i-1]) trend=-1;
  115. if(trend>0 && smin[i]<smin[i-1]) smin[i]=smin[i-1];
  116. if(trend<0 && smax[i]>smax[i-1]) smax[i]=smax[i-1];
  117. bsmax[i]=smax[i]+0.5*(MoneyRisk-1)*(smax[i]-smin[i]);
  118. bsmin[i]=smin[i]-0.5*(MoneyRisk-1)*(smax[i]-smin[i]);
  119. if(trend>0 && bsmin[i]<bsmin[i-1]) bsmin[i]=bsmin[i-1];
  120. if(trend<0 && bsmax[i]>bsmax[i-1]) bsmax[i]=bsmax[i-1];
  121. if (trend>0)
  122. {
  123. UpTrendLine[i]=bsmin[i];
  124. if (SoundON==True && !TurnedUp && i==BarCount-1 && IsEmpty(UpTrendLine[i-1]))
  125. {
  126. Say("Bollinger Bands going Up");
  127. TurnedUp=StaticVarSet("TurnedUp",1);
  128. TurnedDown=StaticVarSet("TurnedDown",0);
  129.  
  130. }
  131. }
  132.  
  133. if (trend<0)
  134. {
  135. DownTrendLine[i]=bsmax[i];
  136. if (SoundON==True && !TurnedDown && i==BarCount-1 && IsEmpty(DownTrendLine[i-1]))
  137. {
  138. Say("Bollinger Bands going Down");
  139. TurnedUp=StaticVarSet("TurnedUp",0);
  140. TurnedDown=StaticVarSet("TurnedDown",1);
  141. }
  142. } //if (trend<0)
  143. } //for
  144. } //procedure
  145.  
  146. bbtop=BBandTop(C,Length,Deviation);
  147. bbbot=BBandBot(C,Length,Deviation);
  148.  
  149. CalcTrend_proc(bbtop,bbbot,Length,MoneyRisk,SoundON,TurnedUp,TurnedDown);
  150. UpTrendSigNal=UpTrendLine AND IsEmpty(Ref(UpTrendLine,-1));
  151. DownTrendSigNal=DownTrendLine AND IsEmpty(Ref(DownTrendLine,-1));
  152.  
  153. DisplayStyle = styleNoLabel|styleDots|styleNoTitle;
  154. if(LineStyle == 0) DisplayStyle |= styleNoLine;
  155.  
  156.  
  157. Plot(UpTrendLine,"UPTRENDLINE",cUpTrendLine,DisplayStyle);
  158. Plot(DownTrendLine,"DOWNTRENDLINE",cDnTrendLine,DisplayStyle) ;
  159.  
  160. PlotShapes(IIf(UpTrendSignal,shapeCircle,shapeNone ),cUpTrendLine,0,bbbot,0);
  161. PlotShapes(IIf(DownTrendSignal,shapeCircle,shapeNone),cDnTrendLine,0,bbtop,0);
  162. _SECTION_END();
  163.  
  164. _SECTION_BEGIN("Wave Channel");
  165.  
  166. cOutLine = ParamColor("Outer Line", colorWhite);
  167. cMidLine = ParamColor("Mid Line", colorGrey40);
  168.  
  169. Plot( MA(C, 53), "", cMidLine, styleNoLabel);
  170. Plot( MA(H, 53), "", cOutLine, styleThick|styleNoLabel);
  171. Plot( MA(L, 53), "", cOutLine, styleThick|styleNoLabel);
  172.  
  173.  
  174. _SECTION_END();
  175.  
  176. _SECTION_BEGIN("WMA Rainbow");
  177.  
  178. cOutLine = ParamColor("Outline", colorBlue);
  179. cInnerLine = ParamColor("Innerline", colorDarkBlue);
  180.  
  181.  
  182. Plot( WMA(C, 2), "", cOutLine, styleThick|styleNoLabel);
  183. Plot( WMA(C, 8), "", cOutLine, styleThick|styleNoLabel);
  184.  
  185. Plot( WMA(C, 3), "", cInnerLine, styleNoLabel);
  186. Plot( WMA(C, 4), "", cInnerLine, styleNoLabel);
  187. Plot( WMA(C, 5), "", cInnerLine, styleNoLabel);
  188. Plot( WMA(C, 6), "", cInnerLine, styleNoLabel);
  189. Plot( WMA(C, 7), "", cInnerLine, styleNoLabel);
  190.  
  191.  
  192. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement