From c6dcb2677475fcd8fd7beba1ca9c58211fda65be Mon Sep 17 00:00:00 2001 From: x p k Date: Sun, 26 Jul 2020 13:33:27 +0800 Subject: [PATCH] NEW: initial commit --- tradingview/README.md | 4 ++++ tradingview/macd-rsi.txt | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tradingview/README.md create mode 100644 tradingview/macd-rsi.txt 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) +