交易视图指标测试
我的多头信号条件是:
- 8 EMA 高于 14 EMA,即高于 50 EMA
- 随机 RSI 指标的 k 线应与随机 RSI 指标的 d 线交叉,即 k 线应从下方与 d 线相交
- 当两者都出现时,应发生交叉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:
- 8 EMA is above 14 EMA which is above 50 EMA
- k line of stochastic RSI indicator should crossover d line of stochastic RSI indicator, i.e. k line should intersect d line from below
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论