交易视图指标测试

发布于 2025-01-19 20:01:36 字数 1372 浏览 3 评论 0原文

我的多头信号条件是:

  1. 8 EMA 高于 14 EMA,即高于 50 EMA
  2. 随机 RSI 指标的 k 线应与随机 RSI 指标的 d 线交叉,即 k 线应从下方与 d 线相交
  3. 当两者都出现时,应发生交叉k 和 d 线低于 70。

代码:

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © junjinho1

//@version=5
indicator("3 EMA, Stochastic RSI, ATR", overlay=true)

//SMA
eight_EMA = ta.ema(close,8)
fourteen_EMA = ta.ema(close,14)
fifty_EMA = ta.ema(close,50)


//StoRSI
smoothK = input.int(3, minval=1)
smoothD = input.int(3, minval=1)
lengthRSI = input.int(14, minval=1)
lengthStoch = input.int(14, minval=1)
src = input(close, title="RSI Source")

rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)

//conditions
longCondition = (eight_EMA > fourteen_EMA) and (fourteen_EMA > fifty_EMA) and (ta.crossover(k, d)) and (k < 70) and (d < 70)
shortCondition = (eight_EMA < fourteen_EMA) and (fourteen_EMA < fifty_EMA) and (ta.crossunder(k, d)) and (k > 30) and (d > 30)

alertcondition(longCondition, title = "Stochastic_RSI_Long", message = "Stochastic_RSI_Long")
alertcondition(shortCondition, title = "Stochastic_RSI_Short", message = "Stochastic_RSI_Short")

有时,我发现收到的警报无法准确捕捉我的预期条件。例如,当条件(1)不满足时,可能存在交叉,或者可能满足条件(2),但交叉不正确。

如果有人能指出我哪里错了,我将不胜感激。

My conditions for a long signal are:

  1. 8 EMA is above 14 EMA which is above 50 EMA
  2. k line of stochastic RSI indicator should crossover d line of stochastic RSI indicator, i.e. k line should intersect d line from below
  3. The cross over should occur when both k and d lines are below 70.

Code:

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © junjinho1

//@version=5
indicator("3 EMA, Stochastic RSI, ATR", overlay=true)

//SMA
eight_EMA = ta.ema(close,8)
fourteen_EMA = ta.ema(close,14)
fifty_EMA = ta.ema(close,50)


//StoRSI
smoothK = input.int(3, minval=1)
smoothD = input.int(3, minval=1)
lengthRSI = input.int(14, minval=1)
lengthStoch = input.int(14, minval=1)
src = input(close, title="RSI Source")

rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)

//conditions
longCondition = (eight_EMA > fourteen_EMA) and (fourteen_EMA > fifty_EMA) and (ta.crossover(k, d)) and (k < 70) and (d < 70)
shortCondition = (eight_EMA < fourteen_EMA) and (fourteen_EMA < fifty_EMA) and (ta.crossunder(k, d)) and (k > 30) and (d > 30)

alertcondition(longCondition, title = "Stochastic_RSI_Long", message = "Stochastic_RSI_Long")
alertcondition(shortCondition, title = "Stochastic_RSI_Short", message = "Stochastic_RSI_Short")

Sometimes, I find that the alerts I'm receiving do not accurately capture my intended conditions. E.g. there may be a crossover when condition (1) is not met, or condition (2) may be met, but the cross over is incorrect.

If any one could point out where I went wrong, I would be so grateful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文