不同时间范围内的随机 hline 交叉
Stochastic hline cross on different timeframe
我正在尝试创建一个策略,我查看信号的每小时时间范围(随机 D 线高于 60 或低于 40 hline),然后在 15 分钟的时间范围内执行交易 - 但我没有太多安全函数中的 hline 表达式成功。有人可以建议更好或不同的方法来做到这一点。
这是在每小时时间范围内定义随机属性的代码,而图表专注于 15 分钟时间范围
我收到以下错误消息:类型 hline 不能用于安全“表达式”参数
////PINE脚本
htf_stoch_k = security(syminfo.tickerid,"60",sma(stoch(close, high, low, 14), 1),lookahead=barmerge.lookahead_on)
htf_stoch_d = security(syminfo.tickerid,"60",sma(htf_stoch_k, 3),lookahead=barmerge.lookahead_on)
htf_stoch_h0 = security(syminfo.tickerid,"60",hline(60, "Upper Band", color=#787B86),lookahead=barmerge.lookahead_on)
htf_stoch_h1 = security(syminfo.tickerid,"60",hline(40, "Lower Band", color=#787B86),lookahead=barmerge.lookahead_on)
给你伙计(这没有重绘),
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SafetyHammer
//@version=4
study("My Script")
Length = input(14, minval=1, title="Stochastic Length")
smoothK = input(1, title="Smoothing of Stochastic K")
smoothD = input(3, title="Smoothing of Stochastic D")
Res_stoch_k = input(title="Stoch K Resolution", type=input.resolution, defval="60")
Res_stoch_d = input(title="Stoch D Resolution", type=input.resolution, defval="60")
f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src[1],barmerge.gaps_on, lookahead = barmerge.lookahead_on) // orignal code line
Sto = stoch(close, high, low, Length)
K = sma(Sto, smoothK)
D = sma(Sto, smoothD)
htf_stoch_k = f_secureSecurity(syminfo.tickerid, Res_stoch_k, K)
htf_stoch_d = f_secureSecurity(syminfo.tickerid, Res_stoch_d, D)
upper_bound = input(title="Upper Bound", type=input.integer, defval=60, minval=0, maxval=100) // User input for overbought horizontal line
lower_bound = input(title="Lower Bound", type=input.integer, defval=40, minval=0, maxval=100) // User input for oversold horizontal line
upper_hl = hline(upper_bound, title="Upper bound")
lower_hl = hline(lower_bound, title="Lower bound")
top_hl = hline(100, title="100 bound")
bottom_hl = hline(0, title="0 bound")
fill(top_hl, upper_hl, color=color.new(color.red,80))
fill(lower_hl, bottom_hl, color=color.new(color.blue,80))
plot(htf_stoch_k, title="htf_stoch K", color=color.new(color.blue,10))
plot(htf_stoch_d, title="htf stoch D", color=color.new(color.red,10))
我正在尝试创建一个策略,我查看信号的每小时时间范围(随机 D 线高于 60 或低于 40 hline),然后在 15 分钟的时间范围内执行交易 - 但我没有太多安全函数中的 hline 表达式成功。有人可以建议更好或不同的方法来做到这一点。
这是在每小时时间范围内定义随机属性的代码,而图表专注于 15 分钟时间范围
我收到以下错误消息:类型 hline 不能用于安全“表达式”参数
////PINE脚本
htf_stoch_k = security(syminfo.tickerid,"60",sma(stoch(close, high, low, 14), 1),lookahead=barmerge.lookahead_on)
htf_stoch_d = security(syminfo.tickerid,"60",sma(htf_stoch_k, 3),lookahead=barmerge.lookahead_on)
htf_stoch_h0 = security(syminfo.tickerid,"60",hline(60, "Upper Band", color=#787B86),lookahead=barmerge.lookahead_on)
htf_stoch_h1 = security(syminfo.tickerid,"60",hline(40, "Lower Band", color=#787B86),lookahead=barmerge.lookahead_on)
给你伙计(这没有重绘),
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SafetyHammer
//@version=4
study("My Script")
Length = input(14, minval=1, title="Stochastic Length")
smoothK = input(1, title="Smoothing of Stochastic K")
smoothD = input(3, title="Smoothing of Stochastic D")
Res_stoch_k = input(title="Stoch K Resolution", type=input.resolution, defval="60")
Res_stoch_d = input(title="Stoch D Resolution", type=input.resolution, defval="60")
f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src[1],barmerge.gaps_on, lookahead = barmerge.lookahead_on) // orignal code line
Sto = stoch(close, high, low, Length)
K = sma(Sto, smoothK)
D = sma(Sto, smoothD)
htf_stoch_k = f_secureSecurity(syminfo.tickerid, Res_stoch_k, K)
htf_stoch_d = f_secureSecurity(syminfo.tickerid, Res_stoch_d, D)
upper_bound = input(title="Upper Bound", type=input.integer, defval=60, minval=0, maxval=100) // User input for overbought horizontal line
lower_bound = input(title="Lower Bound", type=input.integer, defval=40, minval=0, maxval=100) // User input for oversold horizontal line
upper_hl = hline(upper_bound, title="Upper bound")
lower_hl = hline(lower_bound, title="Lower bound")
top_hl = hline(100, title="100 bound")
bottom_hl = hline(0, title="0 bound")
fill(top_hl, upper_hl, color=color.new(color.red,80))
fill(lower_hl, bottom_hl, color=color.new(color.blue,80))
plot(htf_stoch_k, title="htf_stoch K", color=color.new(color.blue,10))
plot(htf_stoch_d, title="htf stoch D", color=color.new(color.red,10))