RedK EVEREX - Effort Versus Results Explorer for ThinkOrSwim

samer800

Conversion Expert
VIP
Lifetime
7LpEc5h.png


Creator Message: https://www.tradingview.com/v/I5qJDPxT/

CODE:

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © RedKTrader - March 2023
#// https://www.tradingview.com/v/I5qJDPxT/
#// inspecting the effort vs result concept by plotting volume vs. price change
#// this is like looking at distance versus fuel consumption - but comparing a normalized average of each
#// to help reveal areas of volume & price action anomalies, contraction & expansion
#indicator('RedK Effort Versus Results Explorer', 'RedK EVEREX v1.0', precision = 0,
# Converted and mod by Sam4Cok@Samer800        - 03/2023
declare lower;
input UseChartTimeframe = yes;
input CustomAggregation = AggregationPeriod.FIFTEEN_MIN;
input DisplayType = {Default EVEREX, Bias, Both};
input ColorBars   = yes;
input BiasLabel   = yes;
input Signal_Line = yes;
input rofLine     = yes;
input bandScale   = {default "100", "200", "400"};          # "Band Scale"
input LookbackCalcType = {default "Simple", "Same as RRoF"}; # 'Lookback Averaging Type'
input lookback    = 20;  # 'lookback'
input RofType     = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};    # 'MA type'
input RofLength   = 10;    # 'ROF Length'
input RofSmooth   = 3;     # 'Smooth'
input SignalType  = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};  # 'Signal Ma Type'
input signalLength = 5;   # 'Signal Length'
input BiasType    = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};      # 'Bias MA type',
input BiasLength  = 30;  # 'Bias Length'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def scale = if bandscale == bandscale."100" then 100 else
            if bandscale == bandscale."200" then 200 else
            if bandscale == bandscale."400" then 400 else scale[1];
def ikbk = LookbackCalcType == LookbackCalcType."Simple";
def DispBias    = DisplayType==DisplayType.Bias or DisplayType==DisplayType.Both;
def DispEVEREX  = DisplayType==DisplayType.EVEREX or DisplayType==DisplayType.Both;
def chartTf = GetAggregationPeriod();
def tf     = if UseChartTimeframe then chartTf else CustomAggregation;
def close  = close(Period=tf);
def high   = high(Period=tf);
def low    = low(Period=tf);
def open   = open(Period=tf);
def volume = volume(Period=tf);

#---- Color
DefineGlobalColor("c_vol_grn" , CreateColor(15, 65, 61));
DefineGlobalColor("b_vol_grn" , CreateColor(33,145,135));
DefineGlobalColor("c_vol_red" , CreateColor(84, 9, 8));
DefineGlobalColor("b_vol_red" , CreateColor(235,37,33));
DefineGlobalColor("c_pri_grn" , CreateColor(13,62,13));
DefineGlobalColor("b_pri_grn" , CreateColor(43,208,43));
DefineGlobalColor("c_pri_red" , CreateColor(83,42,0));
DefineGlobalColor("b_pri_red" , CreateColor(240,122,0));
DefineGlobalColor("c_up" , CreateColor(41,98,255));
DefineGlobalColor("c_dn" , CreateColor(255,152,0));
DefineGlobalColor("green" , CreateColor(0,177,0));
DefineGlobalColor("red"   , CreateColor(177,0,0));
DefineGlobalColor("dgreen" , CreateColor(0,39,0));
DefineGlobalColor("dred"   , CreateColor(59,0,0));
#// --- Functions
#GetAverage(_data, _len, MAOption) =>
script GetAverage {
    input _data = close;
    input _len = 10;
    input MAOption = "SMA";
    def w = wma(_data, _len);
    def mav = ((Average(_data, _len)[1]*(_len-1)) + _data) / _len;
    def GetAverage = if MAOption == "SMA" then Average(_data, _len) else
                     if MAOption == "SMMA" then if isNaN(w[1]) then average(_data, _len) else
                         CompoundValue(1, (w[1] * (_len - 1) + _data) / _len,  average(_data, _len)) else
                     if MAOption == "EMA" then ExpAverage(_data, _len) else
                     if MAOption == "MAV" then mav else              
                     if MAOption == "HMA" then HullMovingAvg(_data, _len) else
                     if MAOption == "RMA" then WildersAverage(_data, _len) else
                     if MAOption == "WMA" then WMA(_data, _len) else Average(_data, _len);
    plot out = GetAverage;
}
#Normalize(_Value, _Avg) =>
script Normalize {
    input _Value = close;
    input _Avg = 10;
    def _X = _Value / _Avg;
    def _Nor =
      if _X > 1.50 then 1.00 else
      if _X > 1.20 then 0.90 else
      if _X > 1.00 then 0.80 else
      if _X > 0.80 then 0.70 else
      if _X > 0.60 then 0.60 else
      if _X > 0.40 then 0.50 else
      if _X > 0.20 then 0.25 else 0.1;
    plot norm = _Nor;
}
#//          Calculations
def v   = if IsNaN(volume) then 1 else volume;
def NoVol_Flag = if IsNaN(volume) then yes else no;#      // this is a flag to use later

def Vola  = if ikbk then Average(v,lookback) else GetAverage(v, lookback, RofType);
def Vola_n_pre = Normalize(v, Vola) * 100;

#//Now trap the case of no volume data - ensure final calculation not impacted
def Vola_n = if NoVol_Flag then 100 else Vola_n_pre;

def BarSpread = close - open;
def BarRange  = high - low;
def R2        = Highest(high, 2) - Lowest(low, 2);
def SrcShift  = close - close[1];
#//TR = ta.tr(true)

def sign_shift = Sign(SrcShift);
def sign_spread = Sign(BarSpread);
#//    in-bar assessments

def barclosing  = 2 * (close - low) / BarRange * 100 - 100;
def s2r = BarSpread / BarRange * 100;

def BarSpread_abs   = AbsValue(BarSpread);
def BarSpread_avg   = if ikbk then Average(BarSpread_abs,lookback) else GetAverage(BarSpread_abs, lookback, RofType);
def BarSpread_ratio_n = Normalize(BarSpread_abs, BarSpread_avg) * 100 * sign_spread ;
#//    2-bar assessments
def barclosing_2  = 2 * (close - Lowest(low, 2)) / R2 * 100 - 100;
def Shift2Bar_toR2 = SrcShift / R2 * 100;
def SrcShift_abs     = AbsValue(SrcShift);
def srcshift_avg     = if ikbk then Average(SrcShift_abs,lookback) else GetAverage(SrcShift_abs, lookback, RofType);
def srcshift_ratio_n = Normalize(SrcShift_abs, srcshift_avg) * 100 * sign_shift;
#/ Relative Price Strength combining all strength elements
def Pricea_n = (barclosing + s2r + BarSpread_ratio_n + barclosing_2 + Shift2Bar_toR2 + srcshift_ratio_n) / 6;# "Price Normalized"
#//Let's take Bar Flow as the combined price strength * the volume:avg ratio
def bar_flow  =   Pricea_n * Vola_n / 100;
#/ Relative Price Strength combining all strength elements
def bulls = Max(bar_flow, 0);
def bears = -1 * Min(bar_flow, 0);

def bulls_avg = GetAverage(bulls, RofLength, RofType);
def bears_avg = GetAverage(bears, RofLength, RofType);
def dx     = bulls_avg / bears_avg;
def RROF   = 2 * (100 - 100 / (1 + dx)) - 100;
def RROF_s = WMA(RROF, RofSmooth);

def Signal = GetAverage(RROF_s, signalLength, SignalType);
#// Calculate Bias / sentiment on longer length
def dx_b    = GetAverage(bulls, BiasLength, BiasType) / GetAverage(bears, BiasLength, BiasType);
def RROF_b  = 2 * (100 - 100 / (1 + dx_b)) - 100;
def RROF_bs = WMA(RROF_b, RofSmooth);
#//      Colors & plots
def up      = RROF_s >= 0;
def s_up    = RROF_bs >= 0;

plot level1 = if last then na else 0.25 * scale; # '1/4 Level'
plot level2 = if last then na else 0.50 * scale; # '2/4 Level'
plot level3 = if last then na else 0.75 * scale; # '3/4 Level'
plot level4 = if last then na else scale;        # '4/4 Level'

level1.SetDefaultColor(Color.GRAY);
level2.SetDefaultColor(Color.GRAY);
level3.SetDefaultColor(Color.GRAY);
level4.SetDefaultColor(Color.GRAY);
level1.SetStyle(Curve.SHORT_DASH);
level2.SetStyle(Curve.SHORT_DASH);
level3.SetStyle(Curve.SHORT_DASH);
level4.SetStyle(Curve.SHORT_DASH);
#// Plot main plot, smoothed plot and signal line

plot RROF_Smooth = if rofLine then RROF_s else na;#, 'RROF Smooth'
#RROF_Smooth.SetLineWeight(2);
RROF_Smooth.SetDefaultColor(Color.WHITE);
plot SignalLine = if Signal_Line then Signal else na;#, "Signal Line"
SignalLine.SetLineWeight(3);
SignalLine.AssignValueColor( if up then GlobalColor("c_up") else GlobalColor("c_dn"));

#// Plot Bias / Sentiment
plot BiasSentiment = if DispBias then RROF_bs else na;#, "Bias / Sentiment"
BiasSentiment.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BiasSentiment.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));

AddLabel(BiasLabel, if RROF_bs>0 then "Bias: UP" else "Bias: DN", if RROF_bs>0 then Color.GREEN else Color.RED);

plot ZeroLine = if last then na else 0;    # 'Zero Line'
ZeroLine.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));
#// =============================================================================
#// Plot Price Strength & Relative Volume as stacked "equalizer bands"

def nPrice  = Max(Min(Pricea_n, 100), -100);
def nVol    = Max(Min(Vola_n, 100), -100);
def bar = bar_flow;
def c_vol  = bar > 0;
def cb_vol = if bar > 0 then 1 else -1;
def vc_lo = if DispEVEREX then 0 else na;
def vc_hi = nVol * scale / 100 / 2;
def pc_lo = if DispEVEREX then vc_hi else na; def pc_hi = vc_hi + AbsValue(nPrice) * scale / 100 / 2;

AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_grn"));
AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_grn"));

AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_red"));
AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_red"));

AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_grn"));
AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_grn"));

AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_red"));
AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_red"));



#-- Background
AddCloud(if up then pos else neg, if up then neg else pos, GlobalColor("dgreen"), GlobalColor("dred"));

#-- Bar Color
def ExtUp = s_up and c_vol;
def ExtDn = !s_up and !c_vol;

AssignPriceColor( if !ColorBars then Color.CURRENT else
                  if ExtUp then Color.GREEN else
                  if s_up then Color.DARK_GREEN else
                  if ExtDn then Color.RED else
                  if !s_up then Color.DARK_RED else Color.GRAY);
               

#--- END CODE
 
Last edited by a moderator:
SignalLine and RRofLine shows only in red or green areas tested in1 min and 5 min
this is a volume accumulated indicator. try to use the indicator in RTH since volume can be very low in none trading hours.
 
I installed this study and added it to my TOS chart, but then noticed that the candle colors on the main chart were changed, reds were now green and vice versa, but not consistently. Then I looked at the original screenshot above and noticed the same. Is there an option to change this script so that it builds the study in the lower pane, but does not affect the candles on the main chart? When I look at the charts posted by the original author for TradingView, I do not see this same affect on the main chart candle color. Thanks!
 
I installed this study and added it to my TOS chart, but then noticed that the candle colors on the main chart were changed, reds were now green and vice versa, but not consistently. Then I looked at the original screenshot above and noticed the same. Is there an option to change this script so that it builds the study in the lower pane, but does not affect the candles on the main chart? When I look at the charts posted by the original author for TradingView, I do not see this same affect on the main chart candle color. Thanks!
not sure what is the exact issue. However, try below code, I just did some minor code change.
still, the results may vary from TV code.

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © RedKTrader - March 2023
#// https://www.tradingview.com/v/I5qJDPxT/
#// inspecting the effort vs result concept by plotting volume vs. price change
#// this is like looking at distance versus fuel consumption - but comparing a normalized average of each
#// to help reveal areas of volume & price action anomalies, contraction & expansion
#indicator('RedK Effort Versus Results Explorer', 'RedK EVEREX v1.0', precision = 0,
# Converted and mod by Sam4Cok@Samer800        - 03/2023
# Update - minor code fixing - 07/2023
declare lower;
input showMarkers = yes;# 'Show EVEREX Markers ?')
input ColorBars   = no;
input UseChartTimeframe = {Default "Yes", "No"};
input CustomAggregation = AggregationPeriod.FIFTEEN_MIN;
input DisplayType = {Default EVEREX, Bias, Both, "Don't Show"};
input BiasLabel   = no;
input Signal_Line = yes;
input rofLine     = yes;
input bandScale   = {default "100", "200", "400"};          # "Band Scale"
input LookbackCalcType = {default "Simple", "Same as RRoF"}; # 'Lookback Averaging Type'
input lookback    = 20;  # 'lookback'
input RofType     = {default WMA, EMA, SMA, HMA, RMA, MAV};    # 'MA type'
input RofLength   = 10;    # 'ROF Length'
input RofSmooth   = 3;     # 'Smooth'
input SignalType  = {default WMA, EMA, SMA, HMA, RMA, MAV};  # 'Signal Ma Type'
input signalLength = 5;   # 'Signal Length'
input BiasType    = {default WMA, EMA, SMA, HMA, RMA, MAV};      # 'Bias MA type',
input BiasLength  = 30;  # 'Bias Length'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def DispBias;
def DispEVEREX;

Switch (DisplayType) {
Case EVEREX :
    DispBias = no;
    DispEVEREX = yes;
Case Bias :
    DispBias = yes;
    DispEVEREX = no;
Case Both :
    DispBias = yes;
    DispEVEREX = yes;
Case "Don't Show" :
    DispBias = no;
    DispEVEREX = no;
}
def scale;
Switch (bandScale) {
Case "100" : scale = 100;
Case "200" : scale = 200;
Case "400" : scale = 400;
}
def c; def h; def l; def o; def vol;
Switch (useChartTimeframe) {
Case "Yes" :
    c = close;
    h = high;
    l = low;
    o = open;
    vol = volume;
Case "No" :
    c = close(Period=CustomAggregation);
    h = high(Period=CustomAggregation);
    l = low(Period=CustomAggregation);
    o = open(Period=CustomAggregation);
    vol = volume(Period=CustomAggregation);
}
#---- Color
DefineGlobalColor("c_vol_grn" , CreateColor(15, 65, 61));
DefineGlobalColor("b_vol_grn" , CreateColor(33,145,135));
DefineGlobalColor("c_vol_red" , CreateColor(84, 9, 8));
DefineGlobalColor("b_vol_red" , CreateColor(235,37,33));
DefineGlobalColor("c_pri_grn" , CreateColor(13,62,13));
DefineGlobalColor("b_pri_grn" , CreateColor(43,208,43));
DefineGlobalColor("c_pri_red" , CreateColor(83,42,0));
DefineGlobalColor("b_pri_red" , CreateColor(240,122,0));
DefineGlobalColor("c_up" , CreateColor(41,98,255));
DefineGlobalColor("c_dn" , CreateColor(255,152,0));
DefineGlobalColor("green" , CreateColor(0,177,0));
DefineGlobalColor("red"   , CreateColor(177,0,0));
DefineGlobalColor("dgreen" , CreateColor(0,59,0));
DefineGlobalColor("dred"   , CreateColor(79,0,0));
#// --- Functions
#GetAverage(_data, _len, MAOption) =>
script GetAverage {
    input _data = close;
    input _len = 10;
    input MAOption = "SMA";
    def mav = ((Average(_data, _len)[1]*(_len-1)) + _data) / _len;
    def GetAverage = if MAOption == "SMA" then Average(_data, _len) else
                     if MAOption == "EMA" then ExpAverage(_data, _len) else
                     if MAOption == "MAV" then mav else               
                     if MAOption == "HMA" then HullMovingAvg(_data, _len) else
                     if MAOption == "RMA" then WildersAverage(_data, _len) else
                     if MAOption == "WMA" then WMA(_data, _len) else Average(_data, _len);
    plot out = GetAverage;
}
#Normalize(_Value, _Avg) =>
script Normalize {
    input _Value = close;
    input _Avg = 10;
    def _X = _Value / _Avg;
    def _Nor =
      if _X > 1.50 then 1.00 else
      if _X > 1.20 then 0.90 else
      if _X > 1.00 then 0.80 else
      if _X > 0.80 then 0.70 else
      if _X > 0.60 then 0.60 else
      if _X > 0.40 then 0.50 else
      if _X > 0.20 then 0.25 else 0.1;
    plot norm = _Nor;
}
#//          Calculations
def v   = if isNaN(vol) then 1 else vol;
def NoVol_Flag = if IsNaN(v) then yes else no;#      // this is a flag to use later
def volSMA =  Average(v,lookback);
def volROFF = GetAverage(v, lookback, RofType);
def Vola;
Switch (LookbackCalcType) {
Case "Simple" : Vola = volSMA;
Case "Same as RRoF" : Vola = volROFF;
}
def Vola_n_pre = Normalize(v, Vola) * 100;

#//Now trap the case of no volume data - ensure final calculation not impacted
def Vola_n = if NoVol_Flag then 100 else Vola_n_pre;

def BarSpread = (c - o);
def hl        = (h - l);
def BarRange  = if hl==0 then BarRange[1] else hl;
def hhll      = Highest(h, 2) - Lowest(l, 2);
def R2        = if hhll==0 then R2[1] else hhll;
def SrcShift  = c - c[1];
#//TR = ta.tr(true)

def sign_shift = Sign(SrcShift);
def sign_spread = Sign(BarSpread);
#//    in-bar assessments
def dif = (c - l);#if (c - l)==0 then dif[1] else (c - l);
def barclosing  = 2 * dif / BarRange * 100 - 100;
def s2r = BarSpread / BarRange * 100;

def BarSpread_abs   = AbsValue(BarSpread);
def barSMA = Average(BarSpread_abs,lookback);
def barROFF = GetAverage(BarSpread_abs, lookback, RofType);
def BarSpread_avg;
Switch (LookbackCalcType) {
Case "Simple" : BarSpread_avg = barSMA;
Case "Same as RRoF" : BarSpread_avg = barROFF;
}
def BarSpread_ratio_n = Normalize(BarSpread_abs, BarSpread_avg) * 100 * sign_spread ;

#//    2-bar assessments
def cl = c - Lowest(l, 2);
def barclosing_2  = 2 * cl / R2 * 100 - 100;
def Shift2Bar_toR2 = SrcShift / R2 * 100;
#// 6. Calculate 2-bar Relative Shift
def SrcShift_abs = AbsValue(SrcShift);
def srcSMA = Average(SrcShift_abs,lookback);
def srcRROF = GetAverage(SrcShift_abs, lookback, RofType);
def srcshift_avg;
Switch (LookbackCalcType) {
Case "Simple" : srcshift_avg = srcSMA;
Case "Same as RRoF" : srcshift_avg = srcRROF;
}
def srcshift_ratio_n = Normalize(SrcShift_abs, srcshift_avg) * 100 * sign_shift;
#/ Relative Price Strength combining all strength elements
def Pricea_n = (barclosing + s2r + BarSpread_ratio_n + barclosing_2 + Shift2Bar_toR2 + srcshift_ratio_n) / 6;
# "Price Normalized"
#//Let's take Bar Flow as the combined price strength * the volume:avg ratio
def bar_flow  =   Pricea_n * Vola_n / 100;
#/ Relative Price Strength combining all strength elements
def bulls = Max(bar_flow, 0);
def bears = -1 * Min(bar_flow, 0);

def bulls_avg = GetAverage(bulls, RofLength, RofType);
def bears_avg = GetAverage(bears, RofLength, RofType);
def dx     = bulls_avg / bears_avg;
def RROF   = 2 * (100 - 100 / (1 + dx)) - 100;
def RROF_s = WMA(RROF, RofSmooth);

def Signal = GetAverage(RROF_s, signalLength, SignalType);
#// Calculate Bias / sentiment on longer length
def bulls_bia = GetAverage(bulls, BiasLength, BiasType);
def bears_bia = GetAverage(bears, BiasLength, BiasType);
def dx_b    = bulls_bia / bears_bia;
def RROF_b  = 2 * (100 - 100 / (1 + dx_b)) - 100;
def RROF_bs = WMA(RROF_b, RofSmooth);
#//      Colors & plots
def up      = RROF_s >= 0;
def s_up    = RROF_bs >= 0;

plot level1 = if last then na else 0.25 * scale; # '1/4 Level'
plot level2 = if last then na else 0.50 * scale; # '2/4 Level'
plot level3 = if last then na else 0.75 * scale; # '3/4 Level'
plot level4 = if last then na else scale;        # '4/4 Level'
plot level5 = if last then na else -0.50 * scale; # '2/4 Level'

level1.SetDefaultColor(Color.DARK_GRAY);
level2.SetDefaultColor(Color.WHITE);
level3.SetDefaultColor(Color.YELLOW);
level4.SetDefaultColor(Color.DARK_GRAY);
level5.SetDefaultColor(Color.WHITE);
level1.SetStyle(Curve.SHORT_DASH);
level2.SetStyle(Curve.SHORT_DASH);
level3.SetPaintingStrategy(PaintingStrategy.DASHES);
level4.SetStyle(Curve.SHORT_DASH);
level5.SetStyle(Curve.SHORT_DASH);
#// Plot main plot, smoothed plot and signal line

plot RROF_Smooth = if rofLine then RROF_s else na;#, 'RROF Smooth'
#RROF_Smooth.SetLineWeight(2);
RROF_Smooth.SetDefaultColor(Color.WHITE);

plot SignalLine = if Signal_Line then Signal else na;#, "Signal Line"
SignalLine.SetLineWeight(2);
SignalLine.AssignValueColor( if up then GlobalColor("c_up") else GlobalColor("c_dn"));

#// Plot Bias / Sentiment
plot BiasSentiment = if DispBias then RROF_bs else na;#, "Bias / Sentiment"
BiasSentiment.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BiasSentiment.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));

#// Zero Line
plot ZeroLine = if last then na else 0;    # 'Zero Line'
ZeroLine.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));
#// =============================================================================
#// Plot Price Strength & Relative Volume as stacked "equalizer bands"

def nPrice  = Max(Min(Pricea_n, 100), -100);
def nVol    = Max(Min(Vola_n, 100), -100);
def bar = bar_flow;
def c_vol  = bar > 0;
def vc_lo = if DispEVEREX then 0 else na;
def vc_hi = nVol * scale / 100 / 2;
def pc_lo = if DispEVEREX then vc_hi else na; def pc_hi = vc_hi + AbsValue(nPrice) * scale / 100 / 2;

AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = if c_vol then pc_lo else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_grn"));
AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = if c_vol then pc_hi else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_grn"));

AddChart(high = if c_vol then na else pc_hi, low = pc_lo , open = pc_hi,  close = if c_vol then na else pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_red"));
AddChart(high = if c_vol then na else pc_hi, low = pc_lo , open = pc_lo,  close = if c_vol then na else pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_red"));

AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = if c_vol then vc_lo else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_grn"));
AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = if c_vol then vc_hi else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_grn"));

AddChart(high = if c_vol then na else vc_hi, low = vc_lo , open = vc_hi,  close = if c_vol then na else  vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_red"));
AddChart(high = if c_vol then na else vc_hi, low = vc_lo , open = vc_lo,  close = if c_vol then na else  vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_red"));

#// ===========================================================================================================
#//      v2.0 Adding Markers for Key Patterns 
#// ===========================================================================================================
#// we can re-utilize the Normailize() function here too - but it's cleaner to have a separate ratio calc
def nPrice_abs = AbsValue(nPrice);
#//EV_Ratio = 100 * Normalize(nPrice_abs, nVol)
def EV_Ratio = 100 * nPrice_abs / nVol;

#// initial mapping of return ratios (to be revised)
#// -------------------------------------------------------
#// Case (1): Price > Vol => ratio > 120  =   Ease of Move (EoM)
#// Case (2): Price close to Vol  => ratio between 80 - 120  = Reasonable Balance
#// Case (3): Price less than Vol but reasonable => ratio between 80 - 50  = Drift / "nothing much to see here" bar
#// Case (4): Price a lot less than Vol  => 50 or less  = Compression / Squat
#// we're most interested in cases 1 & 4

#//plot (EV_Ratio)   // for validation only
def is_positive     = nPrice > 0;
def is_Compression  = EV_Ratio <= 50;
def is_EoM          = EV_Ratio >= 120;

#//Provide option to show/hide those EVEREX Markers - and an option for Compression bar
#// - some folks would prefer a cross, others may prefer a circle - can adjust based on feedback
#// no option for Ease of Move, guessing the triangle has the right significance

#// Plot markers
plot EoMPos = if showMarkers and is_EoM and is_positive then 100 else na;    # "EoM +ve"
plot EoMNeg = if showMarkers and is_EoM and !is_positive then 100 else na;   # "EoM -ve"
EoMPos.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
EoMNeg.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
EoMPos.SetDefaultColor(Color.GREEN);
EoMNeg.SetDefaultColor(Color.RED);

plot ComPos = if showMarkers and is_Compression and is_positive then 100 else na; # "Compression +ve"
plot ComNeg = if showMarkers and is_Compression and !is_positive then 100 else na;# "Compression -ve"
ComPos.SetPaintingStrategy(PaintingStrategy.POINTS);
ComNeg.SetPaintingStrategy(PaintingStrategy.POINTS);
ComPos.SetDefaultColor(Color.GREEN);
ComNeg.SetDefaultColor(Color.RED);

#--- Label
AddLabel(BiasLabel, if RROF_bs>0 then "Bias: UP" else "Bias: DN", if RROF_bs>0 then Color.GREEN else Color.RED);

#-- Background
AddCloud(if up then pos else neg, if up then neg else pos, GlobalColor("dgreen"), GlobalColor("dred"));

#-- Bar Color
def ExtUp = s_up and c_vol;
def ExtDn = !s_up and !c_vol;

AssignPriceColor( if !ColorBars then Color.CURRENT else
                  if ExtUp then Color.GREEN else
                  if s_up then Color.DARK_GREEN else
                  if ExtDn then Color.RED else
                  if !s_up then Color.DARK_RED else Color.GRAY);
                

#--- END CODE
 
@samer800 could you add the circles and triangles to the script as in the original version in Tradingview? Thank you in advance for all you do for this community.
 
Last edited by a moderator:
particularly interesting to me was the way you colored the background, which I just copied the idea to add to some indicators I use. it really facilitates the visual, more so when entry and exit criteria depends on a few indicators I am still polishing.

For more information about my chart and a shared setup link:
https://usethinkscript.com/threads/...rts-and-mtf-scanner-for-tos.4793/#post-132015
Screenshot (1375).png
 
Last edited by a moderator:
View attachment 18031

Creator Message: https://www.tradingview.com/v/I5qJDPxT/

CODE:

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © RedKTrader - March 2023
#// https://www.tradingview.com/v/I5qJDPxT/
#// inspecting the effort vs result concept by plotting volume vs. price change
#// this is like looking at distance versus fuel consumption - but comparing a normalized average of each
#// to help reveal areas of volume & price action anomalies, contraction & expansion
#indicator('RedK Effort Versus Results Explorer', 'RedK EVEREX v1.0', precision = 0,
# Converted and mod by Sam4Cok@Samer800        - 03/2023
declare lower;
input UseChartTimeframe = yes;
input CustomAggregation = AggregationPeriod.FIFTEEN_MIN;
input DisplayType = {Default EVEREX, Bias, Both};
input ColorBars   = yes;
input BiasLabel   = yes;
input Signal_Line = yes;
input rofLine     = yes;
input bandScale   = {default "100", "200", "400"};          # "Band Scale"
input LookbackCalcType = {default "Simple", "Same as RRoF"}; # 'Lookback Averaging Type'
input lookback    = 20;  # 'lookback'
input RofType     = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};    # 'MA type'
input RofLength   = 10;    # 'ROF Length'
input RofSmooth   = 3;     # 'Smooth'
input SignalType  = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};  # 'Signal Ma Type'
input signalLength = 5;   # 'Signal Length'
input BiasType    = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};      # 'Bias MA type',
input BiasLength  = 30;  # 'Bias Length'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def scale = if bandscale == bandscale."100" then 100 else
            if bandscale == bandscale."200" then 200 else
            if bandscale == bandscale."400" then 400 else scale[1];
def ikbk = LookbackCalcType == LookbackCalcType."Simple";
def DispBias    = DisplayType==DisplayType.Bias or DisplayType==DisplayType.Both;
def DispEVEREX  = DisplayType==DisplayType.EVEREX or DisplayType==DisplayType.Both;
def chartTf = GetAggregationPeriod();
def tf     = if UseChartTimeframe then chartTf else CustomAggregation;
def close  = close(Period=tf);
def high   = high(Period=tf);
def low    = low(Period=tf);
def open   = open(Period=tf);
def volume = volume(Period=tf);

#---- Color
DefineGlobalColor("c_vol_grn" , CreateColor(15, 65, 61));
DefineGlobalColor("b_vol_grn" , CreateColor(33,145,135));
DefineGlobalColor("c_vol_red" , CreateColor(84, 9, 8));
DefineGlobalColor("b_vol_red" , CreateColor(235,37,33));
DefineGlobalColor("c_pri_grn" , CreateColor(13,62,13));
DefineGlobalColor("b_pri_grn" , CreateColor(43,208,43));
DefineGlobalColor("c_pri_red" , CreateColor(83,42,0));
DefineGlobalColor("b_pri_red" , CreateColor(240,122,0));
DefineGlobalColor("c_up" , CreateColor(41,98,255));
DefineGlobalColor("c_dn" , CreateColor(255,152,0));
DefineGlobalColor("green" , CreateColor(0,177,0));
DefineGlobalColor("red"   , CreateColor(177,0,0));
DefineGlobalColor("dgreen" , CreateColor(0,39,0));
DefineGlobalColor("dred"   , CreateColor(59,0,0));
#// --- Functions
#GetAverage(_data, _len, MAOption) =>
script GetAverage {
    input _data = close;
    input _len = 10;
    input MAOption = "SMA";
    def w = wma(_data, _len);
    def mav = ((Average(_data, _len)[1]*(_len-1)) + _data) / _len;
    def GetAverage = if MAOption == "SMA" then Average(_data, _len) else
                     if MAOption == "SMMA" then if isNaN(w[1]) then average(_data, _len) else
                         CompoundValue(1, (w[1] * (_len - 1) + _data) / _len,  average(_data, _len)) else
                     if MAOption == "EMA" then ExpAverage(_data, _len) else
                     if MAOption == "MAV" then mav else             
                     if MAOption == "HMA" then HullMovingAvg(_data, _len) else
                     if MAOption == "RMA" then WildersAverage(_data, _len) else
                     if MAOption == "WMA" then WMA(_data, _len) else Average(_data, _len);
    plot out = GetAverage;
}
#Normalize(_Value, _Avg) =>
script Normalize {
    input _Value = close;
    input _Avg = 10;
    def _X = _Value / _Avg;
    def _Nor =
      if _X > 1.50 then 1.00 else
      if _X > 1.20 then 0.90 else
      if _X > 1.00 then 0.80 else
      if _X > 0.80 then 0.70 else
      if _X > 0.60 then 0.60 else
      if _X > 0.40 then 0.50 else
      if _X > 0.20 then 0.25 else 0.1;
    plot norm = _Nor;
}
#//          Calculations
def v   = if IsNaN(volume) then 1 else volume;
def NoVol_Flag = if IsNaN(volume) then yes else no;#      // this is a flag to use later

def Vola  = if ikbk then Average(v,lookback) else GetAverage(v, lookback, RofType);
def Vola_n_pre = Normalize(v, Vola) * 100;

#//Now trap the case of no volume data - ensure final calculation not impacted
def Vola_n = if NoVol_Flag then 100 else Vola_n_pre;

def BarSpread = close - open;
def BarRange  = high - low;
def R2        = Highest(high, 2) - Lowest(low, 2);
def SrcShift  = close - close[1];
#//TR = ta.tr(true)

def sign_shift = Sign(SrcShift);
def sign_spread = Sign(BarSpread);
#//    in-bar assessments

def barclosing  = 2 * (close - low) / BarRange * 100 - 100;
def s2r = BarSpread / BarRange * 100;

def BarSpread_abs   = AbsValue(BarSpread);
def BarSpread_avg   = if ikbk then Average(BarSpread_abs,lookback) else GetAverage(BarSpread_abs, lookback, RofType);
def BarSpread_ratio_n = Normalize(BarSpread_abs, BarSpread_avg) * 100 * sign_spread ;
#//    2-bar assessments
def barclosing_2  = 2 * (close - Lowest(low, 2)) / R2 * 100 - 100;
def Shift2Bar_toR2 = SrcShift / R2 * 100;
def SrcShift_abs     = AbsValue(SrcShift);
def srcshift_avg     = if ikbk then Average(SrcShift_abs,lookback) else GetAverage(SrcShift_abs, lookback, RofType);
def srcshift_ratio_n = Normalize(SrcShift_abs, srcshift_avg) * 100 * sign_shift;
#/ Relative Price Strength combining all strength elements
def Pricea_n = (barclosing + s2r + BarSpread_ratio_n + barclosing_2 + Shift2Bar_toR2 + srcshift_ratio_n) / 6;# "Price Normalized"
#//Let's take Bar Flow as the combined price strength * the volume:avg ratio
def bar_flow  =   Pricea_n * Vola_n / 100;
#/ Relative Price Strength combining all strength elements
def bulls = Max(bar_flow, 0);
def bears = -1 * Min(bar_flow, 0);

def bulls_avg = GetAverage(bulls, RofLength, RofType);
def bears_avg = GetAverage(bears, RofLength, RofType);
def dx     = bulls_avg / bears_avg;
def RROF   = 2 * (100 - 100 / (1 + dx)) - 100;
def RROF_s = WMA(RROF, RofSmooth);

def Signal = GetAverage(RROF_s, signalLength, SignalType);
#// Calculate Bias / sentiment on longer length
def dx_b    = GetAverage(bulls, BiasLength, BiasType) / GetAverage(bears, BiasLength, BiasType);
def RROF_b  = 2 * (100 - 100 / (1 + dx_b)) - 100;
def RROF_bs = WMA(RROF_b, RofSmooth);
#//      Colors & plots
def up      = RROF_s >= 0;
def s_up    = RROF_bs >= 0;

plot level1 = if last then na else 0.25 * scale; # '1/4 Level'
plot level2 = if last then na else 0.50 * scale; # '2/4 Level'
plot level3 = if last then na else 0.75 * scale; # '3/4 Level'
plot level4 = if last then na else scale;        # '4/4 Level'

level1.SetDefaultColor(Color.GRAY);
level2.SetDefaultColor(Color.GRAY);
level3.SetDefaultColor(Color.GRAY);
level4.SetDefaultColor(Color.GRAY);
level1.SetStyle(Curve.SHORT_DASH);
level2.SetStyle(Curve.SHORT_DASH);
level3.SetStyle(Curve.SHORT_DASH);
level4.SetStyle(Curve.SHORT_DASH);
#// Plot main plot, smoothed plot and signal line

plot RROF_Smooth = if rofLine then RROF_s else na;#, 'RROF Smooth'
#RROF_Smooth.SetLineWeight(2);
RROF_Smooth.SetDefaultColor(Color.WHITE);
plot SignalLine = if Signal_Line then Signal else na;#, "Signal Line"
SignalLine.SetLineWeight(3);
SignalLine.AssignValueColor( if up then GlobalColor("c_up") else GlobalColor("c_dn"));

#// Plot Bias / Sentiment
plot BiasSentiment = if DispBias then RROF_bs else na;#, "Bias / Sentiment"
BiasSentiment.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BiasSentiment.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));

AddLabel(BiasLabel, if RROF_bs>0 then "Bias: UP" else "Bias: DN", if RROF_bs>0 then Color.GREEN else Color.RED);

plot ZeroLine = if last then na else 0;    # 'Zero Line'
ZeroLine.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));
#// =============================================================================
#// Plot Price Strength & Relative Volume as stacked "equalizer bands"

def nPrice  = Max(Min(Pricea_n, 100), -100);
def nVol    = Max(Min(Vola_n, 100), -100);
def bar = bar_flow;
def c_vol  = bar > 0;
def cb_vol = if bar > 0 then 1 else -1;
def vc_lo = if DispEVEREX then 0 else na;
def vc_hi = nVol * scale / 100 / 2;
def pc_lo = if DispEVEREX then vc_hi else na; def pc_hi = vc_hi + AbsValue(nPrice) * scale / 100 / 2;

AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_grn"));
AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_grn"));

AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_red"));
AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_red"));

AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_grn"));
AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_grn"));

AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_red"));
AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_red"));



#-- Background
AddCloud(if up then pos else neg, if up then neg else pos, GlobalColor("dgreen"), GlobalColor("dred"));

#-- Bar Color
def ExtUp = s_up and c_vol;
def ExtDn = !s_up and !c_vol;

AssignPriceColor( if !ColorBars then Color.CURRENT else
                  if ExtUp then Color.GREEN else
                  if s_up then Color.DARK_GREEN else
                  if ExtDn then Color.RED else
                  if !s_up then Color.DARK_RED else Color.GRAY);
              

