Advertisement
Maurizio-Ciullo

Bot 1.2 Il trading system completo - Trend-wide (Strategia Trend Following) - parte 2

Jul 10th, 2021 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Il trading system completo - Trend-wide (Strategia Trend Following) - parte 2 Study Per Allert
  2. //@version=4
  3. study(title="BOT trend-wide", overlay=true)
  4.  
  5.  
  6. maInputSlow = input(title="MA Slow", type=input.integer, defval=81, minval=0, maxval=500)
  7. maInputFast = input(title="MA Fast", type=input.integer, defval=15, minval=0, maxval=500)
  8. maMinDiff = input(title="Distanza min medie", type=input.float, defval=15)
  9. hourTrading = input(title="Sessione valida di trading", type=input.string, defval="24x7")
  10. onlyLong = input(title="Solo long trade", type=input.bool, defval=false)
  11.  
  12. maSlow = ema(close, maInputSlow)
  13. maFast = ema(close, maInputFast)
  14. rangeTrading = time(timeframe.period, hourTrading)
  15.  
  16. // condizione long cross over chiusura candela con valore media semplice veloce
  17. condEntryLong = close > maSlow and maFast - maSlow > maMinDiff and rangeTrading
  18. condExitLong = crossunder(maFast, maSlow)
  19.  
  20. condEntryShort = crossunder(close, maSlow) and (maSlow - maFast) > maMinDiff and rangeTrading and not onlyLong
  21. condExitShort = crossover(close, maFast)
  22.  
  23. alertcondition(condEntryLong, "Apertura operazione Long {{ticker}}", "Aprire posizione long su {{ticker}} al prezzo {{close}}" )
  24. alertcondition(condExitLong, "Chiudere operazione Long {{ticker}}", "Chiudere posizione long su {{ticker}} al prezzo {{close}}" )
  25. alertcondition(condEntryShort, "Apertura operazione Short {{ticker}}", "Aprire posizione short su {{ticker}} al prezzo {{close}}" )
  26. alertcondition(condExitShort, "Chiudere operazione Short {{ticker}}", "Chiudere posizione short su {{ticker}} al prezzo {{close}}" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement