Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. //@version=4
  2. strategy(title="Ichimoku Cross Strategy", overlay=true, max_bars_back=10, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=75, initial_capital=1000, currency="EUR", commission_type=strategy.commission.percent, commission_value=0.075)
  3.  
  4. //setting baktesting period
  5. testPeriodStart = timestamp(2017,12,15,0,0)
  6. testPeriodStop = timestamp(2019,8,24,0,0)
  7.  
  8. //Ichimoku indicator
  9. conversionPeriods = input(20, minval=1, title="Conversion Line Periods"),
  10. basePeriods = input(60, minval=1, title="Base Line Periods")
  11. laggingSpan2Periods = input(120, minval=1, title="Lagging Span 2 Periods"),
  12. displacement = input(30, minval=1, title="Displacement")
  13.  
  14. donchian(len) => avg(lowest(len), highest(len))
  15.  
  16. conversionLine = donchian(conversionPeriods)
  17. baseLine = donchian(basePeriods)
  18.  
  19. //Long/Short triggers
  20. longTrigger = crossover(conversionLine, baseLine)
  21. shortTrigger = crossunder(conversionLine, baseLine)
  22.  
  23. //strategy
  24. //if time >= testPeriodStart
  25. fromYear = year > 2017
  26. toYear = year < 2020
  27.  
  28. //if longTrigger == true
  29. //strategy.exit("exitShort", "Short")
  30. strategy.entry("Long", strategy.long, when = longTrigger and fromYear)
  31. strategy.close_all(when = shortTrigger and fromYear)
  32.  
  33. strategy.entry("Short", strategy.short, when = shortTrigger and fromYear)
  34. strategy.close_all(when = longTrigger and fromYear)
  35.  
  36. //if shortTrigger == true
  37. //strategy.close_all(when = crossunder(conversionLine, baseLine))
  38. //strategy.entry("Short", strategy.short)
  39.  
  40. //strategy.exit("Long", when = overbought)
  41. //strategy.exit("Short", when = oversold)
  42.  
  43. plotshape(shortTrigger, style=shape.triangledown, color=color.red, size=size.large)
  44. plotshape(longTrigger, style=shape.triangleup, color=color.green, size=size.large)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement