Pbholdings111

Ehler's Stochastic

Apr 29th, 2024
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #
  2. # TD Ameritrade IP Company, Inc. (c) 2013-2024
  3. #
  4.  
  5. declare lower;
  6.  
  7. input price = close;
  8. input length = 20;
  9. input cutoffLength = 10;
  10. input over_bought = 0.8;
  11. input over_sold = 0.2;
  12. input mode = {default Predictive, Conventional};
  13.  
  14. def filt = reference EhlersRoofingFilter(price, cutoffLength);
  15. def highestP = Highest(filt, length);
  16. def lowestP = Lowest(filt, length);
  17. def stoch = if (highestP - lowestP) != 0 then (filt - lowestP) / (highestP - lowestP) else 0;
  18.  
  19. plot Stochastic = reference EhlersSuperSmootherFilter(stoch, cutoffLength);
  20. plot OverBought = over_bought;
  21. plot OverSold = over_sold;
  22. plot Buy;
  23. plot Sell;
  24. switch (mode) {
  25. case Predictive:
  26. Buy = if Stochastic crosses below OverSold then OverSold + 0.05 else Double.NaN;
  27. Sell = if Stochastic crosses above OverBought then OverBought - 0.05 else Double.NaN;
  28. case Conventional:
  29. Buy = if Stochastic crosses above OverSold then OverSold + 0.05 else Double.NaN;
  30. Sell = if Stochastic crosses below OverBought then OverBought - 0.05 else Double.NaN;
  31. }
  32.  
  33. Stochastic.SetDefaultColor(GetColor(5));
  34. OverBought.SetDefaultColor(GetColor(7));
  35. OverSold.SetDefaultColor(GetColor(7));
  36. Buy.SetDefaultColor(Color.UPTICK);
  37. Buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
  38. Buy.HideBubble();
  39. Sell.SetDefaultColor(Color.DOWNTICK);
  40. Sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
  41. Sell.HideBubble();
Advertisement
Add Comment
Please, Sign In to add comment