RicardoSantos

[RS]Khizon (DWTI) Strategy V0

EXPERIMENTAL:
preliminary version
note: signals from the Daily timeframe may repaint.
Script open-source

Dans le véritable esprit de TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par le règlement. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?
//@version=2
strategy(title='[RS]Khizon (DWTI) Strategy V0', shorttitle='K', overlay=false, pyramiding=0, initial_capital=100000, currency=currency.USD)
trade_size = 10000
//  ||  Inputs:
macd_src = input(title='MACD Source:', type=source, defval=close)
macd_fast = input(title='MACD Fast Length:', type=integer, defval=12)
macd_slow = input(title='MACD Slow Length:', type=integer, defval=26)
macd_signal_smooth = input(title='MACD Signal Smoothing:', type=integer, defval=9)
srsi_src = input(title='SRSI Source:', type=source, defval=close)
srsi_rsi_length = input(title='SRSI RSI Length:', type=integer, defval=14)
srsi_stoch_length = input(title='SRSI Stoch Length:', type=integer, defval=14)
srsi_smooth = input(title='SRSI Smoothing:', type=integer, defval=14)
srsi_signal_smooth = input(title='SRSI Signal Smoothing:', type=integer, defval=14)
//  ||  MACD(close, 12, 26, 9):     ||---------------------------------------------||
f_macd_trigger(_src, _fast, _slow, _signal_smooth)=>
    _macd = ema(_src, _fast) - ema(_src, _slow)
    _signal = sma(_macd, _signal_smooth)
    _return_trigger = _macd >= _signal ? true : false
//  ||  Stoch RSI(close, 14, 14, 3, 3)  ||-----------------------------------------||
f_srsi_trigger(_src, _rsi_length, _stoch_length, _smooth, _signal_smooth)=>
    _rsi = rsi(_src, _rsi_length)
    _stoch = sma(stoch(_rsi, _rsi, _rsi, _stoch_length), _smooth)
    _signal = sma(_stoch, _signal_smooth)
    _return_trigger = _stoch >= _signal ? true : false
//  ||-----------------------------------------------------------------------------||
//  ||-----------------------------------------------------------------------------||
//  ||  Check Directional Bias from daily timeframe:
daily_trigger = security('USOIL', 'D', f_macd_trigger(macd_src, macd_fast, macd_slow, macd_signal_smooth) and f_srsi_trigger(srsi_src, srsi_rsi_length, srsi_stoch_length, srsi_smooth, srsi_signal_smooth))
h4_trigger = security('USOIL', '240', f_macd_trigger(macd_src, macd_fast, macd_slow, macd_signal_smooth) and f_srsi_trigger(srsi_src, srsi_rsi_length, srsi_stoch_length, srsi_smooth, srsi_signal_smooth))

plot(0, style=circles, color=daily_trigger?blue:na, linewidth=4, transp=65)
plot(0, style=circles, color=h4_trigger?navy:na, linewidth=2, transp=0)

sel_open = daily_trigger and h4_trigger
buy_open = not daily_trigger and not h4_trigger

strategy.entry('sel', long=false, qty=trade_size, comment='sel', when=sel_open)
strategy.entry('buy', long=true, qty=trade_size, comment='buy', when=buy_open)