xmd79

Phenom 2.0

May 24th, 2023 (edited)
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. //Phenom 2.0
  2.  
  3. //@version=5
  4. indicator("Phenom", overlay=true)
  5.  
  6. //{ EMA
  7.  
  8. //input
  9. showEma = input(title='Show Ema', group='EMA', defval=true)
  10. showColor = input(title='Color bar', group='EMA', defval=true)
  11. emaLeght1 = input(title='EMA 1', group='EMA', defval=5)
  12. emaLeght2 = input(title='EMA 2', group='EMA', defval=10)
  13. emaLeght3 = input(title='EMA 3', group='EMA', defval=20)
  14. emaLeght4 = input(title='EMA 4', group='EMA', defval=50)
  15. emaLeght5 = input(title='EMA 5', group='EMA', defval=100)
  16. emaLeght6 = input(title='EMA 5', group='EMA', defval=150)
  17. emaLeght7 = input(title='EMA 5', group='EMA', defval=200)
  18.  
  19. //calc
  20. ema1 = ta.ema(close, emaLeght1)
  21. ema2 = ta.ema(close, emaLeght2)
  22. ema3 = ta.ema(close, emaLeght3)
  23. ema4 = ta.ema(close, emaLeght4)
  24. ema5 = ta.ema(close, emaLeght5)
  25. ema6 = ta.ema(close, emaLeght6)
  26. ema7 = ta.ema(close, emaLeght7)
  27.  
  28. //plot
  29. plot1 = plot(showEma ? ema1 : na, color=color.gray, transp=50, linewidth=1)
  30. plot2 = plot(showEma ? ema2 : na, color=ema2 < ema3 ? color.red : color.green, transp=30, linewidth=2)
  31. plot3 = plot(showEma ? ema3 : na, color=ema2 < ema3 ? color.red : color.green, transp=30, linewidth=2)
  32. plot4 = plot(showEma ? ema4 : na, color=color.gray, transp=80,linewidth=1)
  33. plot5 = plot(showEma ? ema5 : na, color=color.gray, transp=80, linewidth=1)
  34. plot6 = plot(showEma ? ema6 : na, color=color.gray, transp=80, linewidth=1)
  35. plot7 = plot(showEma ? ema7 : na, color=color.white, linewidth=2)
  36.  
  37. //fill
  38. fill(plot2, plot3, color=ema2 < ema3 ? color.red : color.green, transp=80)
  39. fill(plot2, plot4, color=ema2 < ema4 ? color.red : color.green, transp=95)
  40. fill(plot2, plot5, color=ema2 < ema5 ? color.red : color.green, transp=95)
  41. fill(plot2, plot6, color=ema2 < ema6 ? color.red : color.green, transp=95)
  42. fill(plot2, plot7, color=ema2 < ema7 ? color.red : color.green, transp=95)
  43.  
  44. //bar color
  45. colRed = color.rgb(207, 102, 91, 0)
  46. colGreen = color.rgb(101, 161, 154, 0)
  47. barColor = ema2 < ema3 ? colRed : colGreen
  48. barcolor(showColor ? barColor:na)
  49. //}
  50.  
  51.  
  52. //{ ATR
  53.  
  54. //input
  55. showAtr = input(title="Show Atr", group="ATR", defval=true)
  56. mood = input.string("Long", title='Mood', group='ATR', options=["Long", "Short"])
  57. atrLeght = input(title='ATR Leght', group="ATR", defval=14)
  58. atrMultiply1 = input.float(title="ATR stop", group="ATR", step=0.1, defval=1.5)
  59. atrMultiply2 = input.float(title="ATR conform", group="ATR", step=0.1, defval=0.5)
  60. lastBar = input(title="Values to show", group="ATR", defval=2)
  61.  
  62. //calc atr
  63. atr = ta.atr(atrLeght)
  64.  
  65. atrShortStop = close + atr*atrMultiply1
  66. atrLongStop = close - atr*atrMultiply1
  67.  
  68. atrShortConform = close - atr*atrMultiply2
  69. atrLongConform = close + atr*atrMultiply2
  70.  
  71. //plot short
  72. plot(showAtr ? mood == "Short" ? atrShortStop : na : na, style=plot.style_circles, color=color.red, show_last = lastBar, linewidth = 2)
  73. plot(showAtr ? mood == "Short" ? atrShortStop : na : na, show_last = lastBar, color=color.rgb(255, 82, 82, 50))
  74.  
  75. plot(showAtr ? mood == "Short" ? atrShortConform: na : na, style=plot.style_circles, color=color.red, show_last = lastBar, linewidth = 2)
  76. plot(showAtr ? mood == "Short" ? atrShortConform: na : na, show_last = lastBar, color=color.rgb(255, 82, 82, 50))
  77.  
  78. //plot long
  79. plot(showAtr ? mood == "Long" ? atrLongStop: na :na, style=plot.style_circles, color=color.green, show_last = lastBar, linewidth = 2)
  80. plot(showAtr ? mood == "Long" ? atrLongStop: na:na, show_last = lastBar, color=color.rgb(76, 175, 79, 50))
  81.  
  82. plot(showAtr ? mood == "Long" ? atrLongConform : na:na, style=plot.style_circles, color=color.green, show_last = lastBar, linewidth = 2)
  83. plot(showAtr ? mood == "Long" ? atrLongConform : na:na, show_last = lastBar, color=color.rgb(76, 175, 79, 50))
  84. //}
  85.  
  86.  
  87. //{ Cell
  88.  
  89. //ipnput
  90. showCell = input(title='Show Cell', group='Cell', defval=true)
  91. depo = input(title='Depo', group='Cell', defval=10000)
  92. risk = input.float(title='Risc % of depo', group='Cell', step=0.1, defval=1.0)
  93. currency = input.string('USD', title='Currency', group='Cell', options=['USD', 'RUB'])
  94.  
  95. //calc
  96. sumRisc=(depo/100)*risk
  97. sumStock=sumRisc/(close-atrLongStop)
  98. sumDeal = sumStock*close
  99. atrPercent = (close - atrLongStop)/close*100
  100.  
  101. //cell
  102. var table atrDisplay = table.new(position.bottom_right, columns = 10, rows = 10, bgcolor = color.black, frame_width=1, frame_color=color.rgb(255, 255, 255, 50), border_color=color.white)
  103.  
  104. if (showCell)
  105.  
  106. table.cell(atrDisplay, 0, 0, str.tostring("Depo"), text_color=color.white,text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134, 50))
  107.  
  108. if (currency == "USD")
  109. table.cell(atrDisplay, 0, 1, str.tostring(depo, "#$"), text_color=color.white,text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134, 50))
  110. if (currency == "RUB")
  111. table.cell(atrDisplay, 0, 1, str.tostring(depo, "#₽"), text_color=color.white,text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134, 50))
  112.  
  113. table.cell(atrDisplay, 1, 0, str.tostring(risk, "Risk #.#") + str.tostring("%") , text_color=color.white, text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134,0))
  114.  
  115. if (currency == "USD")
  116. table.cell(atrDisplay, 1, 1, str.tostring(sumRisc, "#.#$"), text_color=color.white, text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134, 0))
  117. if (currency == "RUB")
  118. table.cell(atrDisplay, 1, 1, str.tostring(sumRisc, "#.#₽"), text_color=color.white, text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134, 0))
  119.  
  120. table.cell(atrDisplay, 0, 2, str.tostring(atrMultiply1, "Stop #.## ATR"), text_color=color.white, text_halign=text.align_left, bgcolor = atrPercent < 5 ? color.green:color.red)
  121. table.cell(atrDisplay, 0, 3, str.tostring(atrLongStop, "#.#") + str.tostring(atrPercent, " (#.#") + str.tostring("%) "),text_color=color.white, text_halign=text.align_left, bgcolor = atrPercent < 5 ? color.green:color.red)
  122.  
  123. table.cell(atrDisplay, 1, 2, str.tostring("Sum stock"), text_color=color.white, text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134,50))
  124.  
  125. if (currency == "USD")
  126. table.cell(atrDisplay, 1, 3, str.tostring(sumStock, "#") + str.tostring(sumDeal, " (#$)"), text_color=color.white, text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134,50))
  127. if (currency == "RUB")
  128. table.cell(atrDisplay, 1, 3, str.tostring(sumStock, "#") + str.tostring(sumDeal, " (#₽)"), text_color=color.white, text_halign=text.align_left, bgcolor=color.rgb(120, 123, 134,50))
  129. //}
Advertisement
Add Comment
Please, Sign In to add comment