#--- END CODE
To whoever made this - thank you. Genius work!
 
View attachment 18031

Creator Message: https://www.tradingview.com/v/I5qJDPxT/

CODE:

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © RedKTrader - March 2023
#// https://www.tradingview.com/v/I5qJDPxT/
#// inspecting the effort vs result concept by plotting volume vs. price change
#// this is like looking at distance versus fuel consumption - but comparing a normalized average of each
#// to help reveal areas of volume & price action anomalies, contraction & expansion
#indicator('RedK Effort Versus Results Explorer', 'RedK EVEREX v1.0', precision = 0,
# Converted and mod by Sam4Cok@Samer800        - 03/2023
declare lower;
input UseChartTimeframe = yes;
input CustomAggregation = AggregationPeriod.FIFTEEN_MIN;
input DisplayType = {Default EVEREX, Bias, Both};
input ColorBars   = yes;
input BiasLabel   = yes;
input Signal_Line = yes;
input rofLine     = yes;
input bandScale   = {default "100", "200", "400"};          # "Band Scale"
input LookbackCalcType = {default "Simple", "Same as RRoF"}; # 'Lookback Averaging Type'
input lookback    = 20;  # 'lookback'
input RofType     = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};    # 'MA type'
input RofLength   = 10;    # 'ROF Length'
input RofSmooth   = 3;     # 'Smooth'
input SignalType  = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};  # 'Signal Ma Type'
input signalLength = 5;   # 'Signal Length'
input BiasType    = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};      # 'Bias MA type',
input BiasLength  = 30;  # 'Bias Length'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def scale = if bandscale == bandscale."100" then 100 else
            if bandscale == bandscale."200" then 200 else
            if bandscale == bandscale."400" then 400 else scale[1];
def ikbk = LookbackCalcType == LookbackCalcType."Simple";
def DispBias    = DisplayType==DisplayType.Bias or DisplayType==DisplayType.Both;
def DispEVEREX  = DisplayType==DisplayType.EVEREX or DisplayType==DisplayType.Both;
def chartTf = GetAggregationPeriod();
def tf     = if UseChartTimeframe then chartTf else CustomAggregation;
def close  = close(Period=tf);
def high   = high(Period=tf);
def low    = low(Period=tf);
def open   = open(Period=tf);
def volume = volume(Period=tf);

#---- Color
DefineGlobalColor("c_vol_grn" , CreateColor(15, 65, 61));
DefineGlobalColor("b_vol_grn" , CreateColor(33,145,135));
DefineGlobalColor("c_vol_red" , CreateColor(84, 9, 8));
DefineGlobalColor("b_vol_red" , CreateColor(235,37,33));
DefineGlobalColor("c_pri_grn" , CreateColor(13,62,13));
DefineGlobalColor("b_pri_grn" , CreateColor(43,208,43));
DefineGlobalColor("c_pri_red" , CreateColor(83,42,0));
DefineGlobalColor("b_pri_red" , CreateColor(240,122,0));
DefineGlobalColor("c_up" , CreateColor(41,98,255));
DefineGlobalColor("c_dn" , CreateColor(255,152,0));
DefineGlobalColor("green" , CreateColor(0,177,0));
DefineGlobalColor("red"   , CreateColor(177,0,0));
DefineGlobalColor("dgreen" , CreateColor(0,39,0));
DefineGlobalColor("dred"   , CreateColor(59,0,0));
#// --- Functions
#GetAverage(_data, _len, MAOption) =>
script GetAverage {
    input _data = close;
    input _len = 10;
    input MAOption = "SMA";
    def w = wma(_data, _len);
    def mav = ((Average(_data, _len)[1]*(_len-1)) + _data) / _len;
    def GetAverage = if MAOption == "SMA" then Average(_data, _len) else
                     if MAOption == "SMMA" then if isNaN(w[1]) then average(_data, _len) else
                         CompoundValue(1, (w[1] * (_len - 1) + _data) / _len,  average(_data, _len)) else
                     if MAOption == "EMA" then ExpAverage(_data, _len) else
                     if MAOption == "MAV" then mav else             
                     if MAOption == "HMA" then HullMovingAvg(_data, _len) else
                     if MAOption == "RMA" then WildersAverage(_data, _len) else
                     if MAOption == "WMA" then WMA(_data, _len) else Average(_data, _len);
    plot out = GetAverage;
}
#Normalize(_Value, _Avg) =>
script Normalize {
    input _Value = close;
    input _Avg = 10;
    def _X = _Value / _Avg;
    def _Nor =
      if _X > 1.50 then 1.00 else
      if _X > 1.20 then 0.90 else
      if _X > 1.00 then 0.80 else
      if _X > 0.80 then 0.70 else
      if _X > 0.60 then 0.60 else
      if _X > 0.40 then 0.50 else
      if _X > 0.20 then 0.25 else 0.1;
    plot norm = _Nor;
}
#//          Calculations
def v   = if IsNaN(volume) then 1 else volume;
def NoVol_Flag = if IsNaN(volume) then yes else no;#      // this is a flag to use later

def Vola  = if ikbk then Average(v,lookback) else GetAverage(v, lookback, RofType);
def Vola_n_pre = Normalize(v, Vola) * 100;

#//Now trap the case of no volume data - ensure final calculation not impacted
def Vola_n = if NoVol_Flag then 100 else Vola_n_pre;

def BarSpread = close - open;
def BarRange  = high - low;
def R2        = Highest(high, 2) - Lowest(low, 2);
def SrcShift  = close - close[1];
#//TR = ta.tr(true)

def sign_shift = Sign(SrcShift);
def sign_spread = Sign(BarSpread);
#//    in-bar assessments

def barclosing  = 2 * (close - low) / BarRange * 100 - 100;
def s2r = BarSpread / BarRange * 100;

def BarSpread_abs   = AbsValue(BarSpread);
def BarSpread_avg   = if ikbk then Average(BarSpread_abs,lookback) else GetAverage(BarSpread_abs, lookback, RofType);
def BarSpread_ratio_n = Normalize(BarSpread_abs, BarSpread_avg) * 100 * sign_spread ;
#//    2-bar assessments
def barclosing_2  = 2 * (close - Lowest(low, 2)) / R2 * 100 - 100;
def Shift2Bar_toR2 = SrcShift / R2 * 100;
def SrcShift_abs     = AbsValue(SrcShift);
def srcshift_avg     = if ikbk then Average(SrcShift_abs,lookback) else GetAverage(SrcShift_abs, lookback, RofType);
def srcshift_ratio_n = Normalize(SrcShift_abs, srcshift_avg) * 100 * sign_shift;
#/ Relative Price Strength combining all strength elements
def Pricea_n = (barclosing + s2r + BarSpread_ratio_n + barclosing_2 + Shift2Bar_toR2 + srcshift_ratio_n) / 6;# "Price Normalized"
#//Let's take Bar Flow as the combined price strength * the volume:avg ratio
def bar_flow  =   Pricea_n * Vola_n / 100;
#/ Relative Price Strength combining all strength elements
def bulls = Max(bar_flow, 0);
def bears = -1 * Min(bar_flow, 0);

def bulls_avg = GetAverage(bulls, RofLength, RofType);
def bears_avg = GetAverage(bears, RofLength, RofType);
def dx     = bulls_avg / bears_avg;
def RROF   = 2 * (100 - 100 / (1 + dx)) - 100;
def RROF_s = WMA(RROF, RofSmooth);

def Signal = GetAverage(RROF_s, signalLength, SignalType);
#// Calculate Bias / sentiment on longer length
def dx_b    = GetAverage(bulls, BiasLength, BiasType) / GetAverage(bears, BiasLength, BiasType);
def RROF_b  = 2 * (100 - 100 / (1 + dx_b)) - 100;
def RROF_bs = WMA(RROF_b, RofSmooth);
#//      Colors & plots
def up      = RROF_s >= 0;
def s_up    = RROF_bs >= 0;

plot level1 = if last then na else 0.25 * scale; # '1/4 Level'
plot level2 = if last then na else 0.50 * scale; # '2/4 Level'
plot level3 = if last then na else 0.75 * scale; # '3/4 Level'
plot level4 = if last then na else scale;        # '4/4 Level'

level1.SetDefaultColor(Color.GRAY);
level2.SetDefaultColor(Color.GRAY);
level3.SetDefaultColor(Color.GRAY);
level4.SetDefaultColor(Color.GRAY);
level1.SetStyle(Curve.SHORT_DASH);
level2.SetStyle(Curve.SHORT_DASH);
level3.SetStyle(Curve.SHORT_DASH);
level4.SetStyle(Curve.SHORT_DASH);
#// Plot main plot, smoothed plot and signal line

plot RROF_Smooth = if rofLine then RROF_s else na;#, 'RROF Smooth'
#RROF_Smooth.SetLineWeight(2);
RROF_Smooth.SetDefaultColor(Color.WHITE);
plot SignalLine = if Signal_Line then Signal else na;#, "Signal Line"
SignalLine.SetLineWeight(3);
SignalLine.AssignValueColor( if up then GlobalColor("c_up") else GlobalColor("c_dn"));

#// Plot Bias / Sentiment
plot BiasSentiment = if DispBias then RROF_bs else na;#, "Bias / Sentiment"
BiasSentiment.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BiasSentiment.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));

AddLabel(BiasLabel, if RROF_bs>0 then "Bias: UP" else "Bias: DN", if RROF_bs>0 then Color.GREEN else Color.RED);

