Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1. // Tradingview.com
  2. // @author LazyBear, xSilas, Ni6HTH4wK,
  3. // Drop a line if you use or modify this code.
  4. //modified by sco77m4r7in and oh92 -- updated and fixed multi exchange error, and added addtional caution dots.
  5. //study(title="Godmode3.2")
  6. //description: Godmode3.3.3.1 Red line in range of 9 to 0 flat or pointing up, Long on blue dot
  7. //@version=3
  8. strategy(title="Bull4Life XBT", default_qty_type=strategy.percent_of_equity, default_qty_value=1000, pyramiding=9, slippage=1, commission_type = strategy.commission.percent, commission_value = 0.075)
  9. n1 = input(33, "Channel Length")
  10. n2 = input(8, "Average Length")
  11. n3 = input(3, "Short length")
  12. n4 = input(133, "Percentage Line Interval")
  13. bottom_level = input(28, "Bottom Circle Level")
  14. top_level = input(81, "Top Circle Level")
  15. count_length = input(133, "Circle Count")
  16.  
  17. multi = input(type=bool, defval=false, title="Multi-exchange?")
  18. src0 = hlc3
  19.  
  20. src1 = security("BITFINEX:BTCUSD", period, src0), src2 = security("POLONIEX:BTCUSDT", period, src0),
  21. src3 = security("BITSTAMP:BTCUSD", period, src0), src4 = security("COINBASE:BTCUSD", period, src0),
  22. src5 = security("BITMEX:XBTUSD", period, src0), src10 = security("KRAKEN:XBTUSD", period, src0)
  23.  
  24. tci(src) => ema((src - ema(src, n1)) / (0.025 * ema(abs(src - ema(src, n1)), n1)), n2)+50
  25. mf(src) => rsi(sum(volume * (change(src) <= 0 ? 0 : src), n3), sum(volume * (change(src) >= 0 ? 0 : src), n3))
  26. willy(src) => 60 * (src - highest(src, n2)) / (highest(src, n2) - lowest(src, n2)) + 80
  27. csi(src) => avg(rsi(src, n3),tsi(src0,n1,n2)*50+50)
  28.  
  29. godmode(src) => avg(tci(src),csi(src),mf(src),willy(src))
  30. tradition(src) => avg(tci(src),mf(src),rsi(src, n3))
  31.  
  32. wt1 = multi?avg(godmode(src0),godmode(src1),godmode(src2),godmode(src3),godmode(src4),godmode(src5)):tradition(src0)
  33. wt2 = sma(wt1,6)
  34.  
  35. bottom = wt2<bottom_level ? wt2+5 : na
  36. top = wt2>top_level ? wt2-5 : na
  37.  
  38. reversal_top = (wt1[1] > wt1[2] and wt1 <= wt1[1] and wt1 > top_level) ? wt1 : na
  39. reversal_bottom = (wt1[1] < wt1[2] and wt1 >= wt1[1] and wt1 < bottom_level) ? wt1 : na
  40.  
  41. plot(wt1, color=green)
  42. plot(wt2, color=red)
  43. plot(ema((wt1-wt2)*2+50,n3), color=aqua, style=area, transp=80, histbase=50)
  44. plot(top, title="Caution!", color=red, style=circles, linewidth=3)
  45. plot(bottom, title="Caution!", color=green, style=circles, linewidth=3)
  46. plot(reversal_top, title="Caution!", color=black, style=circles, linewidth=4)
  47. plot(reversal_bottom, title="Caution!", color=blue, style=circles, linewidth=4)
  48.  
  49. blt = ema((wt1-wt2)*2+50,n3) - wt1
  50. bl = blt > 0 ? 1:0
  51. sumpos = 100 / n4 * sum(bl,n4)
  52. plot(sumpos, title="Black line", color=black, linewidth=4)
  53.  
  54.  
  55. blt2 = ema((wt1-wt2)*2+50,n3) - wt2
  56. bl2 = blt2 > 0 ? 1:0
  57. sumpos2 = 100 / n4 * sum(bl2,n4)
  58. plot(sumpos2, color=blue, linewidth=1)
  59.  
  60. blt3 = wt1 - wt2
  61. bl3 = blt3 > 0 ? 1:0
  62. sumpos3 = 100 / n4 * sum(bl3,n4)
  63. plot(sumpos3, title="Orange line", color=orange, linewidth=4)
  64.  
  65.  
  66.  
  67. bottom2 = na(bottom) ? 0 : 1
  68. top2 = na(top) ? 0 : 1
  69.  
  70. count_bottom = sum(bottom2, count_length)
  71. count_top = sum(top2, count_length)
  72.  
  73. plot(count_bottom, color=green, linewidth=4)
  74. plot(count_top, color=red, linewidth=4)
  75.  
  76. hline(top_level)
  77. hline(bottom_level)
  78.  
  79. //orignal settings 9,26,13
  80.  
  81.  
  82. // === STRATEGY RELATED INPUTS ===
  83. tradeInvert = input(defval = false, title = "Invert Trade Direction?")
  84. setDifference = input(defval = 0, title = "Black/orange Difference Value", minval = 0)
  85. setBlackLineShortThreshold = input(defval = 70, title = "Black Line Short Threshold <=", minval = 0)
  86. setRedLineLongThreshold = input(defval = 9, title = "Red Line Long Threshold <=", minval = 0)
  87. // the risk management inputs
  88. inpTakeProfit = input(defval = 2000, title = "Take Profit", minval = 0)
  89. inpStopLoss = input(defval = 0, title = "Stop Loss", minval = 0)
  90. inpTrailStop = input(defval = 0, title = "Trailing Stop Loss", minval = 0)
  91. inpTrailOffset = input(defval = 0, title = "Trailing Stop Loss Offset", minval = 0)
  92.  
  93. // === RISK MANAGEMENT VALUE PREP ===
  94. // if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
  95. useTakeProfit = inpTakeProfit >= 1 ? inpTakeProfit : na
  96. useStopLoss = inpStopLoss >= 1 ? inpStopLoss : na
  97. useTrailStop = inpTrailStop >= 1 ? inpTrailStop : na
  98. useTrailOffset = inpTrailOffset >= 1 ? inpTrailOffset : na
  99.  
  100. timeFilter = (year >= 2012) and (month > 0) and (dayofmonth > 0 and dayofmonth < 32)
  101.  
  102. buy = timeFilter and (reversal_bottom != 0) and count_top <= setRedLineLongThreshold// and rising(wt1, 2) //and not rising(sumpos, 2)
  103. plot(buy? 1: 0, title="BUY", color=green, style=circles, linewidth=3)
  104. if buy == 1 and timeFilter
  105. strategy.close("Short")
  106. strategy.entry("Long", strategy.long)
  107. sell = timeFilter and (reversal_top != 0) and sumpos >= setBlackLineShortThreshold and falling(sumpos, 2)// and falling (wt1, 2) //and not falling(sumpos, 2)
  108. plot(sell? 1: 0, title="SELL", color=red, style=circles, linewidth=3)
  109. strategy.exit("Exit Long", from_entry = "Long", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
  110. strategy.exit("Exit Short", from_entry = "Short", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
  111. if reversal_bottom != 0// or sumpos < sumpos3
  112. strategy.close("Short")
  113. if reversal_top != 0// or sumpos > sumpos3
  114. strategy.close("Long")
  115. //if sell == 1 and timeFilter
  116. // strategy.close("Long")
  117. // strategy.entry("Short", strategy.short)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement