namile

Untitled

Apr 27th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 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(10,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.black,title="Diretion Index color",offset=0)
  30. longCondition = crossover(di,0)
  31. // and atr(14)[1]<atr(14)[0]
  32. if (longCondition and afterStartDate)
  33. strategy.entry("My Long Entry Id", strategy.long)
  34.  
  35. shortCondition = crossunder(di,0)
  36. if (shortCondition and afterStartDate )
  37. // strategy.close_all()
  38. strategy.entry("My Short Entry Id", strategy.short)
Advertisement
Add Comment
Please, Sign In to add comment