decision_cockpit.txt
Copy
// This Pine Script(R) code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// OpenAI - Very Long Term RVOL Pro
//@version=6
indicator("Very Long Term RVOL Pro", shorttitle="Very Long Term", overlay=true, max_labels_count=10)
groupCore = "Core"
groupThresholds = "Thresholds"
groupRanges = "Ranges"
groupDisplay = "Display"
panelCorner = input.string("Top Right", "Panel Corner", options=["Top Left", "Top Right", "Bottom Left", "Bottom Right"], group=groupCore)
rvolLen = input.int(20, "RVOL Length", minval=5, group=groupCore)
effortThreshold = input.float(0.12, "Effort Threshold", minval=0.01, step=0.01, group=groupCore)
rangeLookback = input.int(20, "Range Lookback", minval=5, maxval=100, group=groupCore)
supportNearAtr = input.float(0.80, "Near Level ATR", minval=0.10, step=0.05, group=groupCore)
activeThresh = input.float(1.0, "Active Threshold", minval=0.1, step=0.1, group=groupThresholds)
hotThresh = input.float(1.5, "Hot Threshold", minval=0.2, step=0.1, group=groupThresholds)
extremeThresh = input.float(2.5, "Extreme Threshold", minval=0.5, step=0.1, group=groupThresholds)
tf1 = input.timeframe("1D", "TF 1", group=groupRanges)
tf2 = input.timeframe("7D", "TF 2", group=groupRanges)
tf3 = input.timeframe("1M", "TF 3", group=groupRanges)
tf4 = input.timeframe("6M", "TF 4", group=groupRanges)
showNearestLevels = input.bool(false, "Show Nearest Range Levels", group=groupDisplay)
showAllTfLevels = input.bool(true, "Show All TF S/R Levels", group=groupDisplay)
supportColor = input.color(color.new(color.lime, 0), "Support Color", group=groupDisplay)
resistanceColor = input.color(color.new(color.red, 0), "Resistance Color", group=groupDisplay)
f_safe_div(float a, float b) =>
b == 0.0 ? 0.0 : a / b
f_clamp(float x, float lo, float hi) =>
math.max(lo, math.min(hi, x))
f_bool_int(bool cond) =>
cond ? 1 : 0
f_pack(int rvolLen_, int rangeLookback_) =>
float rng = math.max(high - low, syminfo.mintick)
float atr = ta.atr(14)
float rangeHigh = ta.highest(high, rangeLookback_)
float rangeLow = ta.lowest(low, rangeLookback_)
float rvol = f_safe_div(volume, ta.sma(volume, rvolLen_))
float effort = rvol * f_safe_div(close - open, rng)
float closeLoc = f_safe_div(close - low, rng)
float upperWick = high - math.max(open, close)
float lowerWick = math.min(open, close) - low
float wickBias = f_safe_div(lowerWick - upperWick, rng)
float result = f_safe_div(math.abs(close - open), atr)
float acceptUp = close > ta.highest(high[1], math.min(rangeLookback_, 5)) ? 1.0 : 0.0
float acceptDn = close < ta.lowest(low[1], math.min(rangeLookback_, 5)) ? 1.0 : 0.0
float prevHigh = rangeHigh[1]
float prevLow = rangeLow[1]
float overlapTop = math.min(rangeHigh, prevHigh)
float overlapBot = math.max(rangeLow, prevLow)
float overlapSize = math.max(overlapTop - overlapBot, 0.0)
float currWidth = math.max(rangeHigh - rangeLow, syminfo.mintick)
float prevWidth = math.max(prevHigh - prevLow, syminfo.mintick)
float balancePct = math.min(f_safe_div(overlapSize, currWidth), f_safe_div(overlapSize, prevWidth))
[close, rangeHigh, rangeLow, atr, rvol, effort, closeLoc, wickBias, result, acceptUp, acceptDn, balancePct]
f_trend(float effort_, float closeLoc_) =>
effort_ > effortThreshold and closeLoc_ >= 0.55 ? "BULL" :
effort_ < -effortThreshold and closeLoc_ <= 0.45 ? "BEAR" : "MIXED"
f_closeq(float closeLoc_) =>
closeLoc_ >= 0.75 ? "STRONG+" :
closeLoc_ >= 0.60 ? "STRONG" :
closeLoc_ <= 0.25 ? "WEAK+" :
closeLoc_ <= 0.40 ? "WEAK" : "MID"
f_pressure(float rvol_, float effort_, float closeLoc_, float wickBias_) =>
float bull = rvol_ * math.max(effort_, 0) + closeLoc_ * 0.6 + math.max(wickBias_, 0) * 0.4
float bear = rvol_ * math.max(-effort_, 0) + (1.0 - closeLoc_) * 0.6 + math.max(-wickBias_, 0) * 0.4
bull > bear * 1.15 ? "BUY" : bear > bull * 1.15 ? "SELL" : "NEUTRAL"
f_outcome(float distSupAtr_, float distResAtr_, float rvol_, float effort_, float closeLoc_, float acceptUp_, float acceptDn_) =>
bool nearSup = distSupAtr_ <= supportNearAtr
bool nearRes = distResAtr_ <= supportNearAtr
bool bounce = nearSup and rvol_ >= activeThresh and effort_ > effortThreshold and closeLoc_ >= 0.55 and acceptDn_ == 0.0
bool breakdown = nearSup and rvol_ >= activeThresh and effort_ < -effortThreshold and closeLoc_ <= 0.40 and acceptDn_ == 1.0
bool reject = nearRes and rvol_ >= activeThresh and effort_ < -effortThreshold and closeLoc_ <= 0.45 and acceptUp_ == 0.0
bool breakout = nearRes and rvol_ >= activeThresh and effort_ > effortThreshold and closeLoc_ >= 0.60 and acceptUp_ == 1.0
breakout ? "BREAK UP" :
breakdown ? "BREAK DN" :
bounce ? "BOUNCE" :
reject ? "REJECT" :
rvol_ < activeThresh ? "COMPRESS" : "PRESSURE"
f_er(float effort_, float result_) =>
f_safe_div(result_, math.max(math.abs(effort_), 0.01))
f_dir_er(float effort_, float result_) =>
effort_ == 0.0 ? 0.0 : math.sign(effort_) * f_er(effort_, result_)
f_harmony(float effort_, float result_) =>
math.abs(effort_) > effortThreshold and result_ >= 0.35 ? "EXPAND" :
math.abs(effort_) > effortThreshold and result_ < 0.20 ? "ABSORB" :
math.abs(effort_) < effortThreshold and result_ >= 0.35 ? "AIR" : "NORMAL"
f_operator(float effort_, float result_, float closeLoc_) =>
math.abs(effort_) > effortThreshold and result_ < 0.20 and closeLoc_ > 0.60 ? "ABSORB UP" :
math.abs(effort_) > effortThreshold and result_ < 0.20 and closeLoc_ < 0.40 ? "ABSORB DN" :
effort_ > effortThreshold and result_ >= 0.35 and closeLoc_ >= 0.60 ? "EXPAND UP" :
effort_ < -effortThreshold and result_ >= 0.35 and closeLoc_ <= 0.40 ? "EXPAND DN" :
math.abs(effort_) < effortThreshold and result_ >= 0.35 ? "AIR MOVE" : "NORMAL"
f_velocity(float result_) =>
result_ >= 0.60 ? "FAST" :
result_ >= 0.30 ? "MED" : "SLOW"
f_of_state(float rvol_, float result_, float closeLoc_, float acceptUp_, float acceptDn_) =>
rvol_ >= activeThresh and result_ < 0.20 and closeLoc_ > 0.55 ? "PASSIVE UP" :
rvol_ >= activeThresh and result_ < 0.20 and closeLoc_ < 0.45 ? "PASSIVE DN" :
rvol_ >= activeThresh and result_ >= 0.35 and acceptUp_ == 1.0 ? "AGGR UP" :
rvol_ >= activeThresh and result_ >= 0.35 and acceptDn_ == 1.0 ? "AGGR DN" : "NEUTRAL"
f_ib_state(float closeLoc_) =>
closeLoc_ >= 0.80 ? "IB UP" :
closeLoc_ <= 0.20 ? "IB DN" : "IB IN"
f_absorb_qty(float effort_, float result_, float closeLoc_, float rvol_, bool isUp) =>
bool absorb = isUp ? math.abs(effort_) > effortThreshold and result_ < 0.20 and closeLoc_ > 0.60 : math.abs(effort_) > effortThreshold and result_ < 0.20 and closeLoc_ < 0.40
float resultFactor = 1.0 - f_clamp(result_ / 0.20, 0.0, 1.0)
float closeFactor = isUp ? f_clamp((closeLoc_ - 0.50) / 0.50, 0.0, 1.0) : f_clamp((0.50 - closeLoc_) / 0.50, 0.0, 1.0)
float qty = math.abs(effort_) * math.max(rvol_, 0.0) * resultFactor * (0.50 + closeFactor)
absorb ? qty : 0.0
f_absorb_speed(float qty_) =>
ta.ema(qty_ - nz(qty_[1]), 3)
f_absorb_rating(float upQty_, float dnQty_, float upSpd_, float dnSpd_) =>
float dominantQty = math.max(upQty_, dnQty_)
float dominantSpd = upQty_ >= dnQty_ ? upSpd_ : dnSpd_
dominantQty >= 2.20 and dominantSpd > 0.18 ? "A+" :
dominantQty >= 1.60 and dominantSpd > 0.10 ? "A" :
dominantQty >= 1.00 and dominantSpd > 0.04 ? "B" :
dominantQty >= 0.55 ? "C" :
dominantQty > 0 ? "D" : "-"
f_pick_nearest_tf(string currentTf, float currentScore, string nextTf, float nextScore) =>
nextScore < currentScore ? nextTf : currentTf
f_state_text(float balancePct_, float dirEr_, float acceptUp_, float acceptDn_) =>
balancePct_ >= 0.55 ? "BALANCE" :
acceptUp_ == 1.0 and dirEr_ > 0 ? "IMB UP" :
acceptDn_ == 1.0 and dirEr_ < 0 ? "IMB DN" : "TRANSITION"
f_bias_color(string txt) =>
txt == "BREAK UP" or txt == "BOUNCE" or txt == "BUY" or txt == "BULL" ? color.new(color.lime, 55) :
txt == "BREAK DN" or txt == "REJECT" or txt == "SELL" or txt == "BEAR" ? color.new(color.red, 55) :
txt == "COMPRESS" ? color.new(color.orange, 65) : color.new(color.gray, 70)
f_rvol_color(float x) =>
x >= extremeThresh ? color.new(color.fuchsia, 0) :
x >= hotThresh ? color.new(color.orange, 0) :
x >= activeThresh ? color.new(color.teal, 0) :
color.new(color.gray, 40)
f_absorb_color(float x) =>
x >= 2.20 ? color.new(color.fuchsia, 15) :
x >= 1.60 ? color.new(color.orange, 20) :
x >= 1.00 ? color.new(color.teal, 25) :
x > 0 ? color.new(color.gray, 65) : color.new(color.black, 84)
f_speed_color(float x) =>
x > 0.18 ? color.new(color.lime, 30) :
x > 0.08 ? color.new(color.teal, 35) :
x > 0 ? color.new(color.green, 45) :
x < -0.18 ? color.new(color.red, 30) :
x < -0.08 ? color.new(color.maroon, 35) :
x < 0 ? color.new(color.orange, 45) : color.new(color.black, 84)
f_rating_color(string rate_) =>
rate_ == "A+" ? color.new(color.fuchsia, 10) :
rate_ == "A" ? color.new(color.orange, 15) :
rate_ == "B" ? color.new(color.teal, 20) :
rate_ == "C" ? color.new(color.gray, 45) :
rate_ == "D" ? color.new(color.gray, 65) : color.new(color.black, 84)
f_er_regime(float er_, float dirEr_, float closeLoc_, float distSupAtr_, float distResAtr_) =>
bool nearSup = distSupAtr_ <= supportNearAtr
bool nearRes = distResAtr_ <= supportNearAtr
bool bullExhaust = dirEr_ > 0 and nearRes and closeLoc_ < 0.60
bool bearExhaust = dirEr_ < 0 and nearSup and closeLoc_ > 0.40
er_ <= 1.30 ? "DRIVE" :
er_ <= 1.80 ? "PRESS" :
er_ <= 2.50 ? (bullExhaust or bearExhaust ? "EXH?" : "CHURN") :
bullExhaust or bearExhaust ? "EXH" : "NOISY"
f_er_regime_color(string regime_) =>
regime_ == "DRIVE" ? color.new(color.lime, 10) :
regime_ == "PRESS" ? color.new(color.teal, 15) :
regime_ == "CHURN" ? color.new(color.orange, 12) :
regime_ == "EXH?" ? color.new(color.orange, 0) :
regime_ == "EXH" ? color.new(color.red, 5) : color.new(color.gray, 45)
f_level_power(bool isSupport, float dirEr_, float er_, float rvol_, float effort_, float closeLoc_, float distAtr_, float acceptUp_, float acceptDn_, float balancePct_) =>
float dirScore = isSupport ? math.max(dirEr_, 0.0) * 18.0 : math.max(-dirEr_, 0.0) * 18.0
float effortScore = isSupport ? math.max(effort_, 0.0) * 14.0 : math.max(-effort_, 0.0) * 14.0
float locScore = isSupport ? closeLoc_ * 12.0 : (1.0 - closeLoc_) * 12.0
float volumeScore = math.min(rvol_, 2.5) * 8.0
float proximityScore = distAtr_ <= supportNearAtr ? 18.0 * (1.0 - f_clamp(distAtr_ / supportNearAtr, 0.0, 1.0)) : math.max(0.0, 6.0 - (distAtr_ - supportNearAtr) * 3.0)
float acceptScore = isSupport ? (acceptDn_ == 0.0 ? 6.0 : -10.0) + (acceptUp_ == 1.0 ? 4.0 : 0.0) : (acceptUp_ == 0.0 ? 6.0 : -10.0) + (acceptDn_ == 1.0 ? 4.0 : 0.0)
float balanceAdj = balancePct_ >= 0.55 ? -8.0 : balancePct_ >= 0.35 ? 0.0 : 4.0
float erAdj = er_ <= 1.30 ? 12.0 : er_ <= 1.80 ? 6.0 : er_ <= 2.50 ? -4.0 : -10.0
f_clamp(dirScore + effortScore + locScore + volumeScore + proximityScore + acceptScore + balanceAdj + erAdj, 0.0, 100.0)
f_power_color(float power_, bool isSupport) =>
power_ >= 72 ? color.new(isSupport ? color.lime : color.red, 0) :
power_ >= 58 ? color.new(isSupport ? color.green : color.maroon, 5) :
power_ >= 44 ? color.new(color.teal, 12) :
power_ >= 30 ? color.new(color.orange, 15) : color.new(color.gray, 35)
f_ds_cell_text(float demandPower_, float supplyPower_) =>
"D" + str.tostring(math.round(demandPower_)) + "/S" + str.tostring(math.round(supplyPower_))
f_ds_bias_text(float demandPower_, float supplyPower_) =>
demandPower_ - supplyPower_ >= 18 ? "DEMAND DOM" :
demandPower_ - supplyPower_ >= 6 ? "DEMAND +" :
supplyPower_ - demandPower_ >= 18 ? "SUPPLY DOM" :
supplyPower_ - demandPower_ >= 6 ? "SUPPLY +" : "BAL D/S"
[c1, hi1, lo1, atr1, rv1, ef1, cl1, wb1, rs1, acU1, acD1, bal1] = request.security(syminfo.tickerid, tf1, f_pack(rvolLen, rangeLookback), barmerge.gaps_off, barmerge.lookahead_off)
[c2, hi2, lo2, atr2, rv2, ef2, cl2, wb2, rs2, acU2, acD2, bal2] = request.security(syminfo.tickerid, tf2, f_pack(rvolLen, rangeLookback), barmerge.gaps_off, barmerge.lookahead_off)
[c3, hi3, lo3, atr3, rv3, ef3, cl3, wb3, rs3, acU3, acD3, bal3] = request.security(syminfo.tickerid, tf3, f_pack(rvolLen, rangeLookback), barmerge.gaps_off, barmerge.lookahead_off)
[c4, hi4, lo4, atr4, rv4, ef4, cl4, wb4, rs4, acU4, acD4, bal4] = request.security(syminfo.tickerid, tf4, f_pack(rvolLen, rangeLookback), barmerge.gaps_off, barmerge.lookahead_off)
distSup1Atr = f_safe_div(math.max(c1 - lo1, 0), atr1)
distRes1Atr = f_safe_div(math.max(hi1 - c1, 0), atr1)
distSup2Atr = f_safe_div(math.max(c2 - lo2, 0), atr2)
distRes2Atr = f_safe_div(math.max(hi2 - c2, 0), atr2)
distSup3Atr = f_safe_div(math.max(c3 - lo3, 0), atr3)
distRes3Atr = f_safe_div(math.max(hi3 - c3, 0), atr3)
distSup4Atr = f_safe_div(math.max(c4 - lo4, 0), atr4)
distRes4Atr = f_safe_div(math.max(hi4 - c4, 0), atr4)
trend1 = f_trend(ef1, cl1)
trend2 = f_trend(ef2, cl2)
trend3 = f_trend(ef3, cl3)
trend4 = f_trend(ef4, cl4)
press1 = f_pressure(rv1, ef1, cl1, wb1)
press2 = f_pressure(rv2, ef2, cl2, wb2)
press3 = f_pressure(rv3, ef3, cl3, wb3)
press4 = f_pressure(rv4, ef4, cl4, wb4)
out1 = f_outcome(distSup1Atr, distRes1Atr, rv1, ef1, cl1, acU1, acD1)
out2 = f_outcome(distSup2Atr, distRes2Atr, rv2, ef2, cl2, acU2, acD2)
out3 = f_outcome(distSup3Atr, distRes3Atr, rv3, ef3, cl3, acU3, acD3)
out4 = f_outcome(distSup4Atr, distRes4Atr, rv4, ef4, cl4, acU4, acD4)
harm1 = f_harmony(ef1, rs1)
harm2 = f_harmony(ef2, rs2)
harm3 = f_harmony(ef3, rs3)
harm4 = f_harmony(ef4, rs4)
er1 = f_er(ef1, rs1)
er2 = f_er(ef2, rs2)
er3 = f_er(ef3, rs3)
er4 = f_er(ef4, rs4)
dirEr1 = f_dir_er(ef1, rs1)
dirEr2 = f_dir_er(ef2, rs2)
dirEr3 = f_dir_er(ef3, rs3)
dirEr4 = f_dir_er(ef4, rs4)
erReg1 = f_er_regime(er1, dirEr1, cl1, distSup1Atr, distRes1Atr)
erReg2 = f_er_regime(er2, dirEr2, cl2, distSup2Atr, distRes2Atr)
erReg3 = f_er_regime(er3, dirEr3, cl3, distSup3Atr, distRes3Atr)
erReg4 = f_er_regime(er4, dirEr4, cl4, distSup4Atr, distRes4Atr)
state1 = f_state_text(bal1, dirEr1, acU1, acD1)
state2 = f_state_text(bal2, dirEr2, acU2, acD2)
state3 = f_state_text(bal3, dirEr3, acU3, acD3)
state4 = f_state_text(bal4, dirEr4, acU4, acD4)
closeQ1 = f_closeq(cl1)
closeQ2 = f_closeq(cl2)
closeQ3 = f_closeq(cl3)
closeQ4 = f_closeq(cl4)
op1 = f_operator(ef1, rs1, cl1)
op2 = f_operator(ef2, rs2, cl2)
op3 = f_operator(ef3, rs3, cl3)
op4 = f_operator(ef4, rs4, cl4)
vel1 = f_velocity(rs1)
vel2 = f_velocity(rs2)
vel3 = f_velocity(rs3)
vel4 = f_velocity(rs4)
ofs1 = f_of_state(rv1, rs1, cl1, acU1, acD1)
ofs2 = f_of_state(rv2, rs2, cl2, acU2, acD2)
ofs3 = f_of_state(rv3, rs3, cl3, acU3, acD3)
ofs4 = f_of_state(rv4, rs4, cl4, acU4, acD4)
ib1 = f_ib_state(cl1)
ib2 = f_ib_state(cl2)
ib3 = f_ib_state(cl3)
ib4 = f_ib_state(cl4)
absUpQty1 = f_absorb_qty(ef1, rs1, cl1, rv1, true)
absUpQty2 = f_absorb_qty(ef2, rs2, cl2, rv2, true)
absUpQty3 = f_absorb_qty(ef3, rs3, cl3, rv3, true)
absUpQty4 = f_absorb_qty(ef4, rs4, cl4, rv4, true)
absDnQty1 = f_absorb_qty(ef1, rs1, cl1, rv1, false)
absDnQty2 = f_absorb_qty(ef2, rs2, cl2, rv2, false)
absDnQty3 = f_absorb_qty(ef3, rs3, cl3, rv3, false)
absDnQty4 = f_absorb_qty(ef4, rs4, cl4, rv4, false)
absUpSpd1 = f_absorb_speed(absUpQty1)
absUpSpd2 = f_absorb_speed(absUpQty2)
absUpSpd3 = f_absorb_speed(absUpQty3)
absUpSpd4 = f_absorb_speed(absUpQty4)
absDnSpd1 = f_absorb_speed(absDnQty1)
absDnSpd2 = f_absorb_speed(absDnQty2)
absDnSpd3 = f_absorb_speed(absDnQty3)
absDnSpd4 = f_absorb_speed(absDnQty4)
absRate1 = f_absorb_rating(absUpQty1, absDnQty1, absUpSpd1, absDnSpd1)
absRate2 = f_absorb_rating(absUpQty2, absDnQty2, absUpSpd2, absDnSpd2)
absRate3 = f_absorb_rating(absUpQty3, absDnQty3, absUpSpd3, absDnSpd3)
absRate4 = f_absorb_rating(absUpQty4, absDnQty4, absUpSpd4, absDnSpd4)
demandPower1 = f_level_power(true, dirEr1, er1, rv1, ef1, cl1, distSup1Atr, acU1, acD1, bal1)
demandPower2 = f_level_power(true, dirEr2, er2, rv2, ef2, cl2, distSup2Atr, acU2, acD2, bal2)
demandPower3 = f_level_power(true, dirEr3, er3, rv3, ef3, cl3, distSup3Atr, acU3, acD3, bal3)
demandPower4 = f_level_power(true, dirEr4, er4, rv4, ef4, cl4, distSup4Atr, acU4, acD4, bal4)
supplyPower1 = f_level_power(false, dirEr1, er1, rv1, ef1, cl1, distRes1Atr, acU1, acD1, bal1)
supplyPower2 = f_level_power(false, dirEr2, er2, rv2, ef2, cl2, distRes2Atr, acU2, acD2, bal2)
supplyPower3 = f_level_power(false, dirEr3, er3, rv3, ef3, cl3, distRes3Atr, acU3, acD3, bal3)
supplyPower4 = f_level_power(false, dirEr4, er4, rv4, ef4, cl4, distRes4Atr, acU4, acD4, bal4)
acceptText1 = acU1 == 1.0 ? "UP" : acD1 == 1.0 ? "DN" : "NO"
acceptText2 = acU2 == 1.0 ? "UP" : acD2 == 1.0 ? "DN" : "NO"
acceptText3 = acU3 == 1.0 ? "UP" : acD3 == 1.0 ? "DN" : "NO"
acceptText4 = acU4 == 1.0 ? "UP" : acD4 == 1.0 ? "DN" : "NO"
supportNear = math.min(math.min(distSup1Atr, distSup2Atr), math.min(distSup3Atr, distSup4Atr))
resistanceNear = math.min(math.min(distRes1Atr, distRes2Atr), math.min(distRes3Atr, distRes4Atr))
score1 = math.min(distSup1Atr, distRes1Atr)
score2 = math.min(distSup2Atr, distRes2Atr)
score3 = math.min(distSup3Atr, distRes3Atr)
score4 = math.min(distSup4Atr, distRes4Atr)
nearestTf = tf1
nearestTf := f_pick_nearest_tf(nearestTf, score1, tf2, score2)
nearestTf := f_pick_nearest_tf(nearestTf, math.min(score1, score2), tf3, score3)
nearestTf := f_pick_nearest_tf(nearestTf, math.min(math.min(score1, score2), score3), tf4, score4)
bullPressureScore = (math.max(ef1, 0) * rv1 + math.max(ef2, 0) * rv2 + math.max(ef3, 0) * rv3 + math.max(ef4, 0) * rv4) / 4.0
bearPressureScore = (math.max(-ef1, 0) * rv1 + math.max(-ef2, 0) * rv2 + math.max(-ef3, 0) * rv3 + math.max(-ef4, 0) * rv4) / 4.0
pressureText = bullPressureScore > bearPressureScore * 1.15 ? "BUY" : bearPressureScore > bullPressureScore * 1.15 ? "SELL" : "NEUTRAL"
agreementCount = f_bool_int(trend1 == trend2) + f_bool_int(trend2 == trend3) + f_bool_int(trend3 == trend4)
agreementText = agreementCount >= 3 ? "STRONG" : agreementCount == 2 ? "GOOD" : agreementCount == 1 ? "MIXED" : "WEAK"
outcomeText = supportNear <= supportNearAtr and pressureText == "BUY" ? "SUPPORT BOUNCE" :
supportNear <= supportNearAtr and pressureText == "SELL" ? "SUPPORT BREAK?" :
resistanceNear <= supportNearAtr and pressureText == "BUY" ? "RES BREAK?" :
resistanceNear <= supportNearAtr and pressureText == "SELL" ? "RES REJECT" :
math.max(math.max(rv1, rv2), math.max(rv3, rv4)) < activeThresh ? "COMPRESS" : "WAIT"
nearestSupport = supportNear == distSup1Atr ? lo1 : supportNear == distSup2Atr ? lo2 : supportNear == distSup3Atr ? lo3 : lo4
nearestResistance = resistanceNear == distRes1Atr ? hi1 : resistanceNear == distRes2Atr ? hi2 : resistanceNear == distRes3Atr ? hi3 : hi4
nearestSupportTf = tf1
nearestSupportTf := f_pick_nearest_tf(nearestSupportTf, distSup1Atr, tf2, distSup2Atr)
nearestSupportTf := f_pick_nearest_tf(nearestSupportTf, math.min(distSup1Atr, distSup2Atr), tf3, distSup3Atr)
nearestSupportTf := f_pick_nearest_tf(nearestSupportTf, math.min(math.min(distSup1Atr, distSup2Atr), distSup3Atr), tf4, distSup4Atr)
nearestResistanceTf = tf1
nearestResistanceTf := f_pick_nearest_tf(nearestResistanceTf, distRes1Atr, tf2, distRes2Atr)
nearestResistanceTf := f_pick_nearest_tf(nearestResistanceTf, math.min(distRes1Atr, distRes2Atr), tf3, distRes3Atr)
nearestResistanceTf := f_pick_nearest_tf(nearestResistanceTf, math.min(math.min(distRes1Atr, distRes2Atr), distRes3Atr), tf4, distRes4Atr)
nearestSideText = supportNear < resistanceNear ? "NEAR SUPPORT" : resistanceNear < supportNear ? "NEAR RESISTANCE" : "MID RANGE"
nearSupportText = nearestSupportTf + "@" + str.tostring(nearestSupport, format.mintick) + " (" + str.tostring(supportNear, "#.00") + ")"
nearResistanceText = nearestResistanceTf + "@" + str.tostring(nearestResistance, format.mintick) + " (" + str.tostring(resistanceNear, "#.00") + ")"
tfWeight1 = 0.18
tfWeight2 = 0.22
tfWeight3 = 0.27
tfWeight4 = 0.33
weightSum = tfWeight1 + tfWeight2 + tfWeight3 + tfWeight4
weightedDemandPower = ((demandPower1 * tfWeight1) + (demandPower2 * tfWeight2) + (demandPower3 * tfWeight3) + (demandPower4 * tfWeight4)) / weightSum
weightedSupplyPower = ((supplyPower1 * tfWeight1) + (supplyPower2 * tfWeight2) + (supplyPower3 * tfWeight3) + (supplyPower4 * tfWeight4)) / weightSum
nearestSupportPower = nearestSupportTf == tf1 ? demandPower1 : nearestSupportTf == tf2 ? demandPower2 : nearestSupportTf == tf3 ? demandPower3 : demandPower4
nearestResistancePower = nearestResistanceTf == tf1 ? supplyPower1 : nearestResistanceTf == tf2 ? supplyPower2 : nearestResistanceTf == tf3 ? supplyPower3 : supplyPower4
dailyErText = str.tostring(dirEr1, "#.00") + " / " + str.tostring(er1, "#.00")
nearestSupportPowerText = "D " + str.tostring(math.round(nearestSupportPower))
nearestResistancePowerText = "S " + str.tostring(math.round(nearestResistancePower))
weightedDsText = "D" + str.tostring(math.round(weightedDemandPower)) + " | S" + str.tostring(math.round(weightedSupplyPower))
weightedDsBias = f_ds_bias_text(weightedDemandPower, weightedSupplyPower)
ltpBg = close >= open ? color.new(color.lime, 20) : color.new(color.red, 20)
plot(showNearestLevels ? nearestSupport : na, "Nearest Support", color=color.new(supportColor, 0), linewidth=2, style=plot.style_linebr)
plot(showNearestLevels ? nearestResistance : na, "Nearest Resistance", color=color.new(resistanceColor, 0), linewidth=2, style=plot.style_linebr)
plot(showAllTfLevels ? lo1 : na, "TF1 Support", color=color.new(supportColor, 72), linewidth=1, style=plot.style_linebr)
plot(showAllTfLevels ? hi1 : na, "TF1 Resistance", color=color.new(resistanceColor, 72), linewidth=1, style=plot.style_linebr)
plot(showAllTfLevels ? lo2 : na, "TF2 Support", color=color.new(supportColor, 64), linewidth=1, style=plot.style_linebr)
plot(showAllTfLevels ? hi2 : na, "TF2 Resistance", color=color.new(resistanceColor, 64), linewidth=1, style=plot.style_linebr)
plot(showAllTfLevels ? lo3 : na, "TF3 Support", color=color.new(supportColor, 56), linewidth=1, style=plot.style_linebr)
plot(showAllTfLevels ? hi3 : na, "TF3 Resistance", color=color.new(resistanceColor, 56), linewidth=1, style=plot.style_linebr)
plot(showAllTfLevels ? lo4 : na, "TF4 Support", color=color.new(supportColor, 48), linewidth=1, style=plot.style_linebr)
plot(showAllTfLevels ? hi4 : na, "TF4 Resistance", color=color.new(resistanceColor, 48), linewidth=1, style=plot.style_linebr)
panelPos = panelCorner == "Top Left" ? position.top_left : panelCorner == "Bottom Left" ? position.bottom_left : panelCorner == "Bottom Right" ? position.bottom_right : position.top_right
var table t = table.new(panelPos, 30, 7, bgcolor=color.new(color.black, 84), frame_color=color.new(color.white, 75), border_color=color.new(color.white, 80))
if barstate.islast
table.cell(t, 0, 0, "VERY LONG TERM", text_color=color.white, bgcolor=color.new(color.blue, 70))
table.cell(t, 1, 0, "LTP", text_color=color.white)
table.cell(t, 2, 0, str.tostring(close, format.mintick), text_color=color.white, bgcolor=ltpBg)
table.cell(t, 3, 0, nearestSideText, text_color=color.white, bgcolor=f_bias_color(nearestSideText == "NEAR SUPPORT" ? "BOUNCE" : nearestSideText == "NEAR RESISTANCE" ? "REJECT" : "COMPRESS"))
table.cell(t, 4, 0, nearestTf, text_color=color.white)
table.cell(t, 5, 0, "Near S", text_color=color.white)
table.cell(t, 6, 0, nearSupportText, text_color=color.white, bgcolor=color.new(supportColor, 75), text_halign=text.align_left)
table.cell(t, 7, 0, "Near R", text_color=color.white)
table.cell(t, 8, 0, nearResistanceText, text_color=color.white, bgcolor=color.new(resistanceColor, 75), text_halign=text.align_left)
table.cell(t, 9, 0, "Outcome", text_color=color.white)
table.cell(t, 10, 0, outcomeText, text_color=color.white, bgcolor=f_bias_color(outcomeText), text_halign=text.align_left)
table.cell(t, 11, 0, pressureText, text_color=color.white, bgcolor=f_bias_color(pressureText))
table.cell(t, 12, 0, "Agree", text_color=color.white)
table.cell(t, 13, 0, agreementText, text_color=color.white, bgcolor=f_bias_color(agreementText == "STRONG" ? "BOUNCE" : agreementText == "WEAK" ? "REJECT" : "MIXED"))
table.cell(t, 14, 0, "Range " + str.tostring(rangeLookback), text_color=color.white)
table.cell(t, 15, 0, "Near " + str.tostring(supportNearAtr, "#.00") + " ATR", text_color=color.white, text_halign=text.align_left)
table.cell(t, 16, 0, "S/R Levels", text_color=color.white)
table.cell(t, 17, 0, "Support + Resistance", text_color=color.white, text_halign=text.align_left)
table.cell(t, 18, 0, "State", text_color=color.white)
table.cell(t, 19, 0, "Balance %", text_color=color.white)
table.cell(t, 20, 0, "Absorb", text_color=color.white)
table.cell(t, 21, 0, "Qty + Speed", text_color=color.white, text_halign=text.align_left)
table.cell(t, 22, 0, "AbsRate", text_color=color.white)
table.cell(t, 23, 0, "1D ER", text_color=color.white)
table.cell(t, 24, 0, dailyErText, text_color=color.white, bgcolor=f_bias_color(dirEr1 > 0 ? "BUY" : dirEr1 < 0 ? "SELL" : "COMPRESS"))
table.cell(t, 25, 0, erReg1, text_color=color.white, bgcolor=f_er_regime_color(erReg1))
table.cell(t, 26, 0, "NS/NR", text_color=color.white)
table.cell(t, 27, 0, nearestSupportPowerText + " | " + nearestResistancePowerText, text_color=color.white, bgcolor=nearestSupportPower >= nearestResistancePower ? f_power_color(nearestSupportPower, true) : f_power_color(nearestResistancePower, false), text_halign=text.align_left)
table.cell(t, 28, 0, "D/S", text_color=color.white)
table.cell(t, 29, 0, weightedDsBias, text_color=color.white, bgcolor=weightedDemandPower >= weightedSupplyPower ? f_power_color(weightedDemandPower, true) : f_power_color(weightedSupplyPower, false), text_halign=text.align_left)
table.cell(t, 0, 1, "TF", text_color=color.white)
table.cell(t, 1, 1, "Trend", text_color=color.white)
table.cell(t, 2, 1, "RVOL", text_color=color.white)
table.cell(t, 3, 1, "Eff", text_color=color.white)
table.cell(t, 4, 1, "Support", text_color=color.white)
table.cell(t, 5, 1, "Resistance", text_color=color.white)
table.cell(t, 6, 1, "Dist S", text_color=color.white)
table.cell(t, 7, 1, "Dist R", text_color=color.white)
table.cell(t, 8, 1, "Press", text_color=color.white)
table.cell(t, 9, 1, "Read", text_color=color.white)
table.cell(t, 10, 1, "Res", text_color=color.white)
table.cell(t, 11, 1, "E/R", text_color=color.white)
table.cell(t, 12, 1, "Acc", text_color=color.white)
table.cell(t, 13, 1, "CloseQ", text_color=color.white)
table.cell(t, 14, 1, "Operator", text_color=color.white)
table.cell(t, 15, 1, "AbsUpQ", text_color=color.white)
table.cell(t, 16, 1, "AbsDnQ", text_color=color.white)
table.cell(t, 17, 1, "UpSpd", text_color=color.white)
table.cell(t, 18, 1, "DnSpd", text_color=color.white)
table.cell(t, 19, 1, "AbsRate", text_color=color.white)
table.cell(t, 20, 1, "Vel", text_color=color.white)
table.cell(t, 21, 1, "OF", text_color=color.white)
table.cell(t, 22, 1, "IB", text_color=color.white)
table.cell(t, 23, 1, "Dir E/R", text_color=color.white)
table.cell(t, 24, 1, "State", text_color=color.white)
table.cell(t, 25, 1, "Bal %", text_color=color.white)
table.cell(t, 26, 1, "ER Reg", text_color=color.white)
table.cell(t, 27, 1, "D/S Pow", text_color=color.white)
table.cell(t, 28, 1, "D Pwr", text_color=color.white)
table.cell(t, 29, 1, "S Pwr", text_color=color.white)
table.cell(t, 0, 2, tf1, text_color=color.white)
table.cell(t, 1, 2, trend1, text_color=color.white, bgcolor=f_bias_color(trend1))
table.cell(t, 2, 2, str.tostring(rv1, "#.00"), text_color=color.white, bgcolor=f_rvol_color(rv1))
table.cell(t, 3, 2, str.tostring(ef1, "#.00"), text_color=color.white, bgcolor=f_bias_color(ef1 > effortThreshold ? "BUY" : ef1 < -effortThreshold ? "SELL" : "COMPRESS"))
table.cell(t, 4, 2, str.tostring(lo1, format.mintick), text_color=color.white)
table.cell(t, 5, 2, str.tostring(hi1, format.mintick), text_color=color.white)
table.cell(t, 6, 2, str.tostring(distSup1Atr, "#.00"), text_color=color.white)
table.cell(t, 7, 2, str.tostring(distRes1Atr, "#.00"), text_color=color.white)
table.cell(t, 8, 2, press1, text_color=color.white)
table.cell(t, 9, 2, out1, text_color=color.white, bgcolor=f_bias_color(out1))
table.cell(t, 10, 2, harm1 + " " + str.tostring(rs1, "#.00"), text_color=color.white)
table.cell(t, 11, 2, str.tostring(er1, "#.00"), text_color=color.white)
table.cell(t, 12, 2, acceptText1, text_color=color.white, bgcolor=f_bias_color(acceptText1 == "UP" ? "BOUNCE" : acceptText1 == "DN" ? "REJECT" : "COMPRESS"))
table.cell(t, 13, 2, closeQ1, text_color=color.white)
table.cell(t, 14, 2, op1, text_color=color.white, bgcolor=f_bias_color(op1 == "EXPAND UP" ? "BOUNCE" : op1 == "EXPAND DN" ? "REJECT" : op1 == "ABSORB UP" or op1 == "ABSORB DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 15, 2, str.tostring(absUpQty1, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absUpQty1))
table.cell(t, 16, 2, str.tostring(absDnQty1, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absDnQty1))
table.cell(t, 17, 2, str.tostring(absUpSpd1, "#.00"), text_color=color.white, bgcolor=f_speed_color(absUpSpd1))
table.cell(t, 18, 2, str.tostring(absDnSpd1, "#.00"), text_color=color.white, bgcolor=f_speed_color(absDnSpd1))
table.cell(t, 19, 2, absRate1, text_color=color.white, bgcolor=f_rating_color(absRate1))
table.cell(t, 20, 2, vel1, text_color=color.white)
table.cell(t, 21, 2, ofs1, text_color=color.white, bgcolor=f_bias_color(ofs1 == "AGGR UP" ? "BOUNCE" : ofs1 == "AGGR DN" ? "REJECT" : ofs1 == "PASSIVE UP" or ofs1 == "PASSIVE DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 22, 2, ib1, text_color=color.white)
table.cell(t, 23, 2, str.tostring(dirEr1, "#.00"), text_color=color.white, bgcolor=f_bias_color(dirEr1 > 0 ? "BOUNCE" : dirEr1 < 0 ? "REJECT" : "COMPRESS"))
table.cell(t, 24, 2, state1, text_color=color.white, bgcolor=f_bias_color(state1 == "IMB UP" ? "BOUNCE" : state1 == "IMB DN" ? "REJECT" : state1 == "BALANCE" ? "COMPRESS" : "MIXED"))
table.cell(t, 25, 2, str.tostring(math.round(bal1 * 100.0)) + "%", text_color=color.white)
table.cell(t, 26, 2, erReg1, text_color=color.white, bgcolor=f_er_regime_color(erReg1))
table.cell(t, 27, 2, f_ds_cell_text(demandPower1, supplyPower1), text_color=color.white)
table.cell(t, 28, 2, str.tostring(math.round(demandPower1)), text_color=color.white, bgcolor=f_power_color(demandPower1, true))
table.cell(t, 29, 2, str.tostring(math.round(supplyPower1)), text_color=color.white, bgcolor=f_power_color(supplyPower1, false))
table.cell(t, 0, 3, tf2, text_color=color.white)
table.cell(t, 1, 3, trend2, text_color=color.white, bgcolor=f_bias_color(trend2))
table.cell(t, 2, 3, str.tostring(rv2, "#.00"), text_color=color.white, bgcolor=f_rvol_color(rv2))
table.cell(t, 3, 3, str.tostring(ef2, "#.00"), text_color=color.white, bgcolor=f_bias_color(ef2 > effortThreshold ? "BUY" : ef2 < -effortThreshold ? "SELL" : "COMPRESS"))
table.cell(t, 4, 3, str.tostring(lo2, format.mintick), text_color=color.white)
table.cell(t, 5, 3, str.tostring(hi2, format.mintick), text_color=color.white)
table.cell(t, 6, 3, str.tostring(distSup2Atr, "#.00"), text_color=color.white)
table.cell(t, 7, 3, str.tostring(distRes2Atr, "#.00"), text_color=color.white)
table.cell(t, 8, 3, press2, text_color=color.white)
table.cell(t, 9, 3, out2, text_color=color.white, bgcolor=f_bias_color(out2))
table.cell(t, 10, 3, harm2 + " " + str.tostring(rs2, "#.00"), text_color=color.white)
table.cell(t, 11, 3, str.tostring(er2, "#.00"), text_color=color.white)
table.cell(t, 12, 3, acceptText2, text_color=color.white, bgcolor=f_bias_color(acceptText2 == "UP" ? "BOUNCE" : acceptText2 == "DN" ? "REJECT" : "COMPRESS"))
table.cell(t, 13, 3, closeQ2, text_color=color.white)
table.cell(t, 14, 3, op2, text_color=color.white, bgcolor=f_bias_color(op2 == "EXPAND UP" ? "BOUNCE" : op2 == "EXPAND DN" ? "REJECT" : op2 == "ABSORB UP" or op2 == "ABSORB DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 15, 3, str.tostring(absUpQty2, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absUpQty2))
table.cell(t, 16, 3, str.tostring(absDnQty2, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absDnQty2))
table.cell(t, 17, 3, str.tostring(absUpSpd2, "#.00"), text_color=color.white, bgcolor=f_speed_color(absUpSpd2))
table.cell(t, 18, 3, str.tostring(absDnSpd2, "#.00"), text_color=color.white, bgcolor=f_speed_color(absDnSpd2))
table.cell(t, 19, 3, absRate2, text_color=color.white, bgcolor=f_rating_color(absRate2))
table.cell(t, 20, 3, vel2, text_color=color.white)
table.cell(t, 21, 3, ofs2, text_color=color.white, bgcolor=f_bias_color(ofs2 == "AGGR UP" ? "BOUNCE" : ofs2 == "AGGR DN" ? "REJECT" : ofs2 == "PASSIVE UP" or ofs2 == "PASSIVE DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 22, 3, ib2, text_color=color.white)
table.cell(t, 23, 3, str.tostring(dirEr2, "#.00"), text_color=color.white, bgcolor=f_bias_color(dirEr2 > 0 ? "BOUNCE" : dirEr2 < 0 ? "REJECT" : "COMPRESS"))
table.cell(t, 24, 3, state2, text_color=color.white, bgcolor=f_bias_color(state2 == "IMB UP" ? "BOUNCE" : state2 == "IMB DN" ? "REJECT" : state2 == "BALANCE" ? "COMPRESS" : "MIXED"))
table.cell(t, 25, 3, str.tostring(math.round(bal2 * 100.0)) + "%", text_color=color.white)
table.cell(t, 26, 3, erReg2, text_color=color.white, bgcolor=f_er_regime_color(erReg2))
table.cell(t, 27, 3, f_ds_cell_text(demandPower2, supplyPower2), text_color=color.white)
table.cell(t, 28, 3, str.tostring(math.round(demandPower2)), text_color=color.white, bgcolor=f_power_color(demandPower2, true))
table.cell(t, 29, 3, str.tostring(math.round(supplyPower2)), text_color=color.white, bgcolor=f_power_color(supplyPower2, false))
table.cell(t, 0, 4, tf3, text_color=color.white)
table.cell(t, 1, 4, trend3, text_color=color.white, bgcolor=f_bias_color(trend3))
table.cell(t, 2, 4, str.tostring(rv3, "#.00"), text_color=color.white, bgcolor=f_rvol_color(rv3))
table.cell(t, 3, 4, str.tostring(ef3, "#.00"), text_color=color.white, bgcolor=f_bias_color(ef3 > effortThreshold ? "BUY" : ef3 < -effortThreshold ? "SELL" : "COMPRESS"))
table.cell(t, 4, 4, str.tostring(lo3, format.mintick), text_color=color.white)
table.cell(t, 5, 4, str.tostring(hi3, format.mintick), text_color=color.white)
table.cell(t, 6, 4, str.tostring(distSup3Atr, "#.00"), text_color=color.white)
table.cell(t, 7, 4, str.tostring(distRes3Atr, "#.00"), text_color=color.white)
table.cell(t, 8, 4, press3, text_color=color.white)
table.cell(t, 9, 4, out3, text_color=color.white, bgcolor=f_bias_color(out3))
table.cell(t, 10, 4, harm3 + " " + str.tostring(rs3, "#.00"), text_color=color.white)
table.cell(t, 11, 4, str.tostring(er3, "#.00"), text_color=color.white)
table.cell(t, 12, 4, acceptText3, text_color=color.white, bgcolor=f_bias_color(acceptText3 == "UP" ? "BOUNCE" : acceptText3 == "DN" ? "REJECT" : "COMPRESS"))
table.cell(t, 13, 4, closeQ3, text_color=color.white)
table.cell(t, 14, 4, op3, text_color=color.white, bgcolor=f_bias_color(op3 == "EXPAND UP" ? "BOUNCE" : op3 == "EXPAND DN" ? "REJECT" : op3 == "ABSORB UP" or op3 == "ABSORB DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 15, 4, str.tostring(absUpQty3, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absUpQty3))
table.cell(t, 16, 4, str.tostring(absDnQty3, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absDnQty3))
table.cell(t, 17, 4, str.tostring(absUpSpd3, "#.00"), text_color=color.white, bgcolor=f_speed_color(absUpSpd3))
table.cell(t, 18, 4, str.tostring(absDnSpd3, "#.00"), text_color=color.white, bgcolor=f_speed_color(absDnSpd3))
table.cell(t, 19, 4, absRate3, text_color=color.white, bgcolor=f_rating_color(absRate3))
table.cell(t, 20, 4, vel3, text_color=color.white)
table.cell(t, 21, 4, ofs3, text_color=color.white, bgcolor=f_bias_color(ofs3 == "AGGR UP" ? "BOUNCE" : ofs3 == "AGGR DN" ? "REJECT" : ofs3 == "PASSIVE UP" or ofs3 == "PASSIVE DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 22, 4, ib3, text_color=color.white)
table.cell(t, 23, 4, str.tostring(dirEr3, "#.00"), text_color=color.white, bgcolor=f_bias_color(dirEr3 > 0 ? "BOUNCE" : dirEr3 < 0 ? "REJECT" : "COMPRESS"))
table.cell(t, 24, 4, state3, text_color=color.white, bgcolor=f_bias_color(state3 == "IMB UP" ? "BOUNCE" : state3 == "IMB DN" ? "REJECT" : state3 == "BALANCE" ? "COMPRESS" : "MIXED"))
table.cell(t, 25, 4, str.tostring(math.round(bal3 * 100.0)) + "%", text_color=color.white)
table.cell(t, 26, 4, erReg3, text_color=color.white, bgcolor=f_er_regime_color(erReg3))
table.cell(t, 27, 4, f_ds_cell_text(demandPower3, supplyPower3), text_color=color.white)
table.cell(t, 28, 4, str.tostring(math.round(demandPower3)), text_color=color.white, bgcolor=f_power_color(demandPower3, true))
table.cell(t, 29, 4, str.tostring(math.round(supplyPower3)), text_color=color.white, bgcolor=f_power_color(supplyPower3, false))
table.cell(t, 0, 5, tf4, text_color=color.white)
table.cell(t, 1, 5, trend4, text_color=color.white, bgcolor=f_bias_color(trend4))
table.cell(t, 2, 5, str.tostring(rv4, "#.00"), text_color=color.white, bgcolor=f_rvol_color(rv4))
table.cell(t, 3, 5, str.tostring(ef4, "#.00"), text_color=color.white, bgcolor=f_bias_color(ef4 > effortThreshold ? "BUY" : ef4 < -effortThreshold ? "SELL" : "COMPRESS"))
table.cell(t, 4, 5, str.tostring(lo4, format.mintick), text_color=color.white)
table.cell(t, 5, 5, str.tostring(hi4, format.mintick), text_color=color.white)
table.cell(t, 6, 5, str.tostring(distSup4Atr, "#.00"), text_color=color.white)
table.cell(t, 7, 5, str.tostring(distRes4Atr, "#.00"), text_color=color.white)
table.cell(t, 8, 5, press4, text_color=color.white)
table.cell(t, 9, 5, out4, text_color=color.white, bgcolor=f_bias_color(out4))
table.cell(t, 10, 5, harm4 + " " + str.tostring(rs4, "#.00"), text_color=color.white)
table.cell(t, 11, 5, str.tostring(er4, "#.00"), text_color=color.white)
table.cell(t, 12, 5, acceptText4, text_color=color.white, bgcolor=f_bias_color(acceptText4 == "UP" ? "BOUNCE" : acceptText4 == "DN" ? "REJECT" : "COMPRESS"))
table.cell(t, 13, 5, closeQ4, text_color=color.white)
table.cell(t, 14, 5, op4, text_color=color.white, bgcolor=f_bias_color(op4 == "EXPAND UP" ? "BOUNCE" : op4 == "EXPAND DN" ? "REJECT" : op4 == "ABSORB UP" or op4 == "ABSORB DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 15, 5, str.tostring(absUpQty4, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absUpQty4))
table.cell(t, 16, 5, str.tostring(absDnQty4, "#.00"), text_color=color.white, bgcolor=f_absorb_color(absDnQty4))
table.cell(t, 17, 5, str.tostring(absUpSpd4, "#.00"), text_color=color.white, bgcolor=f_speed_color(absUpSpd4))
table.cell(t, 18, 5, str.tostring(absDnSpd4, "#.00"), text_color=color.white, bgcolor=f_speed_color(absDnSpd4))
table.cell(t, 19, 5, absRate4, text_color=color.white, bgcolor=f_rating_color(absRate4))
table.cell(t, 20, 5, vel4, text_color=color.white)
table.cell(t, 21, 5, ofs4, text_color=color.white, bgcolor=f_bias_color(ofs4 == "AGGR UP" ? "BOUNCE" : ofs4 == "AGGR DN" ? "REJECT" : ofs4 == "PASSIVE UP" or ofs4 == "PASSIVE DN" ? "COMPRESS" : "MIXED"))
table.cell(t, 22, 5, ib4, text_color=color.white)
table.cell(t, 23, 5, str.tostring(dirEr4, "#.00"), text_color=color.white, bgcolor=f_bias_color(dirEr4 > 0 ? "BOUNCE" : dirEr4 < 0 ? "REJECT" : "COMPRESS"))
table.cell(t, 24, 5, state4, text_color=color.white, bgcolor=f_bias_color(state4 == "IMB UP" ? "BOUNCE" : state4 == "IMB DN" ? "REJECT" : state4 == "BALANCE" ? "COMPRESS" : "MIXED"))
table.cell(t, 25, 5, str.tostring(math.round(bal4 * 100.0)) + "%", text_color=color.white)
table.cell(t, 26, 5, erReg4, text_color=color.white, bgcolor=f_er_regime_color(erReg4))
table.cell(t, 27, 5, f_ds_cell_text(demandPower4, supplyPower4), text_color=color.white)
table.cell(t, 28, 5, str.tostring(math.round(demandPower4)), text_color=color.white, bgcolor=f_power_color(demandPower4, true))
table.cell(t, 29, 5, str.tostring(math.round(supplyPower4)), text_color=color.white, bgcolor=f_power_color(supplyPower4, false))
table.cell(t, 0, 6, "Near", text_color=color.white)
table.cell(t, 1, 6, supportNear < resistanceNear ? "Support" : "Resistance", text_color=color.white)
table.cell(t, 2, 6, "S", text_color=color.white)
table.cell(t, 3, 6, str.tostring(supportNear, "#.00"), text_color=color.white)
table.cell(t, 4, 6, "R", text_color=color.white)
table.cell(t, 5, 6, str.tostring(resistanceNear, "#.00"), text_color=color.white)
table.cell(t, 6, 6, "Thr", text_color=color.white)
table.cell(t, 7, 6, str.tostring(activeThresh, "#.00") + " / " + str.tostring(hotThresh, "#.00") + " / " + str.tostring(extremeThresh, "#.00"), text_color=color.white, text_halign=text.align_left)
table.cell(t, 8, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 9, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 10, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 11, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 12, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 13, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 14, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 15, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 16, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 17, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 18, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 19, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 20, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 21, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 22, 6, "", bgcolor=color.new(color.black, 84))
table.cell(t, 23, 6, "1D Reg", text_color=color.white)
table.cell(t, 24, 6, erReg1, text_color=color.white, bgcolor=f_er_regime_color(erReg1))
table.cell(t, 25, 6, weightedDsText, text_color=color.white, bgcolor=weightedDemandPower >= weightedSupplyPower ? f_power_color(weightedDemandPower, true) : f_power_color(weightedSupplyPower, false), text_halign=text.align_left)
table.cell(t, 26, 6, "NS", text_color=color.white)
table.cell(t, 27, 6, nearestSupportPowerText, text_color=color.white, bgcolor=f_power_color(nearestSupportPower, true))
table.cell(t, 28, 6, "NR", text_color=color.white)
table.cell(t, 29, 6, nearestResistancePowerText, text_color=color.white, bgcolor=f_power_color(nearestResistancePower, false))
Show all 621 lines