plot ZeroLine = if last then na else 0;    # 'Zero Line'
ZeroLine.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));
#// =============================================================================
#// Plot Price Strength & Relative Volume as stacked "equalizer bands"

def nPrice  = Max(Min(Pricea_n, 100), -100);
def nVol    = Max(Min(Vola_n, 100), -100);
def bar = bar_flow;
def c_vol  = bar > 0;
def cb_vol = if bar > 0 then 1 else -1;
def vc_lo = if DispEVEREX then 0 else na;
def vc_hi = nVol * scale / 100 / 2;
def pc_lo = if DispEVEREX then vc_hi else na; def pc_hi = vc_hi + AbsValue(nPrice) * scale / 100 / 2;

AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_grn"));
AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_grn"));

AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_red"));
AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_red"));

AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_grn"));
AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_grn"));

AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_red"));
AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_red"));



#-- Background
AddCloud(if up then pos else neg, if up then neg else pos, GlobalColor("dgreen"), GlobalColor("dred"));

#-- Bar Color
def ExtUp = s_up and c_vol;
def ExtDn = !s_up and !c_vol;

AssignPriceColor( if !ColorBars then Color.CURRENT else
                  if ExtUp then Color.GREEN else
                  if s_up then Color.DARK_GREEN else
                  if ExtDn then Color.RED else
                  if !s_up then Color.DARK_RED else Color.GRAY);
              

#--- END CODE
Amazing work!

Is there a way to create a scanner for this? The code as-is is too complicated for the scanner.
 
View attachment 18031

Creator Message: https://www.tradingview.com/v/I5qJDPxT/

CODE:

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © RedKTrader - March 2023
#// https://www.tradingview.com/v/I5qJDPxT/
#// inspecting the effort vs result concept by plotting volume vs. price change
#// this is like looking at distance versus fuel consumption - but comparing a normalized average of each
#// to help reveal areas of volume & price action anomalies, contraction & expansion
#indicator('RedK Effort Versus Results Explorer', 'RedK EVEREX v1.0', precision = 0,
# Converted and mod by Sam4Cok@Samer800        - 03/2023
declare lower;
input UseChartTimeframe = yes;
input CustomAggregation = AggregationPeriod.FIFTEEN_MIN;
input DisplayType = {Default EVEREX, Bias, Both};
input ColorBars   = yes;
input BiasLabel   = yes;
input Signal_Line = yes;
input rofLine     = yes;
input bandScale   = {default "100", "200", "400"};          # "Band Scale"
input LookbackCalcType = {default "Simple", "Same as RRoF"}; # 'Lookback Averaging Type'
input lookback    = 20;  # 'lookback'
input RofType     = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};    # 'MA type'
input RofLength   = 10;    # 'ROF Length'
input RofSmooth   = 3;     # 'Smooth'
input SignalType  = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};  # 'Signal Ma Type'
input signalLength = 5;   # 'Signal Length'
input BiasType    = {default WMA, EMA, SMA, HMA, RMA, SMMA, MAV};      # 'Bias MA type',
input BiasLength  = 30;  # 'Bias Length'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def scale = if bandscale == bandscale."100" then 100 else
            if bandscale == bandscale."200" then 200 else
            if bandscale == bandscale."400" then 400 else scale[1];
def ikbk = LookbackCalcType == LookbackCalcType."Simple";
def DispBias    = DisplayType==DisplayType.Bias or DisplayType==DisplayType.Both;
def DispEVEREX  = DisplayType==DisplayType.EVEREX or DisplayType==DisplayType.Both;
def chartTf = GetAggregationPeriod();
def tf     = if UseChartTimeframe then chartTf else CustomAggregation;
def close  = close(Period=tf);
def high   = high(Period=tf);
def low    = low(Period=tf);
def open   = open(Period=tf);
def volume = volume(Period=tf);

#---- Color
DefineGlobalColor("c_vol_grn" , CreateColor(15, 65, 61));
DefineGlobalColor("b_vol_grn" , CreateColor(33,145,135));
DefineGlobalColor("c_vol_red" , CreateColor(84, 9, 8));
DefineGlobalColor("b_vol_red" , CreateColor(235,37,33));
DefineGlobalColor("c_pri_grn" , CreateColor(13,62,13));
DefineGlobalColor("b_pri_grn" , CreateColor(43,208,43));
DefineGlobalColor("c_pri_red" , CreateColor(83,42,0));
DefineGlobalColor("b_pri_red" , CreateColor(240,122,0));
DefineGlobalColor("c_up" , CreateColor(41,98,255));
DefineGlobalColor("c_dn" , CreateColor(255,152,0));
DefineGlobalColor("green" , CreateColor(0,177,0));
DefineGlobalColor("red"   , CreateColor(177,0,0));
DefineGlobalColor("dgreen" , CreateColor(0,39,0));
DefineGlobalColor("dred"   , CreateColor(59,0,0));
#// --- Functions
#GetAverage(_data, _len, MAOption) =>
script GetAverage {
    input _data = close;
    input _len = 10;
    input MAOption = "SMA";
    def w = wma(_data, _len);
    def mav = ((Average(_data, _len)[1]*(_len-1)) + _data) / _len;
    def GetAverage = if MAOption == "SMA" then Average(_data, _len) else
                     if MAOption == "SMMA" then if isNaN(w[1]) then average(_data, _len) else
                         CompoundValue(1, (w[1] * (_len - 1) + _data) / _len,  average(_data, _len)) else
                     if MAOption == "EMA" then ExpAverage(_data, _len) else
                     if MAOption == "MAV" then mav else             
                     if MAOption == "HMA" then HullMovingAvg(_data, _len) else
                     if MAOption == "RMA" then WildersAverage(_data, _len) else
                     if MAOption == "WMA" then WMA(_data, _len) else Average(_data, _len);
    plot out = GetAverage;
}
#Normalize(_Value, _Avg) =>
script Normalize {
    input _Value = close;
    input _Avg = 10;
    def _X = _Value / _Avg;
    def _Nor =
      if _X > 1.50 then 1.00 else
      if _X > 1.20 then 0.90 else
      if _X > 1.00 then 0.80 else
      if _X > 0.80 then 0.70 else
      if _X > 0.60 then 0.60 else
      if _X > 0.40 then 0.50 else
      if _X > 0.20 then 0.25 else 0.1;
    plot norm = _Nor;
}
#//          Calculations
def v   = if IsNaN(volume) then 1 else volume;
def NoVol_Flag = if IsNaN(volume) then yes else no;#      // this is a flag to use later

def Vola  = if ikbk then Average(v,lookback) else GetAverage(v, lookback, RofType);
def Vola_n_pre = Normalize(v, Vola) * 100;

#//Now trap the case of no volume data - ensure final calculation not impacted
def Vola_n = if NoVol_Flag then 100 else Vola_n_pre;

def BarSpread = close - open;
def BarRange  = high - low;
def R2        = Highest(high, 2) - Lowest(low, 2);
def SrcShift  = close - close[1];
#//TR = ta.tr(true)

def sign_shift = Sign(SrcShift);
def sign_spread = Sign(BarSpread);
#//    in-bar assessments

def barclosing  = 2 * (close - low) / BarRange * 100 - 100;
def s2r = BarSpread / BarRange * 100;

def BarSpread_abs   = AbsValue(BarSpread);
def BarSpread_avg   = if ikbk then Average(BarSpread_abs,lookback) else GetAverage(BarSpread_abs, lookback, RofType);
def BarSpread_ratio_n = Normalize(BarSpread_abs, BarSpread_avg) * 100 * sign_spread ;
#//    2-bar assessments
def barclosing_2  = 2 * (close - Lowest(low, 2)) / R2 * 100 - 100;
def Shift2Bar_toR2 = SrcShift / R2 * 100;
def SrcShift_abs     = AbsValue(SrcShift);
def srcshift_avg     = if ikbk then Average(SrcShift_abs,lookback) else GetAverage(SrcShift_abs, lookback, RofType);
def srcshift_ratio_n = Normalize(SrcShift_abs, srcshift_avg) * 100 * sign_shift;
#/ Relative Price Strength combining all strength elements
def Pricea_n = (barclosing + s2r + BarSpread_ratio_n + barclosing_2 + Shift2Bar_toR2 + srcshift_ratio_n) / 6;# "Price Normalized"
#//Let's take Bar Flow as the combined price strength * the volume:avg ratio
def bar_flow  =   Pricea_n * Vola_n / 100;
#/ Relative Price Strength combining all strength elements
def bulls = Max(bar_flow, 0);
def bears = -1 * Min(bar_flow, 0);

def bulls_avg = GetAverage(bulls, RofLength, RofType);
def bears_avg = GetAverage(bears, RofLength, RofType);
def dx     = bulls_avg / bears_avg;
def RROF   = 2 * (100 - 100 / (1 + dx)) - 100;
def RROF_s = WMA(RROF, RofSmooth);

def Signal = GetAverage(RROF_s, signalLength, SignalType);
#// Calculate Bias / sentiment on longer length
def dx_b    = GetAverage(bulls, BiasLength, BiasType) / GetAverage(bears, BiasLength, BiasType);
def RROF_b  = 2 * (100 - 100 / (1 + dx_b)) - 100;
def RROF_bs = WMA(RROF_b, RofSmooth);
#//      Colors & plots
def up      = RROF_s >= 0;
def s_up    = RROF_bs >= 0;

plot level1 = if last then na else 0.25 * scale; # '1/4 Level'
plot level2 = if last then na else 0.50 * scale; # '2/4 Level'
plot level3 = if last then na else 0.75 * scale; # '3/4 Level'
plot level4 = if last then na else scale;        # '4/4 Level'

