Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1.  
  2. //@version=3
  3. strategy("VCI_MTF", overlay=true, shorttitle="VCI_Multi_TimeFrame_OB_OS Strategy", default_qty_type = strategy.percent_of_equity, default_qty_value = 100, initial_capital = 10000, slippage = 5)
  4. ema1 = input(75, title="fast EMA period", minval=1)
  5. ema2 = input(7, title="slow EMA period", minval=2)
  6. atrp = input(3, title="ATR period", minval=1)
  7. src = input(close, type=source, title="Source")
  8. // Base=input(title="Larger Res than Chart", defval = "D", type=resolution)
  9. otf_period = input(defval=9, title="Look Back Period (2nd Timeframe)", type=integer)
  10. otf = input(defval="30", title="Second Momentum Timeframe", type=resolution)
  11.  
  12. vci = (ema(src,ema1)-ema(src,ema2))/atr(atrp)
  13. vciColor = vci>0? lime:red
  14.  
  15. lvl = stdev(vci,atrp)
  16.  
  17. // Function to dectect a new bar
  18. is_newbar(res) =>
  19. t = time(res)
  20. change(t) != 0 ? true : false
  21.  
  22. // Check how many bars are in our upper timeframe
  23. since_new_bar = barssince(is_newbar(otf))
  24. otf_total_bars = na
  25. otf_total_bars := since_new_bar == 0 ? since_new_bar[1] : otf_total_bars[1]
  26.  
  27.  
  28.  
  29. breakline=input(title="Breaks in lines", defval = true, type=bool)
  30. so = security(tickerid, otf, rsi(open, otf_period))
  31. sh = security(tickerid, otf, rsi(high, otf_period))
  32. sl = security(tickerid, otf, rsi(low, otf_period))
  33. sc = security(tickerid, otf, rsi(close, otf_period))
  34. // br= so != so[1] and sc != sc[1] and sh != sh[1] and sl != sl[1] and breakline == true ? 1 : na
  35. // col= so > sc ? red : green
  36. // a1=na(br) ? so : na
  37. // a2=na(br) ? sh : na
  38. // a3=na(br) ? sl : na
  39. // a4=na(br) ? sc : na
  40.  
  41. final_otf_so = na
  42. final_otf_so := barstate.isrealtime ? since_new_bar == otf_total_bars ? so : final_otf_so[1] : so
  43.  
  44. final_otf_sc = na
  45. final_otf_sc := barstate.isrealtime ? since_new_bar == otf_total_bars ? sc : final_otf_sc[1] : sc
  46.  
  47.  
  48. overbough = input(title="Close Overbought", defval=71, step=1)
  49. oversold = input(title="Close Oversold", defval=37, step=1)
  50.  
  51. overbought_vci = input(title="VCI Overbought", defval=2, step=0.1)
  52. oversold_vci = input(title="VCI Oversold", defval=-2, step=0.1)
  53.  
  54. if (final_otf_sc < oversold) and (vci> overbought_vci )
  55. strategy.entry("LONG", strategy.long, stop=close, oca_name="TREND", oca_type=strategy.oca.cancel, comment="LONG")
  56.  
  57.  
  58. if (final_otf_sc > overbough) and ( vci < oversold_vci)
  59. strategy.close("LONG")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement