xmd79

Tom DeMark Sequential Heat Map

May 16th, 2022
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. ////////////////////////////////////////// Tom DeMark heatmap © by Indicator-Jones /////////////////////////////////////////
  2. //
  3. // This indicator uses Tom DeMark’s TD Sequential counting from 1 to 13.
  4. // Number 9 and 13 usually identify an exhausted trend and mark trend reversal.
  5. // The important numbers get displayed as labels (7-13), where 9 and 13 are both highlighted as "Long" or "Short".
  6. // Besides the numbers the price candles are colored based upon the sequence.
  7. // Bullish colors are starting from bright yellow (TD 1 = start of trend) to dark red (TD 13 = trend exhausted)
  8. // Bearish colors are starting from bright blue (TD 1 = start of trend) to dark blue (TD 13 = trend exhausted)
  9. //
  10. // DeMark recommends to be used for short term price reversals only but as you can see in the chart, it also works for LUNA 1D chart.
  11. // Also works very well with Heikin Ashi candles.
  12. // Use it in combination with for example the "Tom DeMark Pressure Ratio" to find tops and bottoms.
  13. // You can change the timeframes, disable lables/barcolor and customise colors to your liking.
  14. //
  15. // If you have any idea on how to optimise the code, please feel free to share :)
  16. //
  17. // Inspired by "Stochastic Heat Map" from @Violent
  18. //
  19. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  20.  
  21. //@version=5
  22. indicator(title='Tom DeMark Sequential Heat Map', shorttitle='TD heatmap', overlay=true, timeframe='')
  23. //A heat map for TD counts. If you find this useful or yank the code, please consider a donation :)
  24.  
  25. // -------- Inputs --------
  26. paintBars = input(title='Paint Bars', defval=true)
  27. showLabels = input(title='Show labels', defval=true)
  28.  
  29. buy_col = input.color(color.new(#32CD32,0),'Colors',inline='col')
  30. sell_col = input.color(color.new(#F44336,0),'',inline='col')
  31. text_col = input.color(color.new(#FFFFFF,0),'',inline='col')
  32.  
  33.  
  34. // -------- Bearish trend (blue) color selection --------
  35. buyColors = array.from(#11e7f2, #11d9f2, #11cbf2, #11aff2, #1193f2, #1176f2, #105df4, #1051f5, #0f44f5, #0c3de0, #0935ca, #062eb4, #02269e )
  36. currentBuyColor(count) =>
  37. array.get(buyColors, count-1)
  38.  
  39. // -------- Bullish trend (red) color selection --------
  40. sellColors = array.from(#eef211, #efdc11, #f0c511, #f1af11, #f29811, #f28811, #f27811, #f26811, #f25811, #ea420d, #e12c09, #d81605, #cf0000 )
  41. currentSellColor(count) =>
  42. array.get(sellColors, count-1)
  43.  
  44.  
  45. // -------- Calculate bearish trend sequence --------
  46. buySetup = 0
  47. buySetup := close < close[4] ? buySetup[1] == 13 ? 1 : buySetup[1] + 1 : 0
  48.  
  49. // -------- Calculate bullish trend sequence --------
  50. sellSetup = 0
  51. sellSetup := close > close[4] ? sellSetup[1] == 13 ? 1 : sellSetup[1] + 1 : 0
  52.  
  53.  
  54. // -------- Paint bars --------
  55. barColour = buySetup >= 1 ? currentBuyColor(buySetup) : sellSetup >= 1 ? currentSellColor(sellSetup) : na
  56. barcolor(paintBars ? barColour : na, title='Bar colors (heatmap)')
  57.  
  58.  
  59. // -------- Plot labels --------
  60. plotshape(showLabels ? buySetup == 7 : na, title='TD buy sequence 7', location=location.belowbar, style=shape.labelup, size=size.tiny, color=buy_col, text="7", textcolor=text_col)
  61. plotshape(showLabels ? sellSetup == 7 : na, title='TD sell sequence 7', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=sell_col, text="7", textcolor=text_col)
  62. plotshape(showLabels ? buySetup == 8 : na, title='TD buy sequence 8', location=location.belowbar, style=shape.labelup, size=size.tiny, color=buy_col, text="8", textcolor=text_col)
  63. plotshape(showLabels ? sellSetup == 8 : na, title='TD sell sequence 8', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=sell_col, text="8", textcolor=text_col)
  64. plotshape(showLabels ? buySetup == 9 : na, title='TD buy sequence 9', location=location.belowbar, style=shape.labelup, size=size.tiny, color=buy_col, text="Long", textcolor=text_col)
  65. plotshape(showLabels ? sellSetup == 9 : na, title='TD sell sequence 9', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=sell_col, text="Short", textcolor=text_col)
  66. plotshape(showLabels ? buySetup == 10 : na, title='TD buy sequence 10', location=location.belowbar, style=shape.labelup, size=size.tiny, color=buy_col, text="10", textcolor=text_col)
  67. plotshape(showLabels ? sellSetup == 10 : na, title='TD sell sequence 10', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=sell_col, text="10", textcolor=text_col)
  68. plotshape(showLabels ? buySetup == 11 : na, title='TD buy sequence 11', location=location.belowbar, style=shape.labelup, size=size.tiny, color=buy_col, text="11", textcolor=text_col)
  69. plotshape(showLabels ? sellSetup == 12 : na, title='TD sell sequence 11', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=sell_col, text="12", textcolor=text_col)
  70. plotshape(showLabels ? buySetup == 12 : na, title='TD buy sequence 12', location=location.belowbar, style=shape.labelup, size=size.tiny, color=buy_col, text="12", textcolor=text_col)
  71. plotshape(showLabels ? sellSetup == 11 : na, title='TD sell sequence 12', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=sell_col, text="11", textcolor=text_col)
  72. plotshape(showLabels ? buySetup == 13 : na, title='TD buy sequence 13', location=location.belowbar, style=shape.labelup, size=size.tiny, color=buy_col, text="Long", textcolor=text_col)
  73. plotshape(showLabels ? sellSetup == 13 : na, title='TD sell sequence 13', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=sell_col, text="Short", textcolor=text_col)
  74.  
  75.  
  76. // -------- Alerts --------
  77. alertcondition(buySetup == 7, title='Start of BUY zone (TD = 7)', message='{{ticker}} start of BUY zone. TD sequence = 7 on {{interval}} timeframe.')
  78. alertcondition(sellSetup == 7, title='Start of SELL zone (TD = 7)', message='{{ticker}} start of SELL zone. TD sequence = 7 on {{interval}} timeframe.')
  79. alertcondition(buySetup == 9, title='BUY alert (TD = 9)', message='{{ticker}} has a TD buy sequence of 9 on {{interval}} timeframe.')
  80. alertcondition(sellSetup == 9, title='SELL alert (TD = 9)', message='{{ticker}} has a TD sell sequence of 9 on {{interval}} timeframe.')
  81. alertcondition(buySetup == 13, title='BUY alert (TD = 13)', message='{{ticker}} has a TD buy sequence of 13 on {{interval}} timeframe.')
  82. alertcondition(sellSetup == 13, title='SELL alert (TD = 13)', message='{{ticker}} has a TD sell sequence of 13 on {{interval}} timeframe.')
  83. alertcondition(buySetup >= 7 or sellSetup >= 7, title='ANY alert "buy and sell" (TD 7 - 13) ', message='{{ticker}} has a TD sequence >= 7 on {{interval}} timeframe.')
  84. alertcondition(buySetup == 9 or sellSetup == 9, title='ANY alert "buy and sell" (TD = 9) ', message='{{ticker}} has a TD sequence >= 9 on {{interval}} timeframe.')
  85. alertcondition(buySetup == 13 or sellSetup == 13, title='ANY alert "buy and sell" (TD = 13) ', message='{{ticker}} has a TD sequence = 13 on {{interval}} timeframe.')
  86.  
Advertisement
Add Comment
Please, Sign In to add comment