level1.SetDefaultColor(Color.GRAY);
level2.SetDefaultColor(Color.GRAY);
level3.SetDefaultColor(Color.GRAY);
level4.SetDefaultColor(Color.GRAY);
level1.SetStyle(Curve.SHORT_DASH);
level2.SetStyle(Curve.SHORT_DASH);
level3.SetStyle(Curve.SHORT_DASH);
level4.SetStyle(Curve.SHORT_DASH);
#// Plot main plot, smoothed plot and signal line

plot RROF_Smooth = if rofLine then RROF_s else na;#, 'RROF Smooth'
#RROF_Smooth.SetLineWeight(2);
RROF_Smooth.SetDefaultColor(Color.WHITE);
plot SignalLine = if Signal_Line then Signal else na;#, "Signal Line"
SignalLine.SetLineWeight(3);
SignalLine.AssignValueColor( if up then GlobalColor("c_up") else GlobalColor("c_dn"));

#// Plot Bias / Sentiment
plot BiasSentiment = if DispBias then RROF_bs else na;#, "Bias / Sentiment"
BiasSentiment.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BiasSentiment.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));

AddLabel(BiasLabel, if RROF_bs>0 then "Bias: UP" else "Bias: DN", if RROF_bs>0 then Color.GREEN else Color.RED);

plot ZeroLine = if last then na else 0;    # 'Zero Line'
ZeroLine.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));
#// =============================================================================
#// Plot Price Strength & Relative Volume as stacked "equalizer bands"

def nPrice  = Max(Min(Pricea_n, 100), -100);
def nVol    = Max(Min(Vola_n, 100), -100);
def bar = bar_flow;
def c_vol  = bar > 0;
def cb_vol = if bar > 0 then 1 else -1;
def vc_lo = if DispEVEREX then 0 else na;
def vc_hi = nVol * scale / 100 / 2;
def pc_lo = if DispEVEREX then vc_hi else na; def pc_hi = vc_hi + AbsValue(nPrice) * scale / 100 / 2;

AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_grn"));
AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_grn"));

AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_red"));
AddChart(high = if !c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_red"));

AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_grn"));
AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_grn"));

AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_red"));
AddChart(high = if !c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_red"));



#-- Background
AddCloud(if up then pos else neg, if up then neg else pos, GlobalColor("dgreen"), GlobalColor("dred"));

#-- Bar Color
def ExtUp = s_up and c_vol;
def ExtDn = !s_up and !c_vol;

AssignPriceColor( if !ColorBars then Color.CURRENT else
                  if ExtUp then Color.GREEN else
                  if s_up then Color.DARK_GREEN else
                  if ExtDn then Color.RED else
                  if !s_up then Color.DARK_RED else Color.GRAY);
              

#--- END CODE
Would it be possible to have this work on tick charts?
 
Tried to convert this into a "Strategy" without success.
Essentially: buy or sell when the RROF_Smooth Line crosses above or below the SignalLine by a % (user selectable), say for example 10% above to go long. I believe it will make a decent strategy.
 
not sure what is the exact issue. However, try below code, I just did some minor code change.
still, the results may vary from TV code.

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © RedKTrader - March 2023
#// https://www.tradingview.com/v/I5qJDPxT/
#// inspecting the effort vs result concept by plotting volume vs. price change
#// this is like looking at distance versus fuel consumption - but comparing a normalized average of each
#// to help reveal areas of volume & price action anomalies, contraction & expansion
#indicator('RedK Effort Versus Results Explorer', 'RedK EVEREX v1.0', precision = 0,
# Converted and mod by Sam4Cok@Samer800        - 03/2023
# Update - minor code fixing - 07/2023
declare lower;
input showMarkers = yes;# 'Show EVEREX Markers ?')
input ColorBars   = no;
input UseChartTimeframe = {Default "Yes", "No"};
input CustomAggregation = AggregationPeriod.FIFTEEN_MIN;
input DisplayType = {Default EVEREX, Bias, Both, "Don't Show"};
input BiasLabel   = no;
input Signal_Line = yes;
input rofLine     = yes;
input bandScale   = {default "100", "200", "400"};          # "Band Scale"
input LookbackCalcType = {default "Simple", "Same as RRoF"}; # 'Lookback Averaging Type'
input lookback    = 20;  # 'lookback'
input RofType     = {default WMA, EMA, SMA, HMA, RMA, MAV};    # 'MA type'
input RofLength   = 10;    # 'ROF Length'
input RofSmooth   = 3;     # 'Smooth'
input SignalType  = {default WMA, EMA, SMA, HMA, RMA, MAV};  # 'Signal Ma Type'
input signalLength = 5;   # 'Signal Length'
input BiasType    = {default WMA, EMA, SMA, HMA, RMA, MAV};      # 'Bias MA type',
input BiasLength  = 30;  # 'Bias Length'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def DispBias;
def DispEVEREX;

Switch (DisplayType) {
Case EVEREX :
    DispBias = no;
    DispEVEREX = yes;
Case Bias :
    DispBias = yes;
    DispEVEREX = no;
Case Both :
    DispBias = yes;
    DispEVEREX = yes;
Case "Don't Show" :
    DispBias = no;
    DispEVEREX = no;
}
def scale;
Switch (bandScale) {
Case "100" : scale = 100;
Case "200" : scale = 200;
Case "400" : scale = 400;
}
def c; def h; def l; def o; def vol;
Switch (useChartTimeframe) {
Case "Yes" :
    c = close;
    h = high;
    l = low;
    o = open;
    vol = volume;
Case "No" :
    c = close(Period=CustomAggregation);
    h = high(Period=CustomAggregation);
    l = low(Period=CustomAggregation);
    o = open(Period=CustomAggregation);
    vol = volume(Period=CustomAggregation);
}
#---- Color
DefineGlobalColor("c_vol_grn" , CreateColor(15, 65, 61));
DefineGlobalColor("b_vol_grn" , CreateColor(33,145,135));
DefineGlobalColor("c_vol_red" , CreateColor(84, 9, 8));
DefineGlobalColor("b_vol_red" , CreateColor(235,37,33));
DefineGlobalColor("c_pri_grn" , CreateColor(13,62,13));
DefineGlobalColor("b_pri_grn" , CreateColor(43,208,43));
DefineGlobalColor("c_pri_red" , CreateColor(83,42,0));
DefineGlobalColor("b_pri_red" , CreateColor(240,122,0));
DefineGlobalColor("c_up" , CreateColor(41,98,255));
DefineGlobalColor("c_dn" , CreateColor(255,152,0));
DefineGlobalColor("green" , CreateColor(0,177,0));
DefineGlobalColor("red"   , CreateColor(177,0,0));
DefineGlobalColor("dgreen" , CreateColor(0,59,0));
DefineGlobalColor("dred"   , CreateColor(79,0,0));
#// --- Functions
#GetAverage(_data, _len, MAOption) =>
script GetAverage {
    input _data = close;
    input _len = 10;
    input MAOption = "SMA";
    def mav = ((Average(_data, _len)[1]*(_len-1)) + _data) / _len;
    def GetAverage = if MAOption == "SMA" then Average(_data, _len) else
                     if MAOption == "EMA" then ExpAverage(_data, _len) else
                     if MAOption == "MAV" then mav else              
                     if MAOption == "HMA" then HullMovingAvg(_data, _len) else
                     if MAOption == "RMA" then WildersAverage(_data, _len) else
                     if MAOption == "WMA" then WMA(_data, _len) else Average(_data, _len);
    plot out = GetAverage;
}
#Normalize(_Value, _Avg) =>
script Normalize {
    input _Value = close;
    input _Avg = 10;
    def _X = _Value / _Avg;
    def _Nor =
      if _X > 1.50 then 1.00 else
      if _X > 1.20 then 0.90 else
      if _X > 1.00 then 0.80 else
      if _X > 0.80 then 0.70 else
      if _X > 0.60 then 0.60 else
      if _X > 0.40 then 0.50 else
      if _X > 0.20 then 0.25 else 0.1;
    plot norm = _Nor;
}
#//          Calculations
def v   = if isNaN(vol) then 1 else vol;
def NoVol_Flag = if IsNaN(v) then yes else no;#      // this is a flag to use later
def volSMA =  Average(v,lookback);
def volROFF = GetAverage(v, lookback, RofType);
def Vola;
Switch (LookbackCalcType) {
Case "Simple" : Vola = volSMA;
Case "Same as RRoF" : Vola = volROFF;
}
def Vola_n_pre = Normalize(v, Vola) * 100;

#//Now trap the case of no volume data - ensure final calculation not impacted
def Vola_n = if NoVol_Flag then 100 else Vola_n_pre;

def BarSpread = (c - o);
def hl        = (h - l);
def BarRange  = if hl==0 then BarRange[1] else hl;
def hhll      = Highest(h, 2) - Lowest(l, 2);
def R2        = if hhll==0 then R2[1] else hhll;
def SrcShift  = c - c[1];
#//TR = ta.tr(true)

def sign_shift = Sign(SrcShift);
def sign_spread = Sign(BarSpread);
#//    in-bar assessments
def dif = (c - l);#if (c - l)==0 then dif[1] else (c - l);
def barclosing  = 2 * dif / BarRange * 100 - 100;
def s2r = BarSpread / BarRange * 100;

def BarSpread_abs   = AbsValue(BarSpread);
def barSMA = Average(BarSpread_abs,lookback);
def barROFF = GetAverage(BarSpread_abs, lookback, RofType);
def BarSpread_avg;
Switch (LookbackCalcType) {
Case "Simple" : BarSpread_avg = barSMA;
Case "Same as RRoF" : BarSpread_avg = barROFF;
}
def BarSpread_ratio_n = Normalize(BarSpread_abs, BarSpread_avg) * 100 * sign_spread ;

#//    2-bar assessments
def cl = c - Lowest(l, 2);
def barclosing_2  = 2 * cl / R2 * 100 - 100;
def Shift2Bar_toR2 = SrcShift / R2 * 100;
#// 6. Calculate 2-bar Relative Shift
def SrcShift_abs = AbsValue(SrcShift);
def srcSMA = Average(SrcShift_abs,lookback);
def srcRROF = GetAverage(SrcShift_abs, lookback, RofType);
def srcshift_avg;
Switch (LookbackCalcType) {
Case "Simple" : srcshift_avg = srcSMA;
Case "Same as RRoF" : srcshift_avg = srcRROF;
}
def srcshift_ratio_n = Normalize(SrcShift_abs, srcshift_avg) * 100 * sign_shift;
#/ Relative Price Strength combining all strength elements
def Pricea_n = (barclosing + s2r + BarSpread_ratio_n + barclosing_2 + Shift2Bar_toR2 + srcshift_ratio_n) / 6;
# "Price Normalized"
#//Let's take Bar Flow as the combined price strength * the volume:avg ratio
def bar_flow  =   Pricea_n * Vola_n / 100;
#/ Relative Price Strength combining all strength elements
def bulls = Max(bar_flow, 0);
def bears = -1 * Min(bar_flow, 0);

def bulls_avg = GetAverage(bulls, RofLength, RofType);
def bears_avg = GetAverage(bears, RofLength, RofType);
def dx     = bulls_avg / bears_avg;
def RROF   = 2 * (100 - 100 / (1 + dx)) - 100;
def RROF_s = WMA(RROF, RofSmooth);

def Signal = GetAverage(RROF_s, signalLength, SignalType);
#// Calculate Bias / sentiment on longer length
def bulls_bia = GetAverage(bulls, BiasLength, BiasType);
def bears_bia = GetAverage(bears, BiasLength, BiasType);
def dx_b    = bulls_bia / bears_bia;
def RROF_b  = 2 * (100 - 100 / (1 + dx_b)) - 100;
def RROF_bs = WMA(RROF_b, RofSmooth);
#//      Colors & plots
def up      = RROF_s >= 0;
def s_up    = RROF_bs >= 0;

plot level1 = if last then na else 0.25 * scale; # '1/4 Level'
plot level2 = if last then na else 0.50 * scale; # '2/4 Level'
plot level3 = if last then na else 0.75 * scale; # '3/4 Level'
plot level4 = if last then na else scale;        # '4/4 Level'
plot level5 = if last then na else -0.50 * scale; # '2/4 Level'

level1.SetDefaultColor(Color.DARK_GRAY);
level2.SetDefaultColor(Color.WHITE);
level3.SetDefaultColor(Color.YELLOW);
level4.SetDefaultColor(Color.DARK_GRAY);
level5.SetDefaultColor(Color.WHITE);
level1.SetStyle(Curve.SHORT_DASH);
level2.SetStyle(Curve.SHORT_DASH);
level3.SetPaintingStrategy(PaintingStrategy.DASHES);
level4.SetStyle(Curve.SHORT_DASH);
level5.SetStyle(Curve.SHORT_DASH);
#// Plot main plot, smoothed plot and signal line

plot RROF_Smooth = if rofLine then RROF_s else na;#, 'RROF Smooth'
#RROF_Smooth.SetLineWeight(2);
RROF_Smooth.SetDefaultColor(Color.WHITE);

plot SignalLine = if Signal_Line then Signal else na;#, "Signal Line"
SignalLine.SetLineWeight(2);
SignalLine.AssignValueColor( if up then GlobalColor("c_up") else GlobalColor("c_dn"));

#// Plot Bias / Sentiment
plot BiasSentiment = if DispBias then RROF_bs else na;#, "Bias / Sentiment"
BiasSentiment.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BiasSentiment.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));

