在 TradingView 中使用止盈和止损警报

问题描述 投票:0回答:2

我按照答案Here在一个脚本中按百分比实施止损和止盈作为一种策略,如代码所示。

但是,现在我想将此策略转换为指标 v5(研究 v4),并为其添加警报功能。

我使用此代码在满足 EnterLong 条件后触发警报,但是如何使用相同的警报设置 TP 和 SL?

是否可以创建一个带有 TP 和 SL 的警报,避免每个交易对出现多个警报,特别是因为 TradingView 允许的最大警报数为 400,这将被完全消耗?

备注我使用的是 TP% 和 SL%,可能不仅包括现货交易,还包括杠杆。

alertcondition(enterLong, title="LONG", message = "long sl=SLPerc tp=TP1Perc")
alert pine-script algorithmic-trading pine-script-v5
2个回答
0
投票

如果你想使用动态消息,我建议你使用

alert()
功能。

所以,你可以这样做:

s = "Entry price: " + str.tostring(entryPrice) + " Stop loss: " + str.tostring(SLPerc) + " Take profit: " + str.tostring(TP1Perc)

if your_condition
    alert(s, alert.freq_once_per_bar_close)

alertcondition()
不支持您正在尝试做的事情。如果您确实想使用
alertcondition()
,您应该绘制这些值并使用
{{plot_x}}
占位符,如此处所述。


0
投票

Buona sera,ho una domanda non so se vi è headato,io ho realizzato uno script molto Performante,lavora su m1 gold,94.5 di winrate,faccio le op che si presetano a mano su mt4 unaomba,ho deciso di collegarlo per nono Stare ore davanti al pc, cosi ho creato un webhook, dove faccio rimbalzare gli Alert e poi ho creato mt4 bot che Riceve gli Alert trade w, nel 90 % dei casi Alert passa mi apre op su mt4 e mi esce per takeprofit, a Volte invece l'uscita non la passa,è randomico,ma come è possibile è codice è matematica,perche quando gli pare non passa uscita e quindi mi incasina le op?谢谢你的千里之情

© www.soinside.com 2019 - 2024. All rights reserved.