Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- strategy("-=[Venom VI]=- Buy/Sell V2.4", overlay=true, pyramiding=0, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, currency=currency.USD)
- //From TO
- FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
- FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
- FromYear = input(defval = 2019, title = "From Year", minval = 2018)
- ToMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
- ToDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
- ToYear = input(defval = 9999, title = "To Year", minval = 2019)
- start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
- finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
- window() => time >= start and time <= finish ? true : false // create function "within window of time"
- // Williams
- WilliamR(len, chart) =>
- stockClose = security(tickerid, chart, close)
- stockLow = security(tickerid, chart, low)
- stockHigh = security(tickerid, chart, high)
- x = (highest(stockHigh,len )-stockClose[0])/(highest(stockHigh,len)-lowest(stockLow,len))*-100
- x
- m5w = WilliamR(14,'5')
- m15w = WilliamR(14,'15')
- m30w = WilliamR(14,'30')
- // SMA
- sma4= sma(security(tickerid, '60', close),4)
- sma8 = sma(security(tickerid, '60', close),8)
- sma18 = sma(security(tickerid, '60', close),18)
- sma200 = sma(security(tickerid, '60', close),200)
- smad = sma8 - sma18
- plot(smad)
- plot(sma8,color=red)
- plot(sma18,color=green)
- //RSI
- rsiIndicator = rsi(3,close)
- Wt = -80
- rsiThreshold = 15
- if rsiIndicator <= 15 and m15w < Wt and m30w < Wt //and sma4>sma30 and sma200[0]>sma200[1]
- strategy.entry("BUY BULL", strategy.long, when = window() )
- bought = strategy.position_size[0] > strategy.position_size[1]
- entry_price = valuewhen(bought, close, 0)
- if ( close > (entry_price * 1.05) and sma8 < sma8[1] and sma8[1] < sma8[2] or crossunder(sma8,sma18) and close > (entry_price * 1.012))
- strategy.entry("TP", strategy.short, when = window() )
- if (smad < -0.3 and open < (entry_price * 0.96) or open < (entry_price * 0.94))
- strategy.entry("SL", strategy.short, when = window() )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement