我正在结合“UT Bot Alerts”指标和“STC 指标 - 更好的 MACD [SHK]”指标制定以下策略
//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)
// Inputs
a = input(1, title = "Key Vaule. 'This changes the sensitivity'")
c = input(10, title = "ATR Period")
h = input(false, title = "Signals from Heikin Ashi Candles")
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
pos = 0
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
ema = ta.ema(src,1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
EEEEEE = input(12, 'Length')
BBBB = input(26, 'stLength')
BBBBB = input(50, 'SlowLength')
AAAA(BBB, BBBB, BBBBB) =>
fastMA = ta.ema(BBB, BBBB)
slowMA = ta.ema(BBB, BBBBB)
AAAA = fastMA - slowMA
AAAA
AAAAA(EEEEEE, BBBB, BBBBB) =>
AAA = input(0.5)
var CCCCC = 0.0
var DDD = 0.0
var DDDDDD = 0.0
var EEEEE = 0.0
BBBBBB = AAAA(close, BBBB, BBBBB)
CCC = ta.lowest(BBBBBB, EEEEEE)
CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
DDDD = ta.lowest(DDD, EEEEEE)
DDDDD = ta.highest(DDD, EEEEEE) - DDDD
DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
EEEEE
mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
if (buy and mColor == color.green and mAAAAA < 25)
strategy.entry("Long", strategy.long)
if (sell and mColor == color.red and mAAAAA > 75)
strategy.entry("Short", strategy.short)
UT Bot Alerts
位于 pinescriptv4
中,但我已使用文档和我收到的错误将其转换为 v5
。
我已经解决了所有错误,但出于某种原因,每当我尝试将策略添加到图表中时,我都会收到以下消息: 交易视图中的信息消息
User cancelled operation
我已经查看了文档中的所有地方。在文档的错误部分,甚至没有提到“取消”和“操作”。
我在这里应该做什么?
谢谢你。如果我还可以提供其他帮助,请告诉我。这个问题看起来很小,这就是为什么我不愿意在这里问,但我在任何地方都找不到任何相关内容。
我通过尝试交易视图订阅解决了这个问题。
你还在使用这个策略吗?