资源加载中... loading...

倒锤策略(扩展选项)

Author: 雨幕(youquant), Date: 2022-06-14 11:06:26
Tags: EMA

策略回测

img

img

img


/*backtest
start: 2022-01-01 09:00:00
end: 2022-04-21 15:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["ContractType","rb888",360008]]
*/

//@version=5
indicator("Inverted Hammer", overlay=true)

downtrend_threshold = input.int(10, "下降趋势EMA阈值", minval=0, maxval=200, step=1, tooltip="Close must be below this EMA to be considered an inverted hammer in a downtrend")
upper_wick_min = input.float(2, "最小向上 X 主体", minval=2, maxval=20, step=1, tooltip="Upper wick must be this multiple of the body size or greater")
upper_wick_max = input.float(20, "最大向上 X 主体", minval=3, maxval=100, step=1, tooltip="Upper wick must be this multiple of the body size or less")
lower_wick_max = input.float(1, "最大向下 X 主体", minval=.25, maxval=10, step=.25, tooltip="Lower wick must be this multiple of the body size or less")
body_min = input.float(2, "K线的最小主体 %", minval=1, maxval=50, step=1, tooltip="Body must be at least this percent of the total candle range (high - low)")
up_only = input.bool(false, "仅在阳线", tooltip="The close must be higher than the previous close")
broke_high = input.bool(false, "突破先前高点", tooltip="The high must be higher than the previous high")

bodyGreen = close > open

body = math.abs(close - open)
upper_wick = high - math.max(open, close)
lower_wick = math.min(open, close) - low

upper_wick_qualify =
 (body * upper_wick_min <= upper_wick) and
 (body * upper_wick_max >= upper_wick) and
 (not broke_high or high > high[1])

lower_wick_qualify =
 (lower_wick <= body * lower_wick_max)

body_qualify =
 (bodyGreen or not up_only) and
 (body > (body_min / 100 * (high - low))) and
 (downtrend_threshold == 0 or close < ta.ema(close, downtrend_threshold))

invertedHammer = body_qualify and upper_wick_qualify and lower_wick_qualify ? low : na

plot( invertedHammer  , title="Inverted hammer", style=plot.style_circles, linewidth=12,color=color.yellow)
if invertedHammer
   strategy.entry("buy", strategy.long)




相关内容

更多内容