我如何在 ta.sar (pinescript/TradingView) 上调用 request.security?
How i can call request.security on ta.sar (pinescript/TradingView)?
我需要在 heikin ashi 安全中调用 ta.sar,这会给我一个 buy/sell 信号以在日本蜡烛值中执行。
//SAR security example (not working)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
out = (request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) ta.sar(start, increment, maximum))
sarColor = out < low ? color.lime : color.red
plot(out, "ParabolicSAR", style=plot.style_cross, color=sarColor)
request.security()
函数的第 3 个参数是您希望 return 的 expression
。在你的例子中,你在请求 Close
,同时你想获得 sar。您还使用了一个可以从代码中删除的额外括号:
//@version=5
indicator(title="Money Flow Index", shorttitle="MFI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
out = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ta.sar(start, increment, maximum))
sarColor = out < low ? color.lime : color.red
plot(out, "ParabolicSAR", style=plot.style_cross, color=sarColor)
如果您想稍后使用 Close,您可以同时获取 Close 和 sar:
//@version=5
indicator(title="Money Flow Index", shorttitle="MFI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
[_close, out] = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, [close, ta.sar(start, increment, maximum)])
sarColor = out < low ? color.lime : color.red
plot(out, "ParabolicSAR", style=plot.style_cross, color=sarColor)
plot(_close)
我需要在 heikin ashi 安全中调用 ta.sar,这会给我一个 buy/sell 信号以在日本蜡烛值中执行。
//SAR security example (not working)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
out = (request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) ta.sar(start, increment, maximum))
sarColor = out < low ? color.lime : color.red
plot(out, "ParabolicSAR", style=plot.style_cross, color=sarColor)
request.security()
函数的第 3 个参数是您希望 return 的 expression
。在你的例子中,你在请求 Close
,同时你想获得 sar。您还使用了一个可以从代码中删除的额外括号:
//@version=5
indicator(title="Money Flow Index", shorttitle="MFI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
out = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ta.sar(start, increment, maximum))
sarColor = out < low ? color.lime : color.red
plot(out, "ParabolicSAR", style=plot.style_cross, color=sarColor)
如果您想稍后使用 Close,您可以同时获取 Close 和 sar:
//@version=5
indicator(title="Money Flow Index", shorttitle="MFI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
[_close, out] = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, [close, ta.sar(start, increment, maximum)])
sarColor = out < low ? color.lime : color.red
plot(out, "ParabolicSAR", style=plot.style_cross, color=sarColor)
plot(_close)