Pine script Pinescript未在较低的时间段图表上绘制更高分辨率的计算。如何解决

Pine script Pinescript未在较低的时间段图表上绘制更高分辨率的计算。如何解决,pine-script,Pine Script,我已经创建了一个基于较高时间段的绘图,以便在较低时间段查看。然而,当我切换到较低的时间段时,没有进行绘图,代码中会出现什么错误 study(title = "Trading system", shorttitle="TS", overlay =true) //______________User inputs_________________ _1 = input(title = "═════ Bias Settings

我已经创建了一个基于较高时间段的绘图,以便在较低时间段查看。然而,当我切换到较低的时间段时,没有进行绘图,代码中会出现什么错误

study(title = "Trading system", shorttitle="TS", overlay =true)
//______________User inputs_________________
_1              = input(title = "═════ Bias Settings ═════",    type = input.bool,          defval = true)
i_resolution    = input(title = "Select Bias Resolution",       type = input.resolution,    defval ="75")


//____________ variables ____________________
var float highValue     = na
var float lowValue      = na
var float bias          = na
string barType          = na


//_____________Calculations
//Assign high low for bias calculations

tfhigh  = security(syminfo.tickerid,expression = high, resolution = i_resolution, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on )
tflow   = security(syminfo.tickerid,expression = low, resolution = i_resolution, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on )

highValue       := tfhigh < highValue[1] and tflow > lowValue[1] ? highValue[1] : tfhigh
lowValue        := tfhigh < highValue[1] and tflow > lowValue[1] ? lowValue[1] : tflow

// Define Bar Types
barType         := highValue > highValue[1] and lowValue > lowValue[1] ? "Up" : highValue < highValue[1] and lowValue < lowValue[1] ? "Down" : highValue > highValue[1] and lowValue < lowValue[1] ? "Out" : "In"

// Generate bias
bias            := barType == "Up" ? highValue : barType == "Down" ? lowValue : barType == "Out" and barType[1] == "Up" ? highValue : barType == "Out" and barType[1] == "Down" ? lowValue : bias[1]

// Bias shift to bullish or bearish
bullishcondition = bias > bias[1] and bias[1] < bias[2]
bearishcondition = bias < bias[1] and bias[1] > bias[2]

// Values to plot
upBias = valuewhen(bullishcondition, bias[1],0)
dnBias = valuewhen(bearishcondition, bias[1],0)
plot(upBias, color = color.green)
plot(dnBias, color = color.red)
研究(title=“交易系统”,shorttitle=“TS”,overlay=true)
//______________用户输入_________________
_1=输入(标题=”═════ 偏差设置═════",    type=input.bool,deffal=true)
i_分辨率=输入(title=“选择偏差分辨率”,type=input.resolution,deffal=“75”)
//____________变数____________________
var浮点高值=na
var浮点低值=na
var浮动偏差=na
字符串barType=na
//_____________计算
//为偏差计算指定高-低
tfhigh=security(syminfo.tickerid,expression=high,resolution=i\u resolution,gaps=barmerge.gaps\u off,lookahead=barmerge.lookahead\u on)
tflow=security(syminfo.tickerid,expression=low,resolution=i\u resolution,gaps=barmerge.gaps\u off,lookahead=barmerge.lookahead\u on)
高值:=tfhigh<高值[1]和tflow>低值[1]?高值[1]:tfhigh
低值:=tfhigh<高值[1]和tflow>低值[1]?低值[1]:tflow
//定义条形图类型
barType:=高值>高值[1]和低值>低值[1]?“向上”:高值<高值[1]和低值<低值[1]?“向下”:高值>高值[1]和低值<低值[1]?“向外”:“向内”
//产生偏见
偏差:barType==“向上”?高值:barType==“向下”?低值:barType==“向外”和barType[1]==“向上”?高值:barType==“向外”和barType[1]==“向下”?低值:偏差[1]
//偏向转向看涨或看跌
看涨条件=偏差>偏差[1]和偏差[1]<偏差[2]
bearishcondition=偏差<偏差[1]和偏差[1]>偏差[2]
//要绘制的值
upBias=valuewhen(看涨条件,偏差[1],0)
dnBias=valuewhen(熊市条件,偏差[1],0)
绘图(上视,颜色=颜色。绿色)
绘图(dnBias,颜色=颜色。红色)

因为这些条件总是错误的

bullishcondition = bias > bias[1] and bias[1] < bias[2]
bearishcondition = bias < bias[1] and bias[1] > bias[2]

问题在于较低的tf偏差与偏差1比较较低的tf值需要给出要与之比较的tf的倍数。С完成了答案。谢谢你解决了这个问题。我之前尝试过输入安全函数,但不知道偏差作为一个函数可以在安全中绘制。非常感谢
//@version=4
study(title = "Help (Trading system)", shorttitle="TS", overlay =true)
//______________User inputs_________________
_1              = input(title = "═════ Bias Settings ═════",    type = input.bool,          defval = true)
i_resolution    = input(title = "Select Bias Resolution",       type = input.resolution,    defval ="75")


//____________ variables ____________________
// var float highValue     = na
// var float lowValue      = na
// var float bias          = na
// string barType          = na


//_____________Calculations
//Assign high low for bias calculations

bias() =>
    float highValue     = na
    float lowValue      = na
    float bias          = na
    string barType      = na
    // tfhigh  = security(syminfo.tickerid, expression = high, resolution = i_resolution, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on )
    // tflow   = security(syminfo.tickerid, expression = low, resolution = i_resolution, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on )
    
    tfhigh  = high
    tflow   = low

    highValue       := tfhigh < highValue[1] and tflow > lowValue[1] ? highValue[1] : tfhigh
    lowValue        := tfhigh < highValue[1] and tflow > lowValue[1] ? lowValue[1] : tflow
    
    // Define Bar Types
    barType         := highValue > highValue[1] and lowValue > lowValue[1] ? "Up" : highValue < highValue[1] and lowValue < lowValue[1] ? "Down" : highValue > highValue[1] and lowValue < lowValue[1] ? "Out" : "In"
    
    // Generate bias
    bias            := barType == "Up" ? highValue : barType == "Down" ? lowValue : barType == "Out" and barType[1] == "Up" ? highValue : barType == "Out" and barType[1] == "Down" ? lowValue : bias[1]
    
    // Bias shift to bullish or bearish
    bullishcondition = bias > bias[1] and bias[1] < bias[2]
    bearishcondition = bias < bias[1] and bias[1] > bias[2]
    
    // Values to plot
    upBias = valuewhen(bullishcondition, bias[1], 0)
    dnBias = valuewhen(bearishcondition, bias[1], 0)
    [upBias, dnBias]

[up, dn] = security(syminfo.tickerid, expression = bias(), resolution = i_resolution, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on )
plot(up, color = color.green)
plot(dn, color = color.red)