Advertisement
danucante

Untitled

Nov 15th, 2023
215
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.09 KB | None | 1 0
  1.  
  2.  
  3. //@version=5
  4. strategy("THE MATRIX KILLER2", overlay=true, pyramiding = 0, slippage = 1, initial_capital = 100, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
  5.  
  6. // Plot Cobra Metrics Table
  7. import EliCobra/CobraMetrics/4 as cobra
  8.  
  9.  
  10. disp_ind = input.string ("Equity" , title = "Display Curve" , tooltip = "Choose which data you would like to display", options=["Strategy", "Equity", "Open Profit", "Gross Profit", "Net Profit", "None"], group = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  11. pos_table = input.string("Bottom Right", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  12. type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  13.  
  14. plot(cobra.curve(disp_ind))
  15. cobra.cobraTable(type_table, pos_table)
  16.  
  17. // Time Range
  18. startTime = input.time(defval = timestamp("01 January 2018"), title = "Start Date")
  19. isInTimeRange = time >= startTime
  20.  
  21.  
  22.  
  23. // rsi
  24. rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
  25. rsiSourceInput = input.source(close, group="RSI Settings")
  26. uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
  27. downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
  28. rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
  29.  
  30. rsi2 = ta.rsi(close, 21)
  31.  
  32. RSI_long = rsi2 > 50
  33. RSI_short = rsi2 < 50
  34. // RSI_long = ta.crossover(rsi2, 50)
  35. // RSI_short = ta.crossunder(rsi2, 50)
  36.  
  37.  
  38. // ***************************************************************************************************************************************************************
  39.  
  40. // VR
  41. volatilityLower = input.float(title = "Lower Range", defval= -39, group = "VRG")
  42. volatilityHigher = input.float(title = "Higher Range", defval= 9)
  43. volatilityLength = 58
  44. volatilityRange = ta.sma(close - open, volatilityLength)
  45.  
  46. //VR PARAMETERS
  47. VRL = volatilityRange > volatilityLower
  48. VRS = volatilityRange < volatilityHigher
  49.  
  50.  
  51. // Inputs
  52. timeframeAlgo=input.timeframe(defval ='1D', group = "Algo", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  53. sensitivity = input.float(2.5, "โ€ƒโ€ƒSensitivity (0.5 - 10)", 0.5, 10, step=0.1, group = "Algo")
  54. emaEnergy = input.bool(true, "EMA Energy", group = "Algo")
  55. keltner_length = input(10, "Keltner Channel Length", group = "Algo")
  56. atrPeriod = input(10, "ATR Length", group = "Algo")
  57. factor = input.float(3.5, "Factor", step = 0.01, group = "Algo")
  58.  
  59. // =request.security(syminfo.tickerid,timeframe, high)
  60.  
  61. // Keltner Channel function
  62. keltner_channel(src, length) =>
  63. ma = request.security(syminfo.tickerid,timeframeAlgo,ta.sma(src, length))
  64. rangec = request.security(syminfo.tickerid,timeframeAlgo, high) - request.security(syminfo.tickerid,timeframeAlgo, low)
  65. upper = ma + rangec
  66. lower = ma - rangec
  67. [upper, lower]
  68.  
  69. // Modified Supertrend function using Keltner Channel
  70. supertrend(_src, factor, atrLen, kel_length) =>
  71. [upperKeltner, lowerKeltner] = keltner_channel(_src, kel_length)
  72. rangec = upperKeltner - lowerKeltner
  73. upperBand = _src + factor * rangec
  74. lowerBand = _src - factor * rangec
  75. prevLowerBand = nz(lowerBand[1])
  76. prevUpperBand = nz(upperBand[1])
  77. lowerBand := lowerBand > prevLowerBand or request.security(syminfo.tickerid,timeframeAlgo,close[1]) < prevLowerBand ? lowerBand : prevLowerBand
  78. upperBand := upperBand < prevUpperBand or request.security(syminfo.tickerid,timeframeAlgo,close[1]) > prevUpperBand ? upperBand : prevUpperBand
  79. int direction = na
  80. float superTrend = na
  81. prevSuperTrend = superTrend[1]
  82.  
  83. if na(rangec[1])
  84. direction := 1
  85. else if prevSuperTrend == prevUpperBand
  86. direction := close > upperBand ? -1 : 1
  87. else
  88. direction := close < lowerBand ? 1 : -1
  89. superTrend := direction == -1 ? lowerBand : upperBand
  90. [superTrend, direction]
  91. // Get Components
  92. ema1 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 9))
  93. ema2 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 12))
  94. ema3 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 15))
  95. ema4 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 18))
  96. ema5 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 21))
  97. ema6 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 24))
  98. ema7 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 27))
  99. ema8 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 30))
  100. ema9 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 33))
  101. ema10 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 36))
  102. ema11 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 39))
  103. ema12 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 42))
  104. ema13 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 45))
  105. ema14 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 48))
  106. ema15 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 51))
  107. // Colors
  108. green = #2BBC4D, red = #C51D0B
  109. emaEnergyColor(ma) => emaEnergy ? (close >= ma ? green : red) : na
  110. // Plots
  111. plot(ema1, "", emaEnergyColor(ema1), editable=false)
  112. plot(ema2, "", emaEnergyColor(ema2), editable=false)
  113. plot(ema3, "", emaEnergyColor(ema3), editable=false)
  114. plot(ema4, "", emaEnergyColor(ema4), editable=false)
  115. plot(ema5, "", emaEnergyColor(ema5), editable=false)
  116. plot(ema6, "", emaEnergyColor(ema6), editable=false)
  117. plot(ema7, "", emaEnergyColor(ema7), editable=false)
  118. plot(ema8, "", emaEnergyColor(ema8), editable=false)
  119. plot(ema9, "", emaEnergyColor(ema9), editable=false)
  120. plot(ema10, "", emaEnergyColor(ema10), editable=false)
  121. plot(ema11, "", emaEnergyColor(ema11), editable=false)
  122. plot(ema12, "", emaEnergyColor(ema12), editable=false)
  123. plot(ema13, "", emaEnergyColor(ema13), editable=false)
  124. plot(ema14, "", emaEnergyColor(ema14), editable=false)
  125. plot(ema15, "", emaEnergyColor(ema15), editable=false)
  126. [supertrend, direction] = request.security(syminfo.tickerid,timeframeAlgo,supertrend(close, sensitivity, 11, keltner_length))
  127. bull = request.security(syminfo.tickerid,timeframeAlgo,ta.crossover(close, supertrend))
  128. bear = request.security(syminfo.tickerid,timeframeAlgo,ta.crossunder(close, supertrend))
  129. y1 = request.security(syminfo.tickerid,timeframeAlgo,low) - (ta.atr(30) * 2)
  130. y2 = request.security(syminfo.tickerid,timeframeAlgo,high) + (ta.atr(30) * 2)
  131. buy = bull ? label.new(bar_index, y1, "BUY", xloc.bar_index, yloc.price, green, label.style_label_up, color.white, size.normal) : na
  132. sell = bear ? label.new(bar_index, y2, "SELL", xloc.bar_index, yloc.price, red, label.style_label_down, color.white, size.normal) : na
  133. [supertrends, directions] = ta.supertrend(factor, atrPeriod)
  134. bodyMiddle = plot((open + close) / 2, display=display.none)
  135. // Trend Catcher Indicator (Example)
  136. ema100 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(close, 10))
  137. ema200 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(close, 20))
  138. trendCatcher = request.security(syminfo.tickerid,timeframeAlgo,ta.crossover(ema100, ema200)) ? 1 : request.security(syminfo.tickerid,timeframeAlgo,ta.crossunder(ema100, ema200)) ? -1 : 0
  139. trendColor = trendCatcher == 1 ? color.rgb(90, 23, 102) : na
  140. barcolor(trendColor)
  141. // Colored candles
  142. barcolor(color = close > supertrends ? color.rgb(102, 255, 0) : color.rgb(255, 0, 0))
  143. //alertcondition(bull, title="Buy", message="Buy!")
  144. //alertcondition(bear, title="Sell", message="Sell!")
  145.  
  146.  
  147. /////////
  148. longCondition = bull and VRL and RSI_long
  149. //stc ,vrl
  150. //stc , vrs
  151. shortCondition = bear and VRS and RSI_short
  152.  
  153. if barstate.isconfirmed and isInTimeRange and longCondition
  154. strategy.entry("Long", strategy.long)
  155.  
  156.  
  157. if barstate.isconfirmed and isInTimeRange and shortCondition
  158. strategy.entry("Short", strategy.short)
  159.  
  160.  
  161.  
  162.  
Advertisement
Comments
  • # text 0.12 KB | 0 0
    1. download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement