Advertisement
saisri

macd colourful

Jul 15th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. _SECTION_BEGIN("Unnamed 6");
  2. /*
  3. BB Squeeze (conversion for TS code)
  4.  
  5.  
  6. Instructions
  7. Insert Linked to new chart pane
  8. Periods can be selected in Param window
  9.  
  10. For swing trading:
  11. I scan the EOD stock data using the ZigZag indicator for buy/sell signals and confirm the following for the buy decision:
  12. . The close is just crossed the 8 day MA (or close to it) and 20 day MA is moving up direction (on a daily price chart)
  13. . The stochastic indicator shows "oversold" condition is improving
  14. . TTM Sqeeze shows up momentum.
  15. */
  16.  
  17. Price = Close;
  18. Length = Param("Length",20,2,100,1); // { Length for Average True
  19. //Range (ATR)}
  20. Lenght1 = Param("Length1",20,2,100,1); // { Std. Deviation (SD)
  21. //Calcs }
  22.  
  23. nK = Param("Channel ATRs",1.5,0.1,2,0.1); //{ Keltner Channel ATRs
  24. //from Average }
  25. nBB = Param("BB Std Devs",2,0.1,3,0.1); // { Bollinger Band Std.
  26. //Devs. from Average }
  27. AlertLine = Param("AlertLine",1,0,3,1); //{ BBS_Index level at which
  28. //to issue alerts }
  29.  
  30. NormalColor = colorRed; //{ Normal color for BBS_Ind }
  31. AlertlColor = colorBlue; //{ Color for BBS_Ind below alert line }
  32.  
  33.  
  34. LHMult = Nz(PointValue/TickSize);
  35.  
  36. //{-- Calculate BB Squeeze Indicator ----------------------}
  37. AvgTrueRange = ATR(Length);
  38. SDev = StDev(Price, Length);
  39.  
  40. Denom = nK*AvgTrueRange;
  41. BBS_Ind = Nz((nBB * SDev) /Denom);
  42.  
  43. SetPlotColor = IIf( BBS_Ind < Alertline, NormalColor, AlertlColor);
  44. BBcrossDown = Cross(AlertLine,BBS_Ind);
  45. BBcrossUp = Cross(BBS_Ind,AlertLine);
  46.  
  47. SetChartOptions( 0, chartShowDates|chartWrapTitle );
  48. GraphXSpace=10;
  49. //_N(Title = "{{NAME}} - {{INTERVAL}} {{DATE}} "+_DEFAULT_NAME()+" :
  50. //{{OHLCX}} {{VALUES}}");
  51. //+"\nALERT: "+WriteIf(BBcrossDown,"BB Squeeze Alert",WriteIf
  52. //(BBcrossUp,"BB Squeeze Is Over","")) );
  53.  
  54.  
  55. //{-- Plot the Index & Alert Line -------------------------}
  56. Plot(0, "BBS_Ind", SetPlotColor, styleDots );
  57.  
  58. //{-- Plot delta of price from Donchian mid line ----------}
  59. value2 = LinearReg( price-((HHV(H, Lenght1)+LLV(L, Lenght1))/2+ MA
  60. (C,Lenght1))/2, Lenght1);
  61. color = IIf( value2 > 0, IIf( value2 > Ref(value2,-1), colorGreen,
  62. colorDarkGreen),
  63. IIf( value2 < 0, IIf( value2 < Ref(value2,-1), colorRed,
  64. colorDarkRed ), colorYellow ));
  65.  
  66. Plot(value2*LHMult, "NickmNxtMove", color, styleArea );
  67. Plot(value2,"BB Squeeze",color, styleArea );
  68. //{-- Issue Alert when the Squeeze is On ------------------}
  69. //"ALERT";
  70. //Write alerts to Interpretation window
  71. //Ticker = Name();
  72. //WriteIf(BBcrossDown,Ticker + " " + "BB Squeeze Alert" ,WriteIf
  73. //(BBcrossUp,Ticker + " " + "BB Squeeze Is Over",""));
  74.  
  75. //Write alerts to Alert Output window
  76. AlertIf(BBcrossDown,"","BB Squeeze Alert",0);
  77. AlertIf(BBcrossUp,"","BB Squeeze Is Over",0);
  78.  
  79. //Sound alerts
  80. //AlertIf( BBcrossDown, "SOUND
  81. //C:\\Windows\\Media\\RINGIN.WAV", "Audio alert", 2 );
  82. //AlertIf( BBcrossUp, "SOUND C:\\Windows\\Media\\RINGIN.WAV", "Audio
  83. //alert", 2 );
  84.  
  85.  
  86. //Write text to screen
  87. /*
  88. for(i=1;i<BarCount;i++)
  89. {
  90. if(BBcrossDown[i])
  91. {
  92. PlotText("BB Squeeze Alert",i,-6,colorWhite);
  93. }
  94. if(BBcrossUp[i])
  95. {
  96. PlotText("BB Squeeze Is Over",i,-3,colorWhite);
  97. }
  98. }
  99. */
  100. PlotShapes(shapeUpArrow*BBcrossDown,colorBrightGreen,0,0);
  101. PlotShapes(shapeDownArrow*BBcrossup,colorBrightGreen,0,0);
  102. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement