From 49bff1478993839c97c0cf5b6656195540b31bce Mon Sep 17 00:00:00 2001 From: x p k Date: Sun, 26 Jul 2020 15:32:54 +0800 Subject: [PATCH] NEW: added hammer-rsi.txt --- tradingview/README.md | 6 +++++- tradingview/hammer-rsi.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tradingview/hammer-rsi.txt diff --git a/tradingview/README.md b/tradingview/README.md index a55d06f..fa9bf2b 100644 --- a/tradingview/README.md +++ b/tradingview/README.md @@ -1,4 +1,8 @@ # Strategy for use with tradingview.com ## macd-rsi.txt -Long when MACD crossover upwards. Short when RSI exceeds 75. Simple strategy for use with stocks with a long-term uptrend. I'm still working on the code to not short but only close a portion of previous positions. Can't get strategy.close or strategy.close_all to work. +Long when MACD crossover upwards. close all when RSI exceeds 75. Simple strategy for use with stocks with a long-term uptrend. + +## hammer-rsi.txt +Long when hammer is observed, close all when RSI exceeds 75. Simple strategy for use with stocks with a long-term uptrend. + diff --git a/tradingview/hammer-rsi.txt b/tradingview/hammer-rsi.txt new file mode 100644 index 0000000..8e34e3f --- /dev/null +++ b/tradingview/hammer-rsi.txt @@ -0,0 +1,28 @@ +//@version=4 +strategy("Hammer-L RSI-S Strategy", overlay=true, initial_capital=12000, default_qty_type=strategy.cash, default_qty_value=4000) + +// Buy when hammer is observed in a downtrend +//Bullish Hammer Up +bhu1 = close - open > 0 and (close - open) / 3 > high - close and + (open - low) / 2 > close - open and close - open > (open - low) / 8 +if bhu1 == true + strategy.entry("HammerLE", strategy.long, comment="HammerLE") + +// 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.close_all(when=open < close) + // strategy.exit(id = "MacdCU", qty_percent = 80, comment = "RsiC80") + // strategy.entry("Rsi75", strategy.short, comment="Rsi75") + +//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr) +