Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Il trading system completo - Trend-wide (Strategia Trend Following) - parte 1
- //@version=4
- strategy(title="Strategia trend-wide", overlay=true,
- pyramiding=0, initial_capital=10000,
- commission_type=strategy.commission.cash_per_order,
- commission_value=1, slippage=2,
- default_qty_type=strategy.percent_of_equity)
- maInputSlow = input(title="MA Slow", type=input.integer, defval=81, minval=0, maxval=500)
- maInputFast = input(title="MA Fast", type=input.integer, defval=15, minval=0, maxval=500)
- maMinDiff = input(title="Distanza min medie", type=input.float, defval=15)
- hourTrading = input(title="Sessione valida di trading", type=input.string, defval="24x7")
- onlyLong = input(title="Solo long trade", type=input.bool, defval=false)
- maSlow = ema(close, maInputSlow)
- maFast = ema(close, maInputFast)
- rangeTrading = time(timeframe.period, hourTrading)
- // condizione long cross over chiusura candela con valore media semplice veloce
- condEntryLong = close > maSlow and (maFast - maSlow) > maMinDiff and rangeTrading
- condExitLong = crossunder(maFast, maSlow)
- condEntryShort = crossunder(close, maSlow) and (maSlow - maFast) > maMinDiff and rangeTrading and not onlyLong
- condExitShort = crossover(close, maFast)
- strategy.entry("long", true, when = condEntryLong)
- strategy.close("long", when=condExitLong)
- strategy.entry("short", false, when = condEntryShort)
- strategy.close("short", when=condExitShort)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement