Advertisement
Guest User

SM_Squish v1.1

a guest
Jun 29th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #
  2. # The Squish
  3. #
  4. # Works like "the Squeeze" (TTM_Squeeze in Thinkorswim),
  5. # but replaces the default histogram with MACD Histogram,
  6. # which seems more accurate.
  7. #
  8.  
  9. declare lower;
  10.  
  11. ###################
  12. # MACD histogram
  13. ###################
  14.  
  15. def fastLength = 12;
  16. def slowLength = 26;
  17. def MACD_Length = 9;
  18. def averageType = AverageType.EXPONENTIAL;
  19. def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
  20. def Avg = MovingAverage(averageType, Value, MACD_Length);
  21. plot Diff = Value - Avg;
  22. Diff.SetDefaultColor(GetColor(5));
  23. Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
  24. Diff.SetLineWeight(3);
  25. Diff.DefineColor("above going higher", Color.UPTICK);
  26. Diff.DefineColor("above going lower", Color.DOWNTICK);
  27. Diff.DefineColor("below going lower", Color.DOWNTICK);
  28. Diff.DefineColor("below going up", Color.UPTICK);
  29. Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("above going higher") else Diff.Color("above going lower") else if Diff < Diff[1] then Diff.Color("below going lower") else Diff.Color("below going up"));
  30.  
  31. ###################
  32. # Squeeze (dots)
  33. ###################
  34.  
  35. input Length = 20; # Length for Avg True Range & Std. Dev Calcs
  36. input Price = Close; # type of price to use
  37. input minPriceMove = 1; # for scaling
  38. input priceIncrement = 0.01;
  39. input nK = 1.5; # Keltner Channel ATRs from Average
  40. input nBB = 2; # Bollinger Band Std. Devs. from Average
  41. input AlertLine = 1; # BBS_Index level at which to issue alerts
  42. input SqueezeOnColor = 2;
  43. input SqueezeOffColor = 6;
  44.  
  45. def ATR = Average(TrueRange(high, close, low), Length);
  46. def SDev = StDev(Price, Length);
  47. def Denom = (nK * ATR);
  48. def BBS_Ind = If (Denom <> 0, ((nBB * SDev) / Denom), 0);
  49. plot BBS_Index = 0;
  50. BBS_Index.AssignValueColor(if BBS_Ind < AlertLine then Color.RED else Color.GREEN);
  51. BBS_Index.SetStyle(4);
  52. BBS_Index.SetLineWeight(2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement