Pine script 基于3hr时间框架的日线图上的彩色条

Pine script 基于3hr时间框架的日线图上的彩色条,pine-script,Pine Script,当价格在3小时的时间范围内高于200sma时,我试图在日线图上涂上颜色。这是我想出来的,但它似乎不起作用。在查看日线图时,它仅在日线价格高于200sma时突出显示,而不是在3hr图表上价格高于200sma时突出显示 study(title="SMA Gradient Grey", overlay=true) // Compute SMA smaValue_30 = sma(close, 30) smaValue_50 = sma(close, 50) smaValue_20

当价格在3小时的时间范围内高于200sma时,我试图在日线图上涂上颜色。这是我想出来的,但它似乎不起作用。在查看日线图时,它仅在日线价格高于200sma时突出显示,而不是在3hr图表上价格高于200sma时突出显示

study(title="SMA Gradient Grey", overlay=true)

// Compute SMA
smaValue_30 = sma(close, 30)
smaValue_50 = sma(close, 50)
smaValue_200 = sma(close, 200)

//grabs 3hr 200 day sma
timeFrame = input(title="Other time frame", type=resolution,
     defval="180")

smaClose = sma(security(tickerid, timeFrame, close),
     200)

threehr_price = security(tickerid, timeFrame, close)

semi_grey  = (threehr_price >= smaClose)

// Colour price bars
barColour = (semi_grey) ? #e7e7e7 : na

barcolor(color=barColour)
该脚本尚未经过测试,但应该可以根据需要工作

study(title="SMA Gradient Grey", overlay=true)

// Compute SMA
smaValue_30 = sma(close, 30)
smaValue_50 = sma(close, 50)
smaValue_200 = sma(close, 200)

//grabs 3hr 200 day sma
timeFrame = input(title="Other time frame", type=resolution,
     defval="180")

smaClose = security(tickerid, timeFrame, sma(close,200))

threehr_price = security(tickerid, timeFrame, close) //the price is the same for any timeframe, it can be removed

semi_grey  = (threehr_price >= smaClose)

// Colour price bars
barColour = (semi_grey) ? #e7e7e7 : na

barcolor(color=barColour)