此脚本:将Heikin Ashi线添加到图表中(基于EMA)。当颜色从绿色变为红色或从红色变为绿色时,提供触发的警报。
只需将指标添加到图表中,创建警报并从下拉列表中选择“Heikin Ashi Trend alert”利润。
回测测试
/*backtest start: 2021-12-01 00:00:00 end: 2022-06-01 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}] args: [["v_input_int_1",26],["ContractType","hc2210",360008]] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © backslash-f // // This script: // - Adds a Heikin-Ashi line to the chart (EMA-based). // - Provides alerts triggered when the color goes from green to red and vice versa. //@version=5 indicator("Heikin-Ashi Trend Alert", overlay=true) // EMA ema_input = input.int(title="EMA周期", defval=26, minval=1) ema_smoothing = input.int(title="EMA平滑", defval=8, minval=1) ema_open = ta.ema(open, ema_input) ema_close = ta.ema(close, ema_input) // Developer shouldShowDebugInfo = input(title="显示debug信息", group="DEVELOPER", defval=false, tooltip="Check this box to see the values of the main variables on the chart, below bars. This is for debugging purposes only.") // Heikin-Ashi heikinashi = ticker.heikinashi(syminfo.tickerid) heikinashi_open = request.security(heikinashi, timeframe.period, ema_open) heikinashi_close = request.security(heikinashi, timeframe.period, ema_close) heikinashi_open_smooth = ta.ema(heikinashi_open, ema_smoothing) heikinashi_close_smooth = ta.ema(heikinashi_close, ema_smoothing) // Trend var trend = false var last_trend = trend trend := heikinashi_close_smooth >= heikinashi_open_smooth if trend strategy.entry("Enter Long", strategy.long) else strategy.entry("Enter Short", strategy.short)template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6