Skip to content

Instantly share code, notes, and snippets.

@StefanKrecher
Last active July 19, 2019 22:54
Show Gist options
  • Save StefanKrecher/5888c7d74a308ee8bf236db1409653cc to your computer and use it in GitHub Desktop.
Save StefanKrecher/5888c7d74a308ee8bf236db1409653cc to your computer and use it in GitHub Desktop.
//@version=2
study("RSI+MA", overlay=true)
// data series for RSI with length 14
rsi = rsi(close, 14)
// data series for Moving Average with length 9
ma = sma(close, 9)
// data series for buy signals:
//price should be below the moving average and RSI should be smaller than 40
buy_signals = close < ma and rsi < 30
// data series for sell signals:
//price should be above the moving average and RSI should be above 60
sell_signals = close > ma and rsi > 70
// draw some shapes on the chart if conditions are met
plotshape(buy_signals, style=shape.triangleup, text="up")
plotshape(sell_signals, style=shape.triangledown, text="down")
// create alert conditions so that alerts can be create via the add alerts dialog
alertcondition(buy_signals, title='Buy-Signal', message='price is below the MA and RSI is below 40')
alertcondition(sell_signals, title='Sell-Signal', message='price is above the MA and RSI is above 60')
@Hanhan1989
Copy link

Thanks so good !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment