提问人:Parshuram Gore 提问时间:11/14/2023 更新时间:11/15/2023 访问量:32
我需要在我的 15 分钟时间框架图表上提供 5 分钟时间框架的 MACD 数据才能在策略中使用它
i need MACD data of 15 min timeframe on my 5 Min time frame chart to use it in a strategy
问:
我需要在我的 5 分钟时间框架图表上获得 15 分钟时间框架(直方图)的 MACD 数据才能在策略中使用它。
request.security_lower_tf(symbol, timeframe, expression, ignore_invalid_symbol, currency, ignore_invalid_timeframe) → array<type>
答:
0赞
Gu5tavo71
11/15/2023
#1
您可以使用此库中的函数在 5 分钟时间段图表上获取 15 分钟时间段(直方图)的 MACD 数据f_security
像这样的东西:
f_security(_symbol, _res, _src, _repaint) =>
request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])
[_repaint ? 0 : barstate.isrealtime ? 0 : 1]
hist = f_security(syminfo.tickerid, '15',
ta.ema(close, 12) - ta.ema(close, 26) -
ta.ema(ta.ema(close, 12) - ta.ema(close, 26), 9),
true)
plot(
hist,
title = "Histogram",
style = plot.style_columns,
color = (hist >= 0 ?
(hist[1] < hist ? #26A69A : #B2DFDB) :
(hist[1] < hist ? #FFCDD2 : #FF5252)))
评论