#// Zero Line
plot ZeroLine = if last then na else 0;    # 'Zero Line'
ZeroLine.AssignValueColor(if s_up then GlobalColor("green") else GlobalColor("red"));
#// =============================================================================
#// Plot Price Strength & Relative Volume as stacked "equalizer bands"

def nPrice  = Max(Min(Pricea_n, 100), -100);
def nVol    = Max(Min(Vola_n, 100), -100);
def bar = bar_flow;
def c_vol  = bar > 0;
def vc_lo = if DispEVEREX then 0 else na;
def vc_hi = nVol * scale / 100 / 2;
def pc_lo = if DispEVEREX then vc_hi else na; def pc_hi = vc_hi + AbsValue(nPrice) * scale / 100 / 2;

AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_hi,  close = if c_vol then pc_lo else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_grn"));
AddChart(high = if c_vol then pc_hi else na , low = pc_lo , open = pc_lo,  close = if c_vol then pc_hi else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_grn"));

AddChart(high = if c_vol then na else pc_hi, low = pc_lo , open = pc_hi,  close = if c_vol then na else pc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_pri_red"));
AddChart(high = if c_vol then na else pc_hi, low = pc_lo , open = pc_lo,  close = if c_vol then na else pc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_pri_red"));

AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_hi,  close = if c_vol then vc_lo else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_grn"));
AddChart(high = if c_vol then vc_hi else na , low = vc_lo , open = vc_lo,  close = if c_vol then vc_hi else na,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_grn"));

AddChart(high = if c_vol then na else vc_hi, low = vc_lo , open = vc_hi,  close = if c_vol then na else  vc_lo,
         type = ChartType.CANDLE, growcolor =  GlobalColor("c_vol_red"));
AddChart(high = if c_vol then na else vc_hi, low = vc_lo , open = vc_lo,  close = if c_vol then na else  vc_hi,
         type = ChartType.CANDLE, growcolor =  GlobalColor("b_vol_red"));

#// ===========================================================================================================
#//      v2.0 Adding Markers for Key Patterns
#// ===========================================================================================================
#// we can re-utilize the Normailize() function here too - but it's cleaner to have a separate ratio calc
def nPrice_abs = AbsValue(nPrice);
#//EV_Ratio = 100 * Normalize(nPrice_abs, nVol)
def EV_Ratio = 100 * nPrice_abs / nVol;

#// initial mapping of return ratios (to be revised)
#// -------------------------------------------------------
#// Case (1): Price > Vol => ratio > 120  =   Ease of Move (EoM)
#// Case (2): Price close to Vol  => ratio between 80 - 120  = Reasonable Balance
#// Case (3): Price less than Vol but reasonable => ratio between 80 - 50  = Drift / "nothing much to see here" bar
#// Case (4): Price a lot less than Vol  => 50 or less  = Compression / Squat
#// we're most interested in cases 1 & 4

#//plot (EV_Ratio)   // for validation only
def is_positive     = nPrice > 0;
def is_Compression  = EV_Ratio <= 50;
def is_EoM          = EV_Ratio >= 120;

#//Provide option to show/hide those EVEREX Markers - and an option for Compression bar
#// - some folks would prefer a cross, others may prefer a circle - can adjust based on feedback
#// no option for Ease of Move, guessing the triangle has the right significance

#// Plot markers
plot EoMPos = if showMarkers and is_EoM and is_positive then 100 else na;    # "EoM +ve"
plot EoMNeg = if showMarkers and is_EoM and !is_positive then 100 else na;   # "EoM -ve"
EoMPos.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
EoMNeg.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
EoMPos.SetDefaultColor(Color.GREEN);
EoMNeg.SetDefaultColor(Color.RED);

plot ComPos = if showMarkers and is_Compression and is_positive then 100 else na; # "Compression +ve"
plot ComNeg = if showMarkers and is_Compression and !is_positive then 100 else na;# "Compression -ve"
ComPos.SetPaintingStrategy(PaintingStrategy.POINTS);
ComNeg.SetPaintingStrategy(PaintingStrategy.POINTS);
ComPos.SetDefaultColor(Color.GREEN);
ComNeg.SetDefaultColor(Color.RED);

#--- Label
AddLabel(BiasLabel, if RROF_bs>0 then "Bias: UP" else "Bias: DN", if RROF_bs>0 then Color.GREEN else Color.RED);

#-- Background
AddCloud(if up then pos else neg, if up then neg else pos, GlobalColor("dgreen"), GlobalColor("dred"));

#-- Bar Color
def ExtUp = s_up and c_vol;
def ExtDn = !s_up and !c_vol;

AssignPriceColor( if !ColorBars then Color.CURRENT else
                  if ExtUp then Color.GREEN else
                  if s_up then Color.DARK_GREEN else
                  if ExtDn then Color.RED else
                  if !s_up then Color.DARK_RED else Color.GRAY);
               

#--- END CODE

Thank you @samer800

This is a very fresh way to interpret Volume Price Analysis. I have traded VPA for a while now and it compares pretty well to traditional VPA methods.

Kudos!
 
Would it be possible to have this work on tick charts?

Some members have had some sporadic success with getting tick / renko / range charts to work by enabling extended hours.

Unfortunately, most indicators on this forum are written for time-based charts.
They can not be made to "work" on tick charts.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Thread starter Similar threads Forum Replies Date
samer800 RedK Chop & Breakout Scout V2.0 for ThinkOrSwim Indicators 18

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
406 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top