Because these conditions are always false
bullishcondition = bias > bias[1] and bias[1] < bias[2]
bearishcondition = bias < bias[1] and bias[1] > bias[2]
To make sure of this, put it on the chart plot(bias, color = color.blue)
[added]
If I understand your comment correctly, all calculations should be combined into a function and called in security
//@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)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…