Advertisement
namile

Untitled

Apr 27th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © yereter
  3.  
  4. //@version=4
  5. strategy("My Strategy", overlay=false)
  6.  
  7. ///// Backtest Start Date /////
  8. startDate = input(title="Start Date", type=input.integer, defval=15, minval=1, maxval=31)
  9. startMonth = input(title="Start Month", type=input.integer, defval=3, minval=1, maxval=12)
  10. startYear = input(title="Start Year", type=input.integer, defval=2019, minval=1800, maxval=2100)
  11.  
  12. startDateEnd = input(title="Start Date", type=input.integer, defval=25, minval=1, maxval=31)
  13. startMonthEnd = input(title="Start Month", type=input.integer, defval=11, minval=1, maxval=12)
  14. startYearEnd = input(title="Start Year", type=input.integer, defval=2021, minval=1800, maxval=2100)
  15. afterStartDate = (time <= timestamp(syminfo.timezone, startYearEnd, startMonthEnd, startDateEnd, 0, 0) and time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0))
  16.  
  17.  
  18. len=input(3,title="length")
  19.  
  20. //DI+ and DI-
  21. upz = change(high)
  22. down = -change(low)
  23. trur = rma(tr, len)
  24. plus = fixnan(100 * rma(upz > down and upz > 0 ? upz : 0, len) / trur)
  25. minus = fixnan(100 * rma(down > upz and down > 0 ? down : 0, len) / trur)
  26. sum = plus + minus
  27. adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), len)
  28. di=plus-minus
  29. // o=plot(di,color=color.white,title="Diretion Index color",offset=0)
  30. df=di>=0? color.lime :color.red
  31. oo=0
  32. zs=100
  33. o=plot(oo,color=color.white,title="Diretion Index color",transp=100)
  34. wq=plot(zs,color=color.white,title="Diretion Index color",transp=100)
  35. fill(o,wq,color=df,transp=50)
  36. longCondition = crossover(di,0)
  37. // and atr(14)[1]<atr(14)[0]
  38. if (longCondition and afterStartDate)
  39. strategy.entry("My Long Entry Id", strategy.long)
  40.  
  41. shortCondition = crossunder(di,0)
  42. if (shortCondition and afterStartDate )
  43. // strategy.close_all()
  44. strategy.entry("My Short Entry Id", strategy.short)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement