Advertisement
Guest User

Untitled

a guest
Jul 29th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 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.  
  3. //@version=4
  4. strategy("sma cross", overlay=true)
  5. sma_length = input(200, "SMA Time Horizon")
  6. use_fract = input(false, "Use Fraction Strategy")
  7. fract = input(0.02, "Fraction to Close")
  8.  
  9. longCondition = use_fract? close < sma(close, sma_length) * (1.0 - fract) : crossover(close, sma(close, sma_length))
  10. if (longCondition)
  11. strategy.entry("buy", strategy.long)
  12.  
  13. shortCondition = use_fract? close > sma(close, sma_length) * (1.0 + fract) : crossunder(close, sma(close, sma_length))
  14. if (shortCondition)
  15. strategy.exit("buy")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement