Advertisement
TrendlineInvestor

N Period high/low breakout

Oct 4th, 2020 (edited)
2,032
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. strategy(title="N Period Highs and Low breakout" , shorttitle="N Period Highs and Low breakout", overlay=true)
  2.  
  3. //Variable definition
  4. periodhigh = input(title="Period High", type=integer, defval=2)
  5. periodlow = input(title="Period Low", type=integer, defval=2)
  6. Period = input(title="Other Period", type=resolution,defval="D")
  7. src = input(close, title="Source")
  8.  
  9. //Define N Period High and Low
  10. Period_High = security(tickerid, Period, highest(high,periodhigh)[1])
  11. Period_Low = security(tickerid, Period, lowest(low,periodlow)[1])
  12.  
  13. //Plot N Period High and N Period Low
  14. plot(isintraday ? Period_High : na, title="N day High",style=line, color=black,linewidth=2)
  15. plot(isintraday ? Period_Low : na, title="N day Low",style=line, color=black,linewidth=2)
  16.  
  17. //Long Entry condition
  18. longentry=src>Period_High
  19. strategy.entry("Long",strategy.long, when=longentry==true,stop=high)
  20.  
  21. //Short entry condition
  22. shortentry=src<Period_Low
  23. strategy.entry("Short",strategy.short, when=shortentry==true,stop=low)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement