指标中不同货币对的 ema

问题描述 投票:0回答:1

我正在尝试编写一个脚本,其中我对多个货币对使用 ta.ema(close,200) 函数,例如。 如果收盘价 > 澳元兑美元均线,则应给出“看涨”信号,并且 如果关闭 < ema for USDJPY it should give a "Bearish" signal ect ect I identified 14 currency pairs. Is it possible to have a ema for each pair ? I tried the following code but I get just one result for all the pairs

EMA_LEN = input(200)

ticker01 = input.symbol("AUDUSD", "Ticker")           
// = input.symbol("ADAUSD", title="", group="Portfolio Asset #1", inline="Ticker 1")
ticker01EMA = request.security(ticker01 , ta.ema(close,EMA_LEN) 
//ta.ema(close,EMA_LEN) 
ticker01TREND = close > ticker01EMA ? "Bullish" : close < ticker01EMA ? "Bearish" : "Neutral"  
pine-script-v5
1个回答
0
投票

request.security需要:符号、时间框架和表达式
试试这个

EMA_LEN = input(200)
ticker01 = input.symbol("AUDUSD", "Ticker")
ticker01EMA = request.security(ticker01 , timeframe.period, ta.ema(close,EMA_LEN))
ticker01TREND = close > ticker01EMA ? "Bullish" : close < ticker01EMA ? "Bearish" : "Neutral"

对于桌子:

var table tbl = table.new(position.top_right, 2, 40)// 40 is max call request security
table.cell(tbl, 0,0, ticker01TREND)
table.cell(tbl, 1,0, ticker01)
© www.soinside.com 2019 - 2024. All rights reserved.