xmd79

Cavuca Technical Analysis

Jan 11th, 2022
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. ///\\===============================================================================//\\\
  3. //████████╗██████╗ █████╗ ██████╗ ██╗███╗ ██╗ ██████╗ ██╗ ██╗██╗███████╗██╗ ██╗\\
  4. //╚══██╔══╝██╔══██╗██╔══██╗██╔══██╗██║████╗ ██║██╔════╝ ██║ ██║██║██╔════╝██║ ██║\\
  5. // ██║ ██████╔╝███████║██║ ██║██║██╔██╗ ██║██║ ███╗██║ ██║██║█████╗ ██║ █╗ ██║\\
  6. // ██║ ██╔══██╗██╔══██║██║ ██║██║██║╚██╗██║██║ ██║╚██╗ ██╔╝██║██╔══╝ ██║███╗██║\\
  7. // ██║ ██║ ██║██║ ██║██████╔╝██║██║ ╚████║╚██████╔╝ ╚████╔╝ ██║███████╗╚███╔███╔╝\\
  8. // ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ \\
  9. //\\==============================================================================//\\ \\
  10. // ----------------------------------------------------------------------------------- \\
  11. // CAVUCA INDICATOR TECHNICAL ANALYSIS: Developed by Cavuca-Trader \\
  12. // ----------------------------------------------------------------------------------- \\
  13. // ................................................................................... \\
  14. // Name : Cavuca Technical Analysis \\
  15. // Surname : Cavuca \\
  16. // Description : Technical Analysis Setup \\
  17. // Info : Signals inputs and outputs through technical coloring \\
  18. // Creation Date : 11/20/2021 \\
  19. // Version TradingView : 4 \\
  20. // ................................................................................... \\
  21. // v1.0 - release = TrandingView = Ok \\
  22. //=====================================================================================\\
  23. // © Cavuca-Trader
  24. //@version=4
  25. study(title="Cavuca Technical Analysis",shorttitle="Cavuca", overlay=true)
  26.  
  27. //Parameters for the zigzag
  28. length = input(4, title = "High/Low length")
  29. h = highest(high, length * 2 + 1)
  30. l = lowest(low, length * 2 + 1)
  31. f_isMin(len) =>
  32. l == low[len]
  33. f_isMax(len) =>
  34. h == high[len]
  35.  
  36. //Parameters
  37. MMR = input(9, minval=1, title="Fast Moving Average")
  38. MMM = input(21, minval=1, title="Moving Average Average")
  39. MML = input(200, minval=1, title="Slow Moving Average")
  40. src = input(close, title="Source")
  41. offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  42.  
  43. //Calculation
  44. MM1 = sma(src, MMR)
  45. MM2 = sma(src, MMM)
  46. MM3 = sma(src, MML)
  47.  
  48. // Calculation for ZigZag
  49. var dirUp = false
  50. var lastLow = high * 100
  51. var lastHigh = 0.0
  52. var timeLow = bar_index
  53. var timeHigh = bar_index
  54. var line li = na
  55. var topo = 0.0
  56. var fundo = high * 100
  57.  
  58. f_drawLine() =>
  59. _li_color = dirUp ? color.teal : color.orange
  60. line.new(timeHigh - length, lastHigh, timeLow - length, lastLow, xloc.bar_index, color=_li_color, width=1)
  61.  
  62. if dirUp
  63. if (f_isMin(length) and low[length] < lastLow)
  64. lastLow := low[length]
  65. timeLow := bar_index
  66. line.delete(li)
  67. li := f_drawLine()
  68.  
  69. if (f_isMax(length) and high[length] > lastLow)
  70. lastHigh := high[length]
  71. timeHigh := bar_index
  72. topo := lastHigh
  73. dirUp := false
  74. li := f_drawLine()
  75.  
  76. if not dirUp
  77. if (f_isMax(length) and high[length] > lastHigh)
  78. lastHigh := high[length]
  79. timeHigh := bar_index
  80. line.delete(li)
  81. li := f_drawLine()
  82.  
  83. if f_isMin(length) and low[length] < lastHigh
  84. lastLow := low[length]
  85. timeLow := bar_index
  86. fundo := lastLow
  87. dirUp := true
  88. li := f_drawLine()
  89. if (f_isMax(length) and high[length] > lastLow)
  90. lastHigh := high[length]
  91. timeHigh := bar_index
  92. dirUp := false
  93. li := f_drawLine()
  94.  
  95. //Candle coloring rule
  96. Dgbar = close>topo
  97. Drbar = close<fundo
  98. Dwbar = close<topo and close > fundo
  99.  
  100. //Color of candles
  101. barcolor(Dgbar ? color.green : na)
  102. barcolor(Drbar ? color.red : na)
  103. barcolor(Dwbar ? color.white : na)
  104.  
  105. // Plot
  106. plot(MM1, color=color.red, title="MMR", offset=offset, linewidth=1)
  107. plot(MM2, color=color.blue, title="MMM", offset=offset, linewidth=1)
  108. plot(MM3, color=color.white, title="MML", offset=offset, linewidth=1)
  109. plot(fundo, color=color.green, title="Fundo", offset=-length, style=plot.style_cross, linewidth=1)
  110. plot(topo, color=color.red, title="Topo", offset=-length, style=plot.style_cross, linewidth=1)
  111.  
  112.  
Advertisement
Add Comment
Please, Sign In to add comment