Advertisement
Guest User

Untitled

a guest
May 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. //@version=3
  2. strategy("-=[Venom VI]=- Buy/Sell V2.4", overlay=true, pyramiding=0, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, currency=currency.USD)
  3.  
  4. //From TO
  5. FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
  6. FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
  7. FromYear = input(defval = 2019, title = "From Year", minval = 2018)
  8. ToMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
  9. ToDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
  10. ToYear = input(defval = 9999, title = "To Year", minval = 2019)
  11.  
  12. start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
  13. finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
  14. window() => time >= start and time <= finish ? true : false // create function "within window of time"
  15.  
  16. // Williams
  17.  
  18. WilliamR(len, chart) =>
  19. stockClose = security(tickerid, chart, close)
  20. stockLow = security(tickerid, chart, low)
  21. stockHigh = security(tickerid, chart, high)
  22.  
  23.  
  24. x = (highest(stockHigh,len )-stockClose[0])/(highest(stockHigh,len)-lowest(stockLow,len))*-100
  25. x
  26.  
  27. m5w = WilliamR(14,'5')
  28. m15w = WilliamR(14,'15')
  29. m30w = WilliamR(14,'30')
  30.  
  31. // SMA
  32. sma4= sma(security(tickerid, '60', close),4)
  33. sma8 = sma(security(tickerid, '60', close),8)
  34. sma18 = sma(security(tickerid, '60', close),18)
  35. sma200 = sma(security(tickerid, '60', close),200)
  36. smad = sma8 - sma18
  37. plot(smad)
  38. plot(sma8,color=red)
  39. plot(sma18,color=green)
  40.  
  41. //RSI
  42.  
  43. rsiIndicator = rsi(3,close)
  44.  
  45.  
  46. Wt = -80
  47. rsiThreshold = 15
  48.  
  49. if rsiIndicator <= 15 and m15w < Wt and m30w < Wt //and sma4>sma30 and sma200[0]>sma200[1]
  50. strategy.entry("BUY BULL", strategy.long, when = window() )
  51.  
  52. bought = strategy.position_size[0] > strategy.position_size[1]
  53. entry_price = valuewhen(bought, close, 0)
  54.  
  55.  
  56. if ( close > (entry_price * 1.05) and sma8 < sma8[1] and sma8[1] < sma8[2] or crossunder(sma8,sma18) and close > (entry_price * 1.012))
  57. strategy.entry("TP", strategy.short, when = window() )
  58. if (smad < -0.3 and open < (entry_price * 0.96) or open < (entry_price * 0.94))
  59. strategy.entry("SL", strategy.short, when = window() )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement