[text] script

Viewer

  1. //PLEASE READ BELOW BEFORE USING THIS INDICATOR IN ANY WAY.
  2.  
  3. // This work is licensed under an Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
  4.  
  5. // THIS COPYRIGHT MEANS THAT YOU ARE NOT ALLOWED TO TAKE THIS CODE AND SELL IT UNDER ANY CIRCUMSTANCES.
  6. // YOU ARE ALLOWED TO EDIT THE CODE AS MUCH AS YOU WANT FOR PERSONAL USE, BUT IF YOU DECIDE TO PUBLISH YOUR ALTERED VERSION YOU MUST GIVE ME CREDIT.
  7. // IF YOU DO PUBLISH AN EDITED VERSION, YOU MUST USE THE SAME COPYRIGHT AS WELL.
  8. // NO MATTER HOW MUCH YOU ALTER THE CODE, YOU STILL CANNOT SELL IT UNDER THE RULES OF THIS COPYRIGHT.
  9.  
  10. // INFRINGEMENT OF THIS COPYRIGHT MAY RESULT IN A LAWSUIT SO PLEASE RESPECT THE RULES OF THE COPYRIGHT.
  11. // I CREATED THIS FOR THE COMMUNITY TO USE AND ENJOY. NOT FOR OTHERS TO MAKE PROFIT OFF IT.
  12.  
  13. // © HomelessLemon
  14. // A product of Project Lemon LLC
  15.  
  16. //@version=4
  17. study("☁️ Algo XRP -15 Minutes☁️", overlay=true)
  18.  
  19. //Gathers User Inputs
  20. voidLines = input(true, "Void Lines On / Off")
  21. dashOn = input(true, "Dashboard On / Off")
  22. colorBar = input(true, "Signal Bars On / Off")
  23. srLines = input(false, "Support & Resistance Lines On / Off")
  24. emaLines = input(false, "EMA (8, 200) On / Off")
  25. bsSignals = input(true, "Buy & Sell Signals On / Off")
  26. afibOn = input(false, "Fibonacci Retracement On / Off")
  27. dashDist = input(13, "Dashboard Distance")
  28. dashColor = input(color.new(#696969, 80), "Dashboard Color", inline="Dash Line")
  29. dashTextColor = input(color.new(#ffffff, 0), "Text Color", inline="Dash Line")
  30.  
  31. //Calculates Volatility for Dashboard
  32. atr = atr(14)
  33. stdAtr = 2 * stdev(atr, 20)
  34. smaAtr = sma(atr, 20)
  35. topAtrDev = smaAtr + stdAtr
  36. bottomAtrDev = smaAtr - stdAtr
  37. calcDev = (atr - bottomAtrDev) / (topAtrDev - bottomAtrDev)
  38. percentVol = (40 * calcDev + 30)
  39.  
  40. //Calculates Volume for Dashboard
  41. volumeDash = volume
  42.  
  43. //RSI for Dashboard
  44. rsiDash = rsi(close, 14)
  45.  
  46. //Calculates Sentiment for Dashboard
  47. ema9 = ema(close, 9)
  48. totalSentTxt = ema9 > ema9[2] ? "Bullish" : ema9 < ema9[2] ? "Bearish" : "Flat"
  49.  
  50. //Defines Each Timeframe for Trend Panel
  51. sma = sma(close, 50)
  52. oneM = security(syminfo.tickerid, "1", sma, barmerge.gaps_off, barmerge.lookahead_off)
  53. fiveM = security(syminfo.tickerid, "5", sma, barmerge.gaps_off, barmerge.lookahead_off)
  54. fifteenM = security(syminfo.tickerid, "15", sma, barmerge.gaps_off, barmerge.lookahead_off)
  55. thirtyM = security(syminfo.tickerid, "30", sma, barmerge.gaps_off, barmerge.lookahead_off)
  56. oneH = security(syminfo.tickerid, "60", sma, barmerge.gaps_off, barmerge.lookahead_off)
  57. twoH = security(syminfo.tickerid, "120", sma, barmerge.gaps_off, barmerge.lookahead_off)
  58. fourH = security(syminfo.tickerid, "240", sma, barmerge.gaps_off, barmerge.lookahead_off)
  59. weekly = security(syminfo.tickerid, "W", sma, barmerge.gaps_off, barmerge.lookahead_off)
  60. monthly = security(syminfo.tickerid, "M", sma, barmerge.gaps_off, barmerge.lookahead_off)
  61. daily = security(syminfo.tickerid, "D", sma, barmerge.gaps_off, barmerge.lookahead_off)
  62.  
  63. //Defines An Uptrend for Trend Panel
  64. oneMUp = oneM > oneM[1]
  65. fiveMUp = fiveM > fiveM[1]
  66. fifteenMUp = fifteenM > fifteenM[1]
  67. thirtyMUp = thirtyM > thirtyM[1]
  68. oneHUp = oneH > oneH[1]
  69. twoHUp = twoH > twoH[1]
  70. fourHUp = fourH > fourH[1]
  71. weeklyUp = weekly > weekly[1]
  72. monthlyUp = monthly > monthly[1]
  73. dailyUp = daily > daily[1]
  74.  
  75. //Checks if the Current State is an Uptrend or Downtrend for the Trend Panel
  76. up = "📈"
  77. down = "📉"
  78. oneMTrend = oneMUp ? up : down
  79. fiveMTrend = fiveMUp ? up : down
  80. fifteenMTrend = fifteenMUp ? up : down
  81. thirtyMTrend = thirtyMUp ? up : down
  82. oneHTrend = oneHUp ? up : down
  83. twoHTrend = twoHUp ? up : down
  84. fourHTrend = fourHUp ? up : down
  85. weeklyTrend = weeklyUp ? up : down
  86. monthlyTrend = monthlyUp ? up : down
  87. dailyTrend = dailyUp ? up : down
  88.  
  89. if dashOn
  90.     label lemonLabel = label.new(time, close,
  91.      text="☁️ TV Community Algo Dashboard ☁️"
  92.      + "\n━━━━━━━━━━━━━━━━━"
  93.      + "\n           🤹 Market Information 🤹"
  94.      + "\n━━━━━━━━━━━━━━━━━"
  95.      + "\n🎈   Volatility                     | " + tostring(percentVol, "##.##") + "%"
  96.      + "\n🎈 Volume                           | " + tostring(volumeDash,"##.##" )
  97.      + "\n🎈 RSI                                           | " + tostring(rsiDash, "##.##")
  98.      + "\n🎈 Current Sentiment | " + totalSentTxt
  99.      + "\n━━━━━━━━━━━━━━━━━"
  100.      + "\n               🎪 Trend Panel 🎪"
  101.      + "\n━━━━━━━━━━━━━━━━━"
  102.      + "\n     1 Minute | " + oneMTrend + "         2 Hour | " + twoHTrend
  103.      + "\n     5 Minute | " + fiveMTrend + "         4 Hour | " + fourHTrend
  104.      + "\n        15 Minute | " + fifteenMTrend + "         Weekly | " + weeklyTrend
  105.      + "\n        30 Minute | " + thirtyMTrend + "       Monthly |     " + monthlyTrend
  106.      + "\n        1 Hour | " + oneHTrend + "                Daily | " + dailyTrend
  107.      + "\n━━━━━━━━━━━━━━━━━"
  108.      + "\n                        with love, -Lemon 🍋",
  109.      color=dashColor, xloc= xloc.bar_time, style=label.style_label_left, textcolor=dashTextColor, textalign=text.align_left)
  110.     label.set_x(lemonLabel, label.get_x(lemonLabel) + round(change(time)*dashDist))
  111.     label.delete(lemonLabel[1])
  112.  
  113. //Color Gradient Code
  114. //Shoutout to @LunaOwl for Making This!
  115.  
  116. //Red                                 //Orange
  117. Red_1 = color.new(#FF0000,  0),       Orange_1 = color.new(#FF9800,  0)
  118. Red_2 = color.new(#FF0000, 30),       Orange_2 = color.new(#FF9800, 30)
  119. Red_3 = color.new(#FF0000, 50),       Orange_3 = color.new(#FF9800, 50)
  120. Red_4 = color.new(#FF0000, 60),       Orange_4 = color.new(#FF9800, 70)
  121. Red_5 = color.new(#FF0000, 80),       Orange_5 = color.new(#FF9800, 80)
  122.  
  123. //Yellow                              //Green
  124. Yellow_1 = color.new(#FFE500,  0),    Green_1 = color.new(#00FF00,  0)
  125. Yellow_2 = color.new(#FFE500, 30),    Green_2 = color.new(#00FF00, 30)
  126. Yellow_3 = color.new(#FFE500, 50),    Green_3 = color.new(#00FF00, 50)
  127. Yellow_4 = color.new(#FFE500, 60),    Green_4 = color.new(#00FF00, 70)
  128. Yellow_5 = color.new(#FFE500, 80),    Green_5 = color.new(#00FF00, 80)
  129.  
  130. //Blue                                //Indigo
  131. Blue_1 = color.new(#4985E7,  0),      Indigo_1 = color.new(#7A2BCE,  0)
  132. Blue_2 = color.new(#4985E7, 30),      Indigo_2 = color.new(#7A2BCE, 30)
  133. Blue_3 = color.new(#4985E7, 50),      Indigo_3 = color.new(#7A2BCE, 50)
  134. Blue_4 = color.new(#4985E7, 60),      Indigo_4 = color.new(#7A2BCE, 60)
  135. Blue_5 = color.new(#4985E7, 80),      Indigo_5 = color.new(#7A2BCE, 80)
  136.  
  137. //Purple
  138. Purple_1 = color.new(#D12FAD,  0)
  139. Purple_2 = color.new(#D12FAD, 30)
  140. Purple_3 = color.new(#D12FAD, 50)
  141. Purple_4 = color.new(#D12FAD, 60)
  142. Purple_5 = color.new(#D12FAD, 80)
  143.  
  144.  
  145. //Creates Color Variable       //Creates Math Variable
  146. var color c = na,              var int k = na
  147.  
  148. k := nz(k[1], 1)      //This Equation Allows the Colors to Loop
  149.  
  150. //This Code Loops Through 63 Shades of 7 Colors//
  151.  
  152. if k == 1
  153.     c := Red_5
  154. if k == 2
  155.     c := Red_4
  156. if k == 3
  157.     c := Red_3
  158. if k == 4
  159.     c := Red_2
  160. if k == 5
  161.     c := Red_1
  162. if k == 6
  163.     c := Red_2
  164. if k == 7
  165.     c := Red_3
  166. if k == 8
  167.     c := Red_4
  168. if k == 9
  169.     c := Red_5
  170. if k == 10
  171.     c := Orange_5
  172. if k == 11
  173.     c := Orange_4
  174. if k == 12
  175.     c := Orange_3
  176. if k == 13
  177.     c := Orange_2
  178. if k == 14
  179.     c := Orange_1
  180. if k == 15
  181.     c := Orange_2
  182. if k == 16
  183.     c := Orange_3
  184. if k == 17
  185.     c := Orange_4
  186. if k == 18
  187.     c := Orange_5
  188. if k == 19
  189.     c := Yellow_5
  190. if k == 20
  191.     c := Yellow_4
  192. if k == 21
  193.     c := Yellow_3
  194. if k == 22
  195.     c := Yellow_2
  196. if k == 23
  197.     c := Yellow_1
  198. if k == 24
  199.     c := Yellow_2
  200. if k == 25
  201.     c := Yellow_3
  202. if k == 26
  203.     c := Yellow_4
  204. if k == 27
  205.     c := Yellow_5
  206. if k == 28
  207.     c := Green_5
  208. if k == 29
  209.     c := Green_4
  210. if k == 30
  211.     c := Green_3
  212. if k == 31
  213.     c := Green_2
  214. if k == 32
  215.     c := Green_1
  216. if k == 33
  217.     c := Green_2
  218. if k == 34
  219.     c := Green_3
  220. if k == 35
  221.     c := Green_4
  222. if k == 36
  223.     c := Green_5
  224. if k == 37
  225.     c := Blue_5
  226. if k == 38
  227.     c := Blue_4
  228. if k == 39
  229.     c := Blue_3
  230. if k == 40
  231.     c := Blue_2
  232. if k == 41
  233.     c := Blue_1
  234. if k == 42
  235.     c := Blue_2
  236. if k == 43
  237.     c := Blue_3
  238. if k == 44
  239.     c := Blue_4     
  240. if k == 45
  241.     c := Blue_5   
  242. if k == 46
  243.     c := Indigo_5
  244. if k == 47
  245.     c := Indigo_4
  246. if k == 48
  247.     c := Indigo_3
  248. if k == 49
  249.     c := Indigo_2
  250. if k == 50
  251.     c := Indigo_1
  252. if k == 51
  253.     c := Indigo_2
  254. if k == 52
  255.     c := Indigo_3
  256. if k == 53
  257.     c := Indigo_4
  258. if k == 54
  259.     c := Indigo_5
  260. if k == 55
  261.     c := Purple_5
  262. if k == 56
  263.     c := Purple_4
  264. if k == 57
  265.     c := Purple_3
  266. if k == 58
  267.     c := Purple_2
  268. if k == 59
  269.     c := Purple_1
  270. if k == 60
  271.     c := Purple_2
  272. if k == 61
  273.     c := Purple_3
  274. if k == 62
  275.     c := Purple_4
  276. if k == 63
  277.     c := Purple_5
  278.  
  279. k := k + 1
  280.  
  281. if k > 63
  282.     k := 1
  283.  
  284. // Auto Fibonacci Code
  285. threshold_multiplier = input(3, "Fibonacci Deviation")
  286. dev_threshold = atr(10) / close * 100 * threshold_multiplier
  287. depth = 10
  288. reverse = input(false, "Reverse Fib?")
  289. var extendLeft = input(false, "Extend Left    |    Extend Right", inline = "Extend Lines")
  290. var extendRight = input(true, "", inline = "Extend Lines")
  291. var extending = extend.none
  292. if extendLeft and extendRight
  293.     extending := extend.both
  294. if extendLeft and not extendRight
  295.     extending := extend.left
  296. if not extendLeft and extendRight
  297.     extending := extend.right
  298. prices = input(true, "Show Prices?")
  299. levels = input(true, "Show Levels?", inline = "Levels")
  300. levelsFormat = input("Percent", "", options = ["Values", "Percent"], inline = "Levels")
  301. labelsPosition = input("Right", "Fib Label Position", options = ["Left", "Right"])
  302.  
  303. var line lineLast = na
  304. var int iLast = 0
  305. var int iPrev = 0
  306. var float pLast = 0
  307. var isHighLast = false // otherwise the last pivot is a low pivot
  308.  
  309. pivots(src, length, isHigh) =>
  310.     l2 = length * 2
  311.     c2 = nz(src[length])
  312.     ok = true
  313.     for i = 0 to l2
  314.         if isHigh and src[i] > c2
  315.             ok := false
  316.  
  317.         if not isHigh and src[i] < c2
  318.             ok := false
  319.     if ok
  320.         [bar_index[length], c2]
  321.     else
  322.         [int(na), float(na)]
  323. [iH, pH] = pivots(high, depth / 2, true)
  324. [iL, pL] = pivots(low, depth / 2, false)
  325.  
  326. calc_dev(base_price, price) =>
  327.     100 * (price - base_price) / price
  328.  
  329. pivotFound(dev, isHigh, index, price) =>
  330.     if isHighLast == isHigh and not na(lineLast)
  331.         // same direction
  332.         if isHighLast ? price > pLast : price < pLast
  333.             line.set_xy2(lineLast, index, price)
  334.             [lineLast, isHighLast]
  335.         else
  336.             [line(na), bool(na)]
  337.     else // reverse the direction (or create the very first line)
  338.         if abs(dev) > dev_threshold
  339.             // price move is significant
  340.             id = line.new(iLast, pLast, index, price, color=na, width=1, style=line.style_dashed)
  341.             [id, isHigh]
  342.         else
  343.             [line(na), bool(na)]
  344.  
  345. if not na(iH)
  346.     dev = calc_dev(pLast, pH)
  347.     [id, isHigh] = pivotFound(dev, true, iH, pH)
  348.     if not na(id)
  349.         if id != lineLast
  350.             line.delete(lineLast)
  351.         lineLast := id
  352.         isHighLast := isHigh
  353.         iPrev := iLast
  354.         iLast := iH
  355.         pLast := pH
  356. else
  357.     if not na(iL)
  358.         dev = calc_dev(pLast, pL)
  359.         [id, isHigh] = pivotFound(dev, false, iL, pL)
  360.         if not na(id)
  361.             if id != lineLast
  362.                 line.delete(lineLast)
  363.             lineLast := id
  364.             isHighLast := isHigh
  365.             iPrev := iLast
  366.             iLast := iL
  367.             pLast := pL
  368.  
  369. _draw_line(price, col) =>
  370.     var id = line.new(iLast, price, bar_index, price, color=col, width=1, extend=extending)
  371.     if not na(lineLast)
  372.         line.set_xy1(id, line.get_x1(lineLast), price)
  373.         line.set_xy2(id, line.get_x2(lineLast), price)
  374.  
  375. _draw_label(price, txt, txtColor) =>
  376.     x = labelsPosition == "Left" ? line.get_x1(lineLast) : not extendRight ? line.get_x2(lineLast) : bar_index
  377.     labelStyle = labelsPosition == "Left" ? label.style_label_right : label.style_label_left
  378.     align = labelsPosition == "Left" ? text.align_right : text.align_left
  379.     labelsAlignStrLeft = txt + '\n ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏ \n'
  380.     labelsAlignStrRight = '       ' + txt + '\n ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏  ‏ \n'
  381.     labelsAlignStr = labelsPosition == "Left" ? labelsAlignStrLeft : labelsAlignStrRight
  382.     var id = label.new(x=x, y=price, text=labelsAlignStr, textcolor=txtColor, style=labelStyle, textalign=align, color=#00000000)
  383.     label.set_xy(id, x, price)
  384.     label.set_text(id, labelsAlignStr)
  385.     label.set_textcolor(id, txtColor)
  386.  
  387. _wrap(txt) =>
  388.     "(" + tostring(txt, "#.##") + ")"
  389.  
  390. _label_txt(level, price) =>
  391.     l = levelsFormat == "Values" ? tostring(level) + " " : tostring(level * 100) + "% "
  392.     (levels ? l : " ") + (prices ? _wrap(price) : " ")
  393.  
  394. _crossing_level(sr, r) =>
  395.     (r > sr and r < sr[1]) or (r < sr and r > sr[1])
  396.  
  397. startPrice = reverse ? line.get_y1(lineLast) : pLast
  398. endPrice = reverse ? pLast : line.get_y1(lineLast)
  399.  
  400. iHL = startPrice > endPrice
  401. diff = (iHL ? -1 : 1) * abs(startPrice - endPrice)
  402.  
  403. processLevel(show, value, colorL) => 
  404.     float m = value
  405.     r = startPrice + diff * m
  406.     if show
  407.         _draw_line(r, colorL)
  408.         _draw_label(r, _label_txt(m, r), colorL)
  409.  
  410. show_0 = true
  411. value_0 = 0
  412. color_0 = #787b86
  413. if afibOn
  414.     processLevel(show_0, value_0, color_0)
  415.  
  416. show_0_236 = true
  417. value_0_236 = 0.236
  418. color_0_236 = #f44336
  419. if afibOn
  420.     processLevel(show_0_236, value_0_236, color_0_236)
  421.  
  422. show_0_382 = true
  423. value_0_382 = 0.382
  424. color_0_382 = #81c784
  425. if afibOn
  426.     processLevel(show_0_382, value_0_382, color_0_382)
  427.  
  428. show_0_5 = true
  429. value_0_5 = 0.5
  430. color_0_5 = #4caf50
  431. if afibOn
  432.     processLevel(show_0_5, value_0_5, color_0_5)
  433.  
  434. show_0_618 = true
  435. value_0_618 = 0.618
  436. color_0_618 = #009688
  437. if afibOn
  438.     processLevel(show_0_618, value_0_618, color_0_618)
  439.  
  440. show_0_786 = true
  441. value_0_786 = 0.786
  442. color_0_786 = #64b5f6
  443. if afibOn
  444.     processLevel(show_0_786, value_0_786, color_0_786)
  445.  
  446. show_1 = true
  447. value_1 = 1
  448. color_1 = #787b86
  449. if afibOn
  450.     processLevel(show_1, value_1, color_1)
  451.  
  452. //Support / Resistance Lines
  453. h1000 = highest(1000)
  454. h750 = highest(750)
  455. h500 = highest(500)
  456. h250 = highest(250)
  457. h100 = highest(100)
  458. h50 = highest(50)
  459. h10 = highest(10)
  460. plot(srLines ? h1000 : na, title='R1', color = close > h1000 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  461. plot(srLines ? h750 : na, title='R2', color = close > h750 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  462. plot(srLines ? h500 : na, title='R3', color = close > h500 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  463. plot(srLines ? h250 : na, title='R4', color = close > h250 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  464. plot(srLines ? h100 : na, title='R5', color = close > h100 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  465. plot(srLines ? h50 : na, title='R6', color = close > h50 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  466. plot(srLines ? h10 : na, title='R6', color = close > h50 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  467.  
  468. l1000 = lowest(1000)
  469. l750 = lowest(750)
  470. l500 = lowest(500)
  471. l250 = lowest(250)
  472. l100 = lowest(100)
  473. l50 = lowest(50)
  474. l10 = lowest(10)
  475. plot(srLines ? l1000 : na, title='S1', color = close > l1000 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  476. plot(srLines ? l750 : na, title='S2', color = close > l750 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  477. plot(srLines ? l500 : na, title='S3', color = close > l500 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  478. plot(srLines ? l250 : na, title='S4', color = close > l250 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  479. plot(srLines ? l100 : na, title='S5', color = close > l100 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  480. plot(srLines ? l50 : na, title='S6', color = close > l50 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  481. plot(srLines ? l10 : na, title='S6', color = close > l50 ? color.green : color.red, linewidth=1, offset=-9999, trackprice=true)
  482.  
  483. //Defines Variables Used in Void Lines
  484. basis = sma(close, 20)
  485. twoDev = 2 * stdev(close, 20)
  486. upper3 = basis + twoDev
  487. lower3 = basis - twoDev
  488. threeDev = 3 * stdev(close, 20)
  489. upper4 = basis + threeDev
  490. lower4 = basis - threeDev
  491.  
  492. //Plots Void Lines
  493. plot(voidLines ? basis : na, "Basis", color.purple, editable=false)
  494. p5 = plot(voidLines ? upper3 : na, "Upper 200%", c, editable=false)
  495. p6 = plot(voidLines ? lower3 : na, "Lower 200%", c, editable=false)
  496. p7 = plot(voidLines ? upper4 : na, "Upper 300%", c, editable=false)
  497. p8 = plot(voidLines ? lower4 : na, "Lower 300%", c, editable=false)
  498. fill(p7, p5, color.teal, 75)
  499. fill(p8, p6, color.purple, 75)
  500.  
  501. //Defines Rules for Coloring Bars
  502. colorBars = close > basis ? color.teal : close < basis ? color.purple : na
  503.  
  504. //Defines EMA Variables
  505. ema8 = ema(close, 8)
  506. ema200 = ema(close, 200)
  507.  
  508. //Colors Bars
  509. barcolor(colorBar ? colorBars : na)
  510.  
  511. //Plots EMA Lines
  512. plot(emaLines ? ema8 : na, "EMA 8", color.white, 2)
  513. plot(emaLines ? ema200 : na, "EMA 200", color.green, 2)
  514.  
  515. //WaveTrend for Signals
  516. n1 = 14, n2 = 21, ap = hlc3, esa = ema(ap, n1), d = ema(abs(ap - esa), n1)
  517. ci = (ap - esa) / (0.015 * d), tci = ema(ci, n2), wt1 = tci, wt2 = sma(wt1,4)
  518.  
  519. // Defines Variables for Avoiding Duplicate Signals
  520. var sell = false
  521. var buy = false
  522.  
  523. // Defines Trade Signals>
  524. buySignal = not sell and crossover(wt1, wt2) and totalSentTxt == "Bullish" and percentVol >= 34 and rsiDash <= 66.66 and rsiDash >= 33.33
  525. sellSignal = not buy and crossunder(wt1, wt2)  and percentVol >= 50 and  totalSentTxt == "Bearish" and rsiDash >= 33.33 and percentVol < 55  or  not buy and crossunder(wt1, wt2)  and percentVol >= 55  and rsiDash >= 33.33
  526.  
  527. if buySignal
  528.     sell := true
  529.     buy := false
  530.  
  531. if sellSignal
  532.     sell := false
  533.     buy := true
  534.  
  535. // Plots Signals to Chart
  536. plotshape(bsSignals ? buySignal : na, title = "Buy Signal", location=location.belowbar, color=color.green, transp=0, style=shape.labelup, size=size.small, textcolor=color.white, text = "BUY")
  537. plotshape(bsSignals ? sellSignal : na, title = "Sell Signal", location=location.abovebar, color=color.red, transp=0, style=shape.labeldown, size=size.small, textcolor=color.white, text = "SELL")
  538.  
  539. // Alert Conditions
  540. alertcondition(buySignal, "Buy Signal", "Buy Signal")
  541. alertcondition(sellSignal, "Sell Signal", "Sell Signal")
  542.  
  543. //

Editor

You can edit this paste and save as new:


File Description
  • script
  • Paste Code
  • 12 May-2021
  • 18.98 Kb
You can Share it: