BB + LC + RKE BUY SELL Indicator Revised 2
BB + LC + RKE BUY SELL Indicator Revised 2
BB + LC + RKE BUY SELL Indicator Revised 2
// 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
//@version=5
// ******************************
// EVEREX v2.0 adds markers for key patterns based on nPrice:nVol ratios
// starting with EoM and Compression - maybe add "Balanced" and "Mega" ??
// to-do list
// 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
//
***********************************************************************************
************************
// This function calcualtes a selectable average type
GetAverage(_data, _len, MAOption) =>
value = switch MAOption
'SMA' => ta.sma(_data, _len)
'EMA' => ta.ema(_data, _len)
'HMA' => ta.hma(_data, _len)
'RMA' => ta.rma(_data, _len)
=>
ta.wma(_data, _len)
//
***********************************************************************************
************************
//
===================================================================================
=====
// Normalization function - Normalizes values that are not restricted within a zero
to 100 range
// This technique provides a scale that is closer to a "human" estimation of value
in "bands"
// as in: low, below average, average, above average, high, super high
// this also avoids the issue of extreme values when using the stoch() -based
technique
// these values are subjective, and can be changed - but slight changes here won't
lead to major changes in outcome
// since all is relative to the same data series.
//
Normalize(_Value, _Avg) =>
_X = _Value / _Avg
_Nor =
_X > 1.50 ? 1.00 :
_X > 1.20 ? 0.90 :
_X > 1.00 ? 0.80 :
_X > 0.80 ? 0.70 :
_X > 0.60 ? 0.60 :
_X > 0.40 ? 0.50 :
_X > 0.20 ? 0.25 :
0.1
//
===================================================================================
//
===================================================================================
========================
// Inputs
//
===================================================================================
========================
grp_1 = 'Rate of FLow (RoF)'
grp_2 = 'Lookback Parameters'
grp_3 = 'Bias / Sentiment'
grp_4 = 'EVEREX Bands'
//
===================================================================================
========================
// Calculations
//
===================================================================================
========================
//Now trap the case of no volume data - ensure final calculation not impacted
Vola_n = NoVol_Flag ? 100 : Vola_n_pre
//plot(Vola_n , "Volume Normalized", color = color.white, display = display.none)
//
===================================================================================
============================
// Price "result" calculation
// we'll consider "result" (strength or weakness) to be the outcome (average) of 6
elements:
// Same (in-)Bar strength elements:
// 1 - Bar Closing: the closing within the bar --> this will be a direct +100 / -
100 value
// 2 - Spread to range: the spread to range ratio (that's BoP formula) --> direct
+100 / -100 value
// 3 - Relative Spread: spread relative to average spread during lookback period --
> normalized
// 2-bar strength elements:
// 4 - 2-bar closing: the closing within 2-bar range (that accomodates open gap
effect)
// 5 - 2-bar Closing Shift to Range: Change in close relative to the 2-bar range
// 6 - 2-bar Relative Shift: the 2-bar Close (or source price) shift - relative to
the average 2-bar shift during lookback period --> normalized
BarSpread = close - open
BarRange = high - low
R2 = ta.highest(2) - ta.lowest(2)
SrcShift = ta.change(close)
//TR = ta.tr(true)
sign_shift = math.sign(SrcShift)
sign_spread = math.sign(BarSpread)
//
===================================================================================
======================
// in-bar assessments
//
===================================================================================
======================
// 1. Calculate closing within bar - should be max value at either ends of the bar
range
barclosing = 2 * (close - low) / BarRange * 100 - 100
//plot(barclosing, "Bar Closing %" , color=color.fuchsia, display = display.none)
//
===================================================================================
======
// Relative Price Strength combining all strength elements
//Let's take Bar Flow as the combined price strength * the volume:avg ratio
// this works in a similar way to a volume-weighted RSI
bar_flow = Pricea_n * Vola_n / 100
//plot(bar_flow, 'bar_flow', color=color.green, display = display.none)
// calc avergae relative rate of flow, then smooth the resulting average
// classic formula would be this
//RROF = f_ma(bar_flow, length, MA_Type)
//
// or we can create a relative index by separating bulls from bears, like in an RSI
- my preferred method
// here we have an added benefit of plotting the (average) bulls vs bears
separately - as an option
bulls = math.max(bar_flow, 0)
bears = -1 * math.min(bar_flow, 0)
dx = bulls_avg / bears_avg
RROF = 2 * (100 - 100 / (1 + dx)) - 100
RROF_s = ta.wma(RROF, smooth)
//
===================================================================================
========================
// Colors & plots
//
===================================================================================
========================
c_up = color.aqua
c_dn = color.orange
up = RROF_s >= 0
s_up = RROF_bs >=0
// ==================================== Plots
==========================================================
// =============================================================================
// Plot Price Strength & Relative Volume as stacked "equalizer bands"
// adding visualization option to make the bands joint or separate at the mid-scale
mark
Eq_band_option = input.string("Joint", title = 'Band Option', options = ["Joint",
"Separate"], group = grp_4)
bar = bar_flow
vc_lo = 0
vc_hi = nVol * bandscale / 100 / 2
pc_lo = pc_lo_base
pc_hi = pc_lo_base + math.abs(nPrice) * bandscale / 100 / 2
//
===================================================================================
========================
// basic alerts
//
===================================================================================
========================
Alert_up = ta.crossover(RROF_s,0)
Alert_dn = ta.crossunder(RROF_s,0)
Alert_swing = ta.cross(RROF_s,0)
// "." in alert title for the alerts to show in the right order up/down/swing
//
===================================================================================
========================
// 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
nPrice_abs = math.abs(nPrice)
//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
//functions
xrf(values, length) =>
r_val = float(na)
if length >= 1
for i = 0 to length by 1
if na(r_val) or not na(values[i])
r_val := values[i]
r_val
r_val
lcbuy = fundtrend > bullbearline and not (fundtrend < xrf(fundtrend * 0.95, 1)) and
(fundtrend[1] <= bullbearline[1] or fundtrend[1] < xrf(fundtrend * 0.95, 1)[1] or
(fundtrend[1] < bullbearline[1] and fundtrend[1] > xrf(fundtrend * 0.95, 1)[1]))
lcsell = fundtrend < bullbearline and not (fundtrend < bullbearline and fundtrend >
xrf(fundtrend * 0.95, 1)) and (fundtrend[1] >= bullbearline[1] or (fundtrend[1] <
bullbearline[1] and fundtrend[1] > xrf(fundtrend * 0.95, 1)[1]))
rkefactbuy = true
for i = 1 to 5
if pc_hi[i] >= pc_hi and close[i] < open[i]
rkefactbuy := false
break
rkefactsell = true
for i = 1 to 5
if pc_hi[i] >= pc_hi and close[i] > open[i]
rkefactsell := false
break
rkebuy = pc_hi >= 75 and rkefactbuy and close > open
rkesell = pc_hi >= 75 and rkefactsell and close < open
plotshape(lcbuy and rkebuy and not bbbuy, "LC + RKE BUY", shape.labelup,
location.belowbar, color.blue, text = "2/3 BUY", textcolor = color.white)
plotshape(lcsell and rkesell and not bbsell, "LC + RKE SELL", shape.labeldown,
location.abovebar, color.fuchsia, text = "2/3 SELL", textcolor = color.white)
plotshape(bbbuy and rkebuy and not lcbuy, "BB + RKE BUY", shape.labelup,
location.belowbar, color.teal, text = "2/3 BUY", textcolor = color.white)
plotshape(bbsell and rkesell and not lcsell, "BB + RKE SELL", shape.labeldown,
location.abovebar, color.red, text = "2/3 SELL", textcolor = color.white)