UPD: updated hamer algo

This commit is contained in:
xpk 2020-07-26 16:43:19 +08:00
parent 49bff14789
commit 80ca61e59c
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
1 changed files with 24 additions and 15 deletions

View File

@ -1,28 +1,37 @@
//@version=4
strategy("Hammer-L RSI-S Strategy", overlay=true, initial_capital=12000, default_qty_type=strategy.cash, default_qty_value=4000)
//@version=3
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")
// Detect downtrend
is_DownTrend = false
// sma100 = sma(close, 100)
sma50 = sma(close, 50)
// is_DownTrend := close < sma50 and sma50 < sma100
is_DownTrend := close < sma50
// Detect hammer
len_upShadow = high - max(open,close)
len_downShadow = min(open,close) - low
len_body = abs(open - close)
if is_DownTrend and len_downShadow > 0
if len_upShadow < len_downShadow / 5 and len_body < len_downShadow / 3
strategy.entry("HammerL", strategy.long, comment="HammerL")
// Sell when RSI exceeds 75
length = input(14)
overSold = input(30)
overBought = input(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)
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)