diff --git a/tradingview/README.md b/tradingview/README.md new file mode 100644 index 0000000..f361a88 --- /dev/null +++ b/tradingview/README.md @@ -0,0 +1,4 @@ +# Strategy for use with tradingview.com + +## macd-rsi.txt +Buy when MACD crossover upwards. Sell when RSI exceeds 75. Simple strategy for use with stocks with a long-term uptrend. diff --git a/tradingview/macd-rsi.txt b/tradingview/macd-rsi.txt new file mode 100644 index 0000000..f4f8855 --- /dev/null +++ b/tradingview/macd-rsi.txt @@ -0,0 +1,31 @@ +//@version=2 +strategy("MACD-L RSI-S Strategy", overlay=true) + +// Buy when MACD crossover upwards +fastLength = input(12) +slowlength = input(26) +MACDLength = input(9) + +MACD = ema(close, fastLength) - ema(close, slowlength) +aMACD = ema(MACD, MACDLength) +delta = MACD - aMACD + +if (crossover(delta, 0)) + strategy.entry("MacdCU", strategy.long, comment="MacdCU") + +// Sell when RSI exceeds 75 +length = input( 14 ) +overSold = input( 30 ) +overBought = input( 75 ) +price = close + +vrsi = rsi(price, length) +co = crossover(vrsi, overSold) +cu = crossunder(vrsi, overBought) + +if (not na(vrsi)) + if (cu) + strategy.entry("Rsi75", strategy.short, comment="Rsi75") + // strategy.close_all(comment = "RsiSE") +//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr) +