NEW: added hammer-rsi.txt

This commit is contained in:
xpk 2020-07-26 15:32:54 +08:00
parent 6776eb1571
commit 49bff14789
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
2 changed files with 33 additions and 1 deletions

View File

@ -1,4 +1,8 @@
# Strategy for use with tradingview.com # Strategy for use with tradingview.com
## macd-rsi.txt ## 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.

View File

@ -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)