Power of Pricaction
Power of Pricaction
//@version=5
if type == 'RMA'
ta.rma(source, length)
else if type == 'SMA'
ta.sma(source, length)
else if type == 'EMA'
ta.ema(source, length)
else if type == 'WMA'
ta.wma(source, length)
else if type == 'HMA'
if(length<2)
ta.hma(source,2)
else
ta.hma(source, length)
else
ta.vwma(source, length)
///////////////////////////////////////////////
///// Signal filters
/////////////////////////////////////////////
leadingindicator = input.string(title="Leading Indicator", defval="Range Filter",
options=["Range Filter", "Rational Quadratic Kernel (RQK)","Supertrend","Half
Trend","Ichimoku Cloud","SuperIchi","True Strength Indicator (TSI)","Trend
Direction Force Index (TDFI)","Trendline Breakout","Range Detector","Heiken-Ashi
Candlestick Oscillator","Donchian Trend Ribbon","Stochastic","RSI","Rate of Change
(ROC)","VWAP","CCI","2 EMA Cross","3 EMA Cross","B-Xtrender","Bull Bear Power
Trend","Detrended Price Oscillator (DPO)","BB Oscillator","Chandelier Exit","DMI
(Adx)","Parabolic SAR (PSAR)","MACD","SSL Channel","Waddah Attar
Explosion","Chaikin Money Flow","Vortex Index","Schaff Trend Cycle (STC)","Awesome
Oscillator","Volatility Oscillator","Wolfpack Id","QQE Mod","Hull Suite"],
group='████████ Main Indicator (signal) ████████', inline='li')
ema2_tooltip = "Generates Long signal if Fast EMA cross above Slow EMA.\n\n
Generates Short signal when Fast EMA cross below the Slow EMA.\n\n Default values
are 50 and 200. you can change that to meet your requirement."
respect2ma = input.bool (false, "2 EMA Cross : ", group=confirmation_group,
inline='2ma')
respect2maperiod_1 = input.int(defval=50, title='',group=confirmation_group,
inline='2ma')
respect2maperiod_2 = input.int(defval=200, title='',group=confirmation_group,
inline='2ma',tooltip=ema2_tooltip)
signal_type = input.string("Default", "Signal Type",group=confirmation_group,
options=["Default", "Lookback"], inline='2ma')
lookback_period = input.int(defval=3, title="Lookback
Period",group=confirmation_group, minval=1, tooltip="Number of candles to look back
for confirming the cross", inline='2ma')
ema3_tooltip = "Generates Long signal if first EMA (Fastest) cross above 2nd and
3rd EMA and 2nd EMA cross above 3rd EMA.\n\n Generates Short signal if first EMA
(Fastest) cross below 2nd and 3rd EMA and 2nd EMA cross below 3rd EMA .\n\n Default
values are 9,21 and 55. you can change that to meet your requirement."
respect3ma = input.bool (false, "3 EMA Cross : ", group=confirmation_group,
inline='3ma',tooltip=ema3_tooltip)
respect3maperiod_1 = input.int(defval=9, title='',group=confirmation_group,
inline='3ma',tooltip=ema3_tooltip)
respect3maperiod_2 = input.int(defval=21, title='',group=confirmation_group,
inline='3ma',tooltip=ema3_tooltip)
respect3maperiod_3 = input.int(defval=55, title='',group=confirmation_group,
inline='3ma',tooltip=ema3_tooltip)
tsitooltip = "Signal Crossover:\n\n TSI crossover or greater than signal line for
long, and TSI crossunder signal line for short.\n\n Zero Line Cross:\n\n TSI cross
above zero line and signal line for long signal. Tsi Cross below zero and signal
line for short signal."
tsitype = input.string(title="", defval="Signal Cross", options=["Signal Cross",
"Zero line cross"],tooltip=tsitooltip, group=confirmation_group, inline='tsi')
respecttdfi = input.bool (false, "Trend Direction Force Index (TDFI)",
group=confirmation_group, inline='tdfi')
/////////////////////////////////////////////////////////////////////////
// Switch Board
////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Fibonacci settings
fibgroup = "█████████ Fibonacci Display Settting █████████"
devTooltip = "Deviation is a multiplier that affects how much the price should
deviate from the previous pivot in order for the bar to become a new pivot."
depthTooltip = "The minimum number of bars that will be taken into account when
calculating the indicator."
threshold_multiplier2 = input.float(title="Deviation", defval=3, minval=0,
tooltip=devTooltip,group=fibgroup)
depth2 = input.int(title="Depth", defval=10, minval=2,
tooltip=depthTooltip,group=fibgroup)
reverse2 = input(false, "Reverse", display = display.data_window,group=fibgroup)
var extendLeft = input(false, "Extend Left | Extend Right", inline = "Extend
Lines",group=fibgroup)
var extendRight = input(true, "", inline = "Extend Lines",group=fibgroup)
var extending = extend.none
if extendLeft and extendRight
extending := extend.both
if extendLeft and not extendRight
extending := extend.left
if not extendLeft and extendRight
extending := extend.right
prices = input(false, "Show Prices", display = display.data_window,group=fibgroup)
levels = input(true, "Show Levels", inline = "Levels", display =
display.data_window,group=fibgroup)
levelsFormat = input.string("Values", "", options = ["Values", "Percent"], inline =
"Levels", display = display.data_window,group=fibgroup)
labelsPosition = input.string("Left", "Labels Position", options = ["Left",
"Right"], display = display.data_window,group=fibgroup)
var int backgroundTransparency = input.int(85, "Background Transparency", minval =
0, maxval = 100, display = display.data_window,group=fibgroup)
update() =>
var settings = zigzag.Settings.new(threshold_multiplier2, depth2, color(na),
false, false, false, false, "Absolute", true)
var zigzag.ZigZag zigZag = zigzag.newInstance(settings)
var zigzag.Pivot lastP = na
var float startPrice2 = na
var float height = na
settings.devThreshold := ta.atr(10) / close * 100 * threshold_multiplier2
if zigZag.update()
lastP := zigZag.lastPivot()
if not na(lastP)
var line lineLast = na
if switch_fibonacci
if na(lineLast)
lineLast := line.new(lastP.start, lastP.end,
xloc=xloc.bar_time, color=color.gray, width=1, style=line.style_dashed)
else
line.set_first_point(lineLast, lastP.start)
line.set_second_point(lineLast, lastP.end)
_wrap(txt) =>
"(" + str.tostring(txt, format.mintick) + ")"
/////////////////////////////////////////////////////////////////////////
// EMA Selection
////////////////////////////////////////////////////////////////////////
len2bool = input.bool(true,'',group=ma_group,inline='len2')
len2 = input.int(13, minval=1, title='MA 2',group=ma_group,inline='len2')
string ma_2_type = input.string(defval='EMA', title='Type', options=['RMA', 'SMA',
'EMA', 'WMA','HMA','VWMA'], inline='len2',group=ma_group)
color ma_2_colour = input.color(color.rgb(253, 84, 87, 0), '',
inline='len2',group=ma_group)
len3bool = input.bool(false,'',group=ma_group,inline='len3')
len3 = input.int(20, minval=1, title='MA 3',group=ma_group,inline='len3')
string ma_3_type = input.string(defval='EMA', title='Type', options=['RMA', 'SMA',
'EMA', 'WMA','HMA','VWMA'], inline='len3',group=ma_group)
color ma_3_colour = input.color(color.new(color.aqua, 0), '',
inline='len3',group=ma_group)
len4bool = input.bool(true,'',group=ma_group,inline='len4')
len4 = input.int(50, minval=1, title='MA 4',group=ma_group,inline='len4')
string ma_4_type = input.string(defval='EMA', title='Type', options=['RMA', 'SMA',
'EMA', 'WMA','HMA','VWMA'], inline='len4',group=ma_group)
color ma_4_colour = input.color(color.new(color.blue, 0), '',
inline='len4',group=ma_group)
len5bool = input.bool(true,'',group=ma_group,inline='len5')
len5 = input.int(200, minval=1, title='MA 5',group=ma_group,inline='len5')
string ma_5_type = input.string(defval='EMA', title='Type', options=['RMA', 'SMA',
'EMA', 'WMA','HMA','VWMA'], inline='len5',group=ma_group)
color ma_5_colour = input.color(color.new(color.white, 0), '',
inline='len5',group=ma_group)
////////////////////////////////////////////////////////////////////////////
//////////// 2EMA cross
////////////////////////////////////////////////////////////////////////////
var float first_2ema = 0
var float second_2ema = 0
// Calculate EMAs
first_2ema := ta.ema(close, respect2maperiod_1)
second_2ema := ta.ema(close, respect2maperiod_2)
if crossUp or crossDown
noCrosses = true
for i = 0 to lookback - 1
if (fast_series[i] > slow_series[i] and fast_series[i+1] <=
slow_series[i+1]) or
(fast_series[i] < slow_series[i] and fast_series[i+1] >=
slow_series[i+1])
noCrosses := false
break
if noCrosses
if crossUp
1
else
-1
else
0
else
0
if signal_type == "Default"
ema2_long := ta.crossover(first_2ema, second_2ema) ? 1 : 0
ema2_short := ta.crossunder(first_2ema, second_2ema) ? 1 : 0
else // Lookback method
crossDetected = detectCrossWithLookback(first_2ema, second_2ema,
lookback_period)
ema2_long := crossDetected == 1 and first_2ema > second_2ema ? 1 : 0
ema2_short := crossDetected == -1 and first_2ema < second_2ema ? 1 : 0
////////////////////////////////////////////////////////////////////////////
//////////// 3EMA cross
////////////////////////////////////////////////////////////////////////////
var float first_3ema = 0
var float second_3ema = 0
var float third_3ema = 0
if respect3ma or leadingindicator=='3 EMA Cross'
first_3ema := ta.ema(close, respect3maperiod_1)
second_3ema := ta.ema(close, respect3maperiod_2)
third_3ema := ta.ema(close, respect3maperiod_3)
//////////////////////////////////////////////////////////////////////////
// Pivots
//////////////////////////////////////////////////////////////////////////
DEFAULT_COLOR = #FB8C00
pColorInput = input.color(DEFAULT_COLOR, "P ", inline="P",group=pivot_group,
display = display.data_window)
pShowInput = input.bool(true, "", inline="P",group=pivot_group, display =
display.data_window)
s1ColorInput = input.color(DEFAULT_COLOR, "S1", inline="S1/R1" ,group=pivot_group,
display = display.data_window)
s1ShowInput = input.bool(true, "", inline="S1/R1",group=pivot_group, display =
display.data_window)
r1ColorInput = input.color(DEFAULT_COLOR, " R1",
inline="S1/R1",group=pivot_group, display = display.data_window)
r1ShowInput = input.bool(true, "", inline="S1/R1",group=pivot_group, display =
display.data_window)
s2ColorInput = input.color(DEFAULT_COLOR, "S2", inline="S2/R2",group=pivot_group,
display = display.data_window)
s2ShowInput = input.bool(true, "", inline="S2/R2",group=pivot_group, display =
display.data_window)
r2ColorInput = input.color(DEFAULT_COLOR, " R2",
inline="S2/R2",group=pivot_group, display = display.data_window)
r2ShowInput = input.bool(true, "", inline="S2/R2",group=pivot_group, tooltip = "Not
applicable to DM", display = display.data_window)
s3ColorInput = input.color(DEFAULT_COLOR, "S3", inline="S3/R3",group=pivot_group,
display = display.data_window)
s3ShowInput = input.bool(true, "", inline="S3/R3",group=pivot_group, display =
display.data_window)
r3ColorInput = input.color(DEFAULT_COLOR, " R3",
inline="S3/R3",group=pivot_group, display = display.data_window)
r3ShowInput = input.bool(true, "", inline="S3/R3",group=pivot_group, tooltip = "Not
applicable to DM", display = display.data_window)
s4ColorInput = input.color(DEFAULT_COLOR, "S4", inline="S4/R4",group=pivot_group,
display = display.data_window)
s4ShowInput = input.bool(true, "", inline="S4/R4",group=pivot_group, display =
display.data_window)
r4ColorInput = input.color(DEFAULT_COLOR, " R4",
inline="S4/R4",group=pivot_group, display = display.data_window)
r4ShowInput = input.bool(true, "", inline="S4/R4",group=pivot_group, tooltip = "Not
applicable to: Fibonacci, DM", display = display.data_window)
s5ColorInput = input.color(DEFAULT_COLOR, "S5", inline="S5/R5",group=pivot_group,
display = display.data_window)
s5ShowInput = input.bool(true, "", inline="S5/R5",group=pivot_group, display =
display.data_window)
r5ColorInput = input.color(DEFAULT_COLOR, " R5",
inline="S5/R5",group=pivot_group, display = display.data_window)
r5ShowInput = input.bool(true, "", inline="S5/R5",group=pivot_group, tooltip = "Not
applicable to: Fibonacci, Woodie, Classic, DM", display = display.data_window)
type graphicSettings
string levelName
color levelColor
bool showLevel
autoAnchor = switch
timeframe.isintraday => timeframe.multiplier <= 15 ? "1D" : "1W"
timeframe.isdaily => "1M"
=> "12M"
type pivotGraphic
line pivotLine
label pivotLabel
pivotTimeframeChangeCounter(condition) =>
var count = 0
if condition and bar_index > 0
count += 1
count
//@function Sets the ending points of the currently active pivots to `endTime`.
affixOldPivots(endTime) =>
if drawnGraphics.rows() > 0
lastGraphics = drawnGraphics.row(drawnGraphics.rows() - 1)
//@function Draws pivot lines and labels from `startTime` to the approximate end of
the period.
drawNewPivots(startTime) =>
newGraphics = array.new<pivotGraphic>()
newGraphics.push(pivotGraphic.new(pivotLine, pivotLabel))
drawnGraphics.add_row(array_id = newGraphics)
// If possible, draw pivots from the beginning of the chart if none were found
var FIRST_BAR_TIME = time
if (barstate.islastconfirmedhistory and drawnGraphics.columns() == 0 and
switch_pivot)
//////////////////////////////////////////////////////////////////////////
// William Fractals
//////////////////////////////////////////////////////////////////////////
// Define "n" as the number of periods and keep a minimum value of 2 for error
handling.
n = input.int(title="Periods", defval=2, minval=2,group="██████████ Fractal
██████████")
// UpFractal
bool upflagDownFrontier = true
bool upflagUpFrontier0 = true
bool upflagUpFrontier1 = true
bool upflagUpFrontier2 = true
bool upflagUpFrontier3 = true
bool upflagUpFrontier4 = true
if switch_fractal
for i = 1 to n
upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n])
upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n])
upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and
high[n+i + 1] < high[n])
upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and
high[n+2] <= high[n] and high[n+i + 2] < high[n])
upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and
high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n])
upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and
high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i
+ 4] < high[n])
flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or
upflagUpFrontier3 or upflagUpFrontier4
// downFractal
bool downflagDownFrontier = true
bool downflagUpFrontier0 = true
bool downflagUpFrontier1 = true
bool downflagUpFrontier2 = true
bool downflagUpFrontier3 = true
bool downflagUpFrontier4 = true
if switch_fractal
for i = 1 to n
downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n])
downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n])
downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and
low[n+i + 1] > low[n])
downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and
low[n+2] >= low[n] and low[n+i + 2] > low[n])
downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and
low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n])
downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and
low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] >
low[n])
flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or
downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4
//////////////////////////////////////////////////////////////////////////
// Range Filter
//////////////////////////////////////////////////////////////////////////
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
// Range Multiplier
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(src, per, mult)
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
// Target Bands
///////////////////////////////
////// RF2
///////////////////////////////
//Filter Type
f_type = input.string(defval='Type 1', options=['Type 1', 'Type 2'], title='Filter
Type')
//Movement Source
mov_src = input.string(defval='Close', options=['Wicks', 'Close'], title='Movement
Source')
//Range Period
rng_per = input.int(defval=14, minval=1, title='Range Period (for ATR, Average
Change, and Standard Deviation)')
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Definitions
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Direction Conditions
var fdir2 = 0.0
fdir2 := filt2 > filt2[1] ? 1 : filt2 < filt2[1] ? -1 : fdir2
rfupward = fdir2 == 1 ? 1 : 0
rfdownward= fdir2 == -1 ? 1 : 0
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//color and switchboard rf
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
filttype = string(na)
if rftype == "Default"
filttype := "filt"
else if rftype == "DW"
filttype := "filt2"
////////////////////////////////
/// RQK
////////////////////////////////
// Rates of Change
bool wasBearish = yhat1[2] > yhat1[1]
bool wasBullish = yhat1[2] < yhat1[1]
bool isBearish = yhat1[1] > yhat1
bool isBullish = yhat1[1] < yhat1
bool isBearishChange = isBearish and wasBullish
bool isBullishChange = isBullish and wasBearish
// Crossovers
bool isBullishCross = ta.crossover(yhat2, yhat1)
bool isBearishCross = ta.crossunder(yhat2, yhat1)
bool isBullishSmooth = yhat2 > yhat1
bool isBearishSmooth = yhat2 < yhat1
/////////////////////////////
////////// TSI
/////////////////////////////
tsi_group = "██████████ True Strength Indicator (TSI) ██████████"
////////////////////////////////
///// Super Trend
//////////////////////////////
/////////////////////////////////////////////
/////////// Half Trend
////////////////////////////////////////////
ht_atr2 = ta.atr(100) / 2
ht_dev = channelDeviation * ht_atr2
highPrice = high[math.abs(ta.highestbars(amplitude))]
lowPrice = low[math.abs(ta.lowestbars(amplitude))]
highma = ta.sma(high, amplitude)
lowma = ta.sma(low, amplitude)
if nextTrend == 1
maxLowPrice := math.max(lowPrice, maxLowPrice)
if ht_trend == 0
if not na(ht_trend[1]) and ht_trend[1] != 0
ht_up := na(ht_down[1]) ? ht_down : ht_down[1]
arrowUp := ht_up - ht_atr2
arrowUp
else
ht_up := na(ht_up[1]) ? maxLowPrice : math.max(maxLowPrice, ht_up[1])
ht_up
atrHigh := ht_up + ht_dev
atrLow := ht_up - ht_dev
atrLow
else
if not na(ht_trend[1]) and ht_trend[1] != 1
ht_down := na(ht_up[1]) ? ht_up : ht_up[1]
arrowDown := ht_down + ht_atr2
arrowDown
else
ht_down := na(ht_down[1]) ? minHighPrice : math.min(minHighPrice,
ht_down[1])
ht_down
atrHigh := ht_down + ht_dev
atrLow := ht_down - ht_dev
atrLow
halftrend_long := ht_trend == 0
halftrend_short := ht_trend != 0
//////////////////////////////////////
/////////////////////////////////////////////
///////// Trend Line Breakout
/////////////////////////////////////////////
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
var upos = 0
var dnos = 0
tb_buysignal = bool (na)
tb_sellsignal = bool (na)
//-----------------------------------------------------------------------------
}
//Calculations
//-----------------------------------------------------------------------------
{
var upper_tb = 0.
var lower_tb = 0.
var slope_ph = 0.
var slope_pl = 0.
n_tb = bar_index
src_tb = close
ph = ta.pivothigh(length_tb, length_tb)
pl = ta.pivotlow(length_tb, length_tb)
for i = 0 to signalexpiry - 1
tb_buysignal := upos[0] > upos[i+1]
tb_sellsignal := dnos[0] > dnos[i+1]
//////////////////////////////////////////////
////// Ichimoku
/////////////////////////////////////////////
fill(p1, p2, color = leadLine1 > leadLine2 and switch_ichi ? color.rgb(67, 160, 71,
70) : color.rgb(244, 67, 54, 70))
//////////////////////////////
///////// SuperIchi
/////////////////////////////
superichigroup = "██████████ SuperIchi ██████████"
offset = input(26,'Displacement',group=superichigroup)
//------------------------------------------------------------------------------
avg(src,length,mult)=>
atr = ta.atr(length)*mult
up = hl2 + atr
dn = hl2 - atr
upper = 0.,lower = 0.
upper := src[1] < upper[1] ? math.min(up,upper[1]) : up
lower := src[1] > lower[1] ? math.max(dn,lower[1]) : dn
os = 0,max = 0.,min = 0.
os := src > upper ? 1 : src < lower ? 0 : os[1]
spt = os == 1 ? lower : upper
max := ta.cross(src,spt) ? math.max(src,max[1]) : os == 1 ?
math.max(src,max[1]) : spt
min := ta.cross(src,spt) ? math.min(src,min[1]) : os == 0 ?
math.min(src,min[1]) : spt
math.avg(max,min)
//------------------------------------------------------------------------------
tenkan = avg(close,tenkan_len,tenkan_mult)
kijun = avg(close,kijun_len,kijun_mult)
senkouA = math.avg(kijun,tenkan)
senkouB = avg(close,spanB_len,spanB_mult)
//------------------------------------------------------------------------------
//////////////////////////////////
///////////Donchian Channel Ribbon
///////////////////////////////////
donchiangroup = "██████████ Donchian Channel Ribbon ██████████"
dlen = input.int(defval=15, title='Donchian Channel Period', group=donchiangroup)
dchannel(len) =>
float hh = ta.highest(len)
float ll = ta.lowest(len)
int trend = 0
trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
trend
int trend = 0
trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
maintrend == 1 ? trend == 1 ? #00FF00ff : #00FF009f : maintrend == -1 ? trend
== -1 ? #FF0000ff : #FF00009f : na
maintrend = dchannel(dlen)
////////////////////////////////
// DMI code
////////////////////////////////
lensig = adxlen
upp = ta.change(high)
downn = ta.change(low)
plusDM = na(upp) ? na : upp > downn and upp > 0 ? upp : 0
minusDM = na(downn) ? na : downn > upp and downn > 0 ? downn : 0
trur = ta.rma(ta.tr, dilen)
plus = fixnan(100 * ta.rma(plusDM, dilen) / trur)
minus = fixnan(100 * ta.rma(minusDM, dilen) / trur)
sum = plus + minus
adxx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
dirmov(dilen) =>
up = ta.change(high)
down = -ta.change(low)
truerange = ta.rma(ta.tr, dilen)
plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, dilen) / truerange)
minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, dilen) /
truerange)
[plus, minus]
////////////////////////////////////////////////
//Parabolic SAR
///////////////////////////////////////////////
//showsar = input.bool (false, "Show SAR", group='-------------------------
Parabolic SAR-------------------------')
psar_group = "██████████ Parabolic SAR (PSAR) ██████████"
start = input.float(0.02, group=psar_group, inline ='sar')
increment = input.float(0.02, group=psar_group, inline ='sar')
maximum = input.float(0.2, 'Max Value', group=psar_group, inline ='sar')
out = ta.sar(start, increment, maximum)
sarcolor = if (out>close)
color.red
else
color.green
if (switch_sar )
color.red
else
color.green
plot(switch_sar ? out : na, 'ParabolicSAR', style=plot.style_cross,
color=sarcolor)
//////////////////////////////////////////////////
///////// TDFI
/////////////////////////////////////////////////
rdfi_group = "█████ Trend Direction Force Index (TDFI) █████ "
tdfi() =>
mma = tdfi_ma(mmaMode, price * 1000, mmaLength)
smma = tdfi_ma(smmaMode, mma, smmaLength)
impetmma = mma - mma[1]
impetsmma = smma - smma[1]
divma = math.abs(mma - smma)
averimpet = (impetmma + impetsmma) / 2
tdf = math.pow(divma, 1) * math.pow(averimpet, nLength)
tdf / ta.highest(math.abs(tdf), lookback * nLength)
signal_tdfi = tdfi()
//////////////////////////////////////////////////
///////// CCI
/////////////////////////////////////////////////
cci_group = "████████████████████ CCI ████████████████████"
ccilength = input.int(20,title="CCI Length", minval=1,inline="cci",
group=cci_group)
ccisrc = input(hlc3, title="Source",inline="cci", group=cci_group)
cciupperband = input.int(100,title="Upper Band",inline="cci2", group=cci_group)
ccilowerband = input.int(-100,title="Lower Band",inline="cci2", group=cci_group)
ma = ta.sma(ccisrc, ccilength)
cci = (ccisrc - ma) / (0.015 * ta.dev(ccisrc, ccilength))
///////////////////////////////////////////////
/////// B-Xtrender
/////////////////////////////////////////////
maShortTermXtrender = t3(shortTermXtrender, 5)
bx_long = bool(na)
bx_short = bool(na)
////////////////////////////////////////////////
////// Bull Bear Power Trend (BBPT)
///////////////////////////////////////////////
BullTrend_hist = 0.0
BearTrend_hist = 0.0
if BullTrend < 2
BullTrend_hist := BullTrend - 2
BullTrend_hist
if BearTrend2 > -2
BearTrend_hist := BearTrend2 + 2
BearTrend_hist
bbpt_long = bool(na)
bbpt_short = bool(na)
if bbpttype =="Follow Trend"
bbpt_long := BearTrend_hist > 0 and Trend>=2
bbpt_short := BullTrend_hist < 0 and Trend<=-2
else if bbpttype == "Without Trend"
bbpt_long := BearTrend_hist > 0
bbpt_short := BullTrend_hist < 0
///////////////////////////////////////////////
//////////// VWAP
/////////////////////////////////////////////
float vwapValue = na
float upperBandValue1 = na
float lowerBandValue1 = na
float upperBandValue2 = na
float lowerBandValue2 = na
float upperBandValue3 = na
float lowerBandValue3 = na
long_vwap = close>vwapValue
short_vwap = close < vwapValue
////////////////////////////////////////////////
////// Chandelier Exit
///////////////////////////////////////////////
ce_long = dir == 1
ce_short = dir == -1
////////////////////////////////////////////////
////// ROC
///////////////////////////////////////////////
////////////////////////////////////////////////
////// SSL Channel
///////////////////////////////////////////////
ssl_long = sslUp>sslDown
ssl_short = sslUp<sslDown
////////////////////////////////////////////////
////// Chaikin Money Flow
///////////////////////////////////////////////
chaikin_long = mf>0
chaikin_short = mf<0
////////////////////////////////////////////////
////// Vortex INdex
///////////////////////////////////////////////
vortex_group = "██████████ Vortex Index ██████████"
/////////////////////////////////////////////////
////////Waddar Atar explosion (WAR)
//////////////////////////////////////////////////
group_wae = "██████████ Waddah Attar Explosion ██████████"
wae_long = trendUp and trendUp >e1 and e1 > deadzone and trendUp>deadzone
wae_short = trendDown and trendDown >e1 and e1 > deadzone and trendDown>deadzone
//////////////////////////////////////////////
////////// Range Detector
//////////////////////////////////////////////
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
rd_length = input.int(20, 'Minimum Range Length', minval = 2,group=rdgroup)
rd_mult = input.float(1., 'Range Width', minval = 0, step = 0.1,group=rdgroup)
rd_atrLen = input.int(500, 'ATR Length', minval = 1,group=rdgroup)
//Style
rd_upCss = input(#089981, 'Broken Upward', group = 'Style',group=rdgroup)
rd_dnCss = input(#f23645, 'Broken Downward', group = 'Style',group=rdgroup)
unbrokenCss = input(#2157f3, 'Unbroken', group = 'Style',group=rdgroup)
//-----------------------------------------------------------------------------}
//Detect and highlight ranges
//-----------------------------------------------------------------------------{
//Ranges drawings
var box bx = na
var line lvl = na
//Extensions
var float rd_max = na
var float rd_min = na
var rd_os = 0
color detect_css = na
rd_n = bar_index
rd_atr = ta.atr(rd_atrLen) * rd_mult
rd_ma = ta.sma(close, rd_length)
count = 0
for i = 0 to rd_length-1
count += math.abs(close[i] - rd_ma) > rd_atr ? 1 : 0
// if switch_rd
if count == 0 and count[1] != count
//Test for overlap and change coordinates
if rd_n[rd_length] <= bx.get_right()
rd_max := math.max(rd_ma + rd_atr, bx.get_top())
rd_min := math.min(rd_ma - rd_atr, bx.get_bottom())
if switch_rd
//Box new coordinates
bx.set_top(rd_max)
bx.set_rightbottom(rd_n, rd_min)
bx.set_bgcolor(color.new(unbrokenCss, 80))
else if count == 0
bx.set_right(rd_n)
lvl.set_x2(rd_n)
//Set color
if close > bx.get_top()
bx.set_bgcolor(color.new(rd_upCss, 80))
lvl.set_color(rd_upCss)
rd_os := 1
else if close < bx.get_bottom()
bx.set_bgcolor(color.new(rd_dnCss, 80))
lvl.set_color(rd_dnCss)
rd_os := -1
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
//Range detection bgcolor
bgcolor(detect_css)
//-----------------------------------------------------------------------------}
/////////////////////////////////////////////////
////////Volatility Oscillator
//////////////////////////////////////////////////
group_vo = "██████████ Volatility Oscillator ██████████"
volength = input(100, group = group_vo)
spike = close - open
vox = ta.stdev(spike,volength)
voy = ta.stdev(spike,volength) * -1
/////////////////////////////////////////////////
////////Detrended Price Oscillator (DPO)
//////////////////////////////////////////////////
group_dpo = "██████████ Detrended Price Oscillator (DPO) ██████████"
/////////////////////////////////////////////////
////////HACOLT
//////////////////////////////////////////////////
hacolt_group = "███████ Heiken-Ashi Candlestick Oscillator ███████"
ci_filter = ci_index<ci_limit
//////////////////////////////////////////////////
////////Damiani Volatmeter
//////////////////////////////////////////////////
vol = 0.0
s1_pivot=nz(vol[1], 0)
s3_pivot=nz(vol[3], 0)
//////////////////////////////////////////////
/////// MACD
/////////////////////////////////////////////
macd_group = "██████████ MACD ██████████"
fast_length = input(title="Fast Length", defval=12,group=macd_group)
slow_length = input(title="Slow Length", defval=26,group=macd_group)
macdsrc = input(title="Source", defval=close,group=macd_group)
signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50,
defval = 9,group=macd_group)
sma_source = input.string(title="Oscillator MA Type", defval="EMA",
options=["SMA", "EMA"],group=macd_group)
sma_signal = input.string(title="Signal Line MA Type", defval="EMA",
options=["SMA", "EMA"],group=macd_group)
/////////////////////////////////////////////
///// Awesome Oscillator
////////////////////////////////////////////
ao_long = bool(na)
ao_short = bool(na)
/////////////////////////////////////////////
///// WolfPack ID
////////////////////////////////////////////
wolfgroup = "██████████ Wolf Pack ID ██████████"
input1 = input(title='Fast Length', group=wolfgroup,defval=3)
input2 = input(title='Slow Length',group=wolfgroup, defval=8)
pivR = input(title='Wolfpack Wave Pivot Lookback Right', group=wolfgroup,defval=1)
pivL = input(title='Wolfpack Wave Pivot Lookback Left',group=wolfgroup, defval=15)
fastmaa = ta.ema(close, input1)
fastmab = ta.ema(close, input2)
wolfsrc = close
bspread = (fastmaa - fastmab) * 1.001
adline = 0
m = bspread > 0 ? color.new(color.lime, 0) : color.new(color.red, 0)
wolfup = ta.rma(math.max(ta.change(wolfsrc), 0), 3)
wolfdown = ta.rma(-math.min(ta.change(wolfsrc), 0), 3)
lbR = input(title='Divergence Pivot Lookback Right',group=wolfgroup, defval=1)
lbL = input(title='Divergence Pivot Lookback Left', group=wolfgroup,defval=10)
rangeUpper = input(title='Max of Lookback Range',group=wolfgroup, defval=100)
rangeLower = input(title='Min of Lookback Range', group=wolfgroup,defval=2)
osc = bspread
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
/////////////////////////////////////////////
///// Bollinger Band (BB)
////////////////////////////////////////////
bbosc_long = bool(na)
bbosc_short = bool(na)
bbcycle = 0
bbup = ta.crossover(j, usmooth)
bbdown = ta.crossunder(j, lsmooth)
bbcycle := bbup ? 1 : bbdown ? -1 : bbcycle[1]
// ////////////////////////////////////////////
// ///// Trend Meter
// ////////////////////////////////////////////
// tm_group = "██████████ Trend Meter ██████████"
// ShowTrendBar = true
// ////////////////Signals - Wave
Trend//////////////////////////////////////////////////////////////////////////////
///////////////////
// // Wave Trend
// ap = hlc3 // input(hlc3, "Wave Trend - Source")
// n1 = 9 //input(9, "Wave Trend - WT Channel Length")
// n2 = 12 // input(12, "Wave Trend - WT Average Length")
// esa = ta.ema(ap, n1)
// de = ta.ema(math.abs(ap - esa), n1)
// ci = (ap - esa) / (0.015 * de)
// tci = ta.ema(ci, n2)
// wt11 = tci
// wt22 = ta.sma(wt11, 3)
// // MA Inputs
// // MA Calculations
// // MA Crossover Condition
// // MA Direction Condition
// MACDfastMA = 12
// MACDslowMA = 26
// MACDsignalSmooth = 9
// FastMACDfastMA = 8
// FastMACDslowMA = 21
// FastMACDsignalSmooth = 5
// TopDog_Fast_MA = 5
// TopDog_Slow_MA = 20
// TopDog_Sig = 30
// TopDogMom = ta.ema(close, TopDog_Fast_MA) - ta.ema(close, TopDog_Slow_MA)
// haclose_tm = ohlc4
// haopen_tm = 0.0
// haopen_tm := na(haopen_tm[1]) ? (open + close) / 2 : (haopen_tm[1] +
haclose_tm[1]) / 2
// RSI5 = ta.rsi(close, 5)
// SignalLineLength1 = 21
// x = bar_index
// y = RSI13
// x_ = ta.sma(x, SignalLineLength1)
// y_ = ta.sma(y, SignalLineLength1)
// mx = ta.stdev(x, SignalLineLength1)
// my = ta.stdev(y, SignalLineLength1)
// c = ta.correlation(x, y, SignalLineLength1)
// slope = c * (my / mx)
// inter = y_ - slope * x_
// LinReg1 = x * slope + inter
// TrendFilterPlus = ta.ema(close, 15) > ta.ema(close, 20) and ta.ema(close, 20) >
ta.ema(close, 30) and ta.ema(close, 30) > ta.ema(close, 40) and ta.ema(close, 40) >
ta.ema(close, 50) ? 1 : 0
// TrendFilterMinus = ta.ema(close, 15) < ta.ema(close, 20) and ta.ema(close, 20) <
ta.ema(close, 30) and ta.ema(close, 30) < ta.ema(close, 40) and ta.ema(close, 40) <
ta.ema(close, 50) ? 1 : 0
// ////////////////////////////////////////////////////////////////////////////////
///////////////////////////////
/////////////////////////////////
/////// Stochastic
/////////////////////////////////
groupname = "██████████ Stochastic ██████████"
len = input.int(14, minval=1, title="Length",group=groupname)
smoothK = input.int(3, minval=1, title="K Smoothing",group=groupname)
smoothD = input.int(3, minval=1, title="D Smoothing",group=groupname)
upLine = input.int(80, minval=50, maxval=90, title="Overbought
level",group=groupname)
lowLine = input.int(20, minval=10, maxval=50, title="Oversold
level",group=groupname)
///////////////////////////////////////////////
///////RSI
///////////////////////////////////////////////
///////////////////////////////////////////////
/// HULL SUITE
//////////////////////////////////////////////
hull_group = "██████████ HullSuite ██████████"
//INPUT
hullsrc = input(close, title='Source',group=hull_group)
modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma',
'Ehma'],group=hull_group)
hull_length = input(55, title='hull_length(180-200 for floating S/R , 55 for swing
entry)',group=hull_group)
hull_lengthMult = input(1.0, title='hull_length multiplier (Used to view higher
timeframes with straight band)',group=hull_group)
//FUNCTIONS
//HMA
HMA(_hullsrc, _hull_length) =>
ta.wma(2 * ta.wma(_hullsrc, _hull_length / 2) - ta.wma(_hullsrc, _hull_length),
math.round(math.sqrt(_hull_length)))
//EHMA
EHMA(_hullsrc, _hull_length) =>
ta.ema(2 * ta.ema(_hullsrc, _hull_length / 2) - ta.ema(_hullsrc, _hull_length),
math.round(math.sqrt(_hull_length)))
//THMA
THMA(_hullsrc, _hull_length) =>
ta.wma(ta.wma(_hullsrc, _hull_length / 3) * 3 - ta.wma(_hullsrc, _hull_length /
2) - ta.wma(_hullsrc, _hull_length), _hull_length)
//SWITCH
Mode(modeSwitch, hullsrc, len) =>
modeSwitch == 'Hma' ? HMA(hullsrc, len) : modeSwitch == 'Ehma' ? EHMA(hullsrc,
len) : modeSwitch == 'Thma' ? THMA(hullsrc, len / 2) : na
//OUT
_hull = Mode(modeSwitch, hullsrc, int(hull_length * hull_lengthMult))
HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull
MHULL = HULL[0]
SHULL = HULL[2]
//COLOR
// hullColor = switchColor ? HULL > HULL[2] ? #00ff00 : #ff0000 : #ff9800
/////////////////////////
/// STC overlay signal
/////////////////////////
stc_group = "██████████ Schaff Trend Cycle (STC) ██████████"
fastLength = input(title='MACD Fast Length', defval=23, group=stc_group)
slowLength = input(title='MACD Slow Length', defval=50, group=stc_group)
cycleLength = input(title='Cycle Length', defval=10, group=stc_group)
d1Length = input(title='1st %D Length', defval=3, group=stc_group)
d2Length = input(title='2nd %D Length', defval=3, group=stc_group)
srcstc = input(title='Source', defval=close, group=stc_group)
upper = input(title='Upper Band', defval=75, group=stc_group)
lower = input(title='Lower Band', defval=25, group=stc_group)
v_show_last = input(2000, "Plotting Length", group=stc_group)
//////////////////////////////////////////////////////
//vector candles
/////////////////////////////////////////////////////
// Indicator Settings
if isBull
if va == 1
candleColor := Bull200CandleColor
is200Bull := true
else
if va == 2
candleColor := Bull150CandleColor
is150Bull := true
else
is200Bull := false
is150Bull := false
candleColor := BullNormCandleColor
imbalanceColor := na
imbalancedLineColor := na
else
if va == 1
candleColor := Bear200CandleColor
is200Bear := true
else
if va == 2
candleColor := Bear150CandleColor
is150Bear := true
else
is200Bear := false
is150Bear := false
candleColor := BearNormCandleColor
imbalanceColor := na
imbalancedLineColor := na
///////////////////////////////////////////////////
//////// SUpply/Demand POI
//////////////////////////////////////////////////
// INDICATOR SETTINGS
poi_group = '██████████ Supply/Demand Zone ██████████'
swing_length = input.int(10, title = 'Swing High/Low Length', group = poi_group,
minval = 1, maxval = 50)
history_of_demand_to_keep = input.int(20, title = 'History To Keep', minval = 5,
maxval = 50, group = poi_group)
box_width = input.float(2.5, title = 'Supply/Demand Box Width', group = poi_group,
minval = 1, maxval = 10, step = 0.5)
//
//END SETTINGS
//
atrpoi = ta.atr(50)
//
//FUNCTIONS
//
else if swing_type == -1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array,0), text = label_text,
style=label.style_label_up, textcolor = swing_type_color, color =
color.new(swing_type_color, 100), size = size.tiny)
atr_threshold = atrpoi * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw and switch_poi
box.delete( array.get(box_array, array.size(box_array) - 1) )
f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right =
box_right, bottom = box_bottom, border_color = supply_outline_color,
bgcolor = supply_color, extend = extend.right, text = 'SUPPLY',
text_halign = text.align_center, text_valign = text.align_center, text_color =
poi_label_color, text_size = size.small, xloc = xloc.bar_index))
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
//ZIG ZAG
h = ta.highest(high, swing_length * 2 + 1)
l = ta.lowest(low, swing_length * 2 + 1)
f_isMin(len) =>
l == low[len]
f_isMax(len) =>
h == high[len]
f_drawLine() =>
_li_color = show_zigzag and switch_poi ? zigzag_color : color.new(#ffffff,100)
line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow,
xloc.bar_index, color=_li_color, width=2)
if dirUp
if f_isMin(swing_length) and low[swing_length] < lastLow
lastLow := low[swing_length]
timeLow := bar_index
line.delete(li)
li := f_drawLine()
li
if not dirUp
if f_isMax(swing_length) and high[swing_length] > lastHigh
lastHigh := high[swing_length]
timeHigh := bar_index
line.delete(li)
li := f_drawLine()
li
if f_isMin(swing_length) and low[swing_length] < lastHigh
lastLow := low[swing_length]
timeLow := bar_index
dirUp := true
li := f_drawLine()
if f_isMax(swing_length) and high[swing_length] > lastLow
lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li
///////////////////////////////////////////////////
///////// Heiken Ashi Candle
////////////////////////////////////////////////////
plotcandle(
hkOpen, hkHigh, hkLow, hkClose,
"Hollow Candles",
switch_ha ? (hollow ? hkClose < hkOpen ? BodyBear : na : candle ? hkClose <
hkOpen ? BodyBear : BodyBull : na) : na,
switch_ha ? (hollow or candle ? hkClose < hkOpen ? WickBear : WickBull : na) :
na,
bordercolor = switch_ha ? (hollow or candle ? hkClose < hkOpen ? BorderBear :
BorderBull : na) : na)
///////////////////////////////////////////////////
///////// Fair Value gap
////////////////////////////////////////////////////
fvggroup = "██████████ Fair Value Gap (FVG) ██████████"
numDays = input.int(7, "number of days lookback",group=fvggroup)
showUP = input.bool(true, "'UP' FVGs:", inline ='1',group=fvggroup)
colUp = input.color(color.new(color.blue, 86), "", inline ='1',group=fvggroup)
showDN = input.bool(true, "'DOWN' FVGs:", inline ='2',group=fvggroup)
colDn = input.color(color.new(color.orange, 86), "", inline ='2',group=fvggroup)
showCE = input.bool(true, "show CE", inline ='3',group=fvggroup)
ceCol = input.color(color.new(color.black, 1), "| color:", inline
='3',group=fvggroup)
ceStyle = input.string(line.style_dotted, "| style:",
options=[line.style_dotted,line.style_solid, line.style_dashed], inline
='3',group=fvggroup)
deleteFilledBoxes = input.bool(true, "delete filled boxes & lines",group=fvggroup)
CEcond = input.bool (false, "Use CE (as opposed to Full Fill)",group=fvggroup,
tooltip = "If toggled OFF, FVGs and CEs will paint until FVG has been completely
filled.\n\nThis threshold is used for Above/Below threshold Alert conditions too
(but does not effect the IOFED alerts):\ni.e. this will determine if your 'ABOVE
threshold' alert fires when price hits most recent FVG CE ABOVE or most recent FVG
Full Fill ABOVE\n\nAlerts are set by clicking the three dots on the indicator
display line.")
colorNone = color.new(color.white, 100)
_day = 24*3600*1000
var box bxUp = na, var box bxDn = na, var line lnUp = na, var line lnDn = na
var array<box> bxUpArr = array.new<box>(0), var array<line> lnUpArr =
array.new<line>(0)
var array<box> bxDnArr = array.new<box>(0), var array<line> lnDnArr =
array.new<line>(0)
dnCE = high[1] + (low[3]-high[1])/2
upCE = low[1] - (low[1]-high[3])/2
if low[3] > high[1] and time> timenow- numDays*_day and showDN and switch_fvg
bxDnArr.push(box.new(bar_index-3, low[3], bar_index, high[1], bgcolor = colDn,
border_color = colorNone))
lnDnArr.push(line.new(bar_index-3, dnCE, bar_index, dnCE, color = showCE?
ceCol:colorNone, style =ceStyle))
if high[3] < low[1] and time> timenow- numDays*_day and showUP and switch_fvg
bxUpArr.push(box.new(bar_index-3, low[1], bar_index, high[3], bgcolor = colUp,
border_color = colorNone))
lnUpArr.push(line.new(bar_index-3, upCE, bar_index, upCE, color = showCE?
ceCol:colorNone, style =ceStyle))
upThresholdLst = array.sum(_countArr)>array.sum(_countArr)[1]
dnThresholdLst = array.sum(_countArr)<array.sum(_countArr)[1]
upIOFEDlast= array.sum(_countArrIOFED)>array.sum(_countArrIOFED)[1]
dnIOFEDlast= array.sum(_countArrIOFED)<array.sum(_countArrIOFED)[1]
///////////////////////////////////////////////////
/////////// Vector Zone
//////////////////////////////////////////////////
//*****************
// Market sessions
//*****************
splitSessionString(sessXTime) =>
//session stirng looks like this: 0000-0000:1234567 ie start time, end time,
day of the week
//we need to parse the sessXTime string into hours and min for start and end
times so we can use those in the timestampfunction below
//now we need to get the start hour and start min, sing 0 index - hour is the
characters in index 0 and index 1 while min is the chars at index 2 and 3
string[] startTimeChars = str.split(startTime, '')
string[] endTimeChars = str.split(endTime, '')
//if start hour is greater than end hour we are dealing with a session that
starts towards the end of one day
//and ends the next day. ie advance the end time by 24 hours - its the next day
bool adjusted = false
if gmt == 'GMT+0'
if math.round(str.tonumber(startHour)) > math.round(str.tonumber(endHour))
if time_now - targetstartTimeX >= 0
targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
adjusted := true
targetendTimeX
if gmt == 'GMT+1'
if math.round(str.tonumber(startHour)) == 0
startHour := '24'
if math.round(str.tonumber(endHour)) == 0
endHour := '24'
if math.round(str.tonumber(startHour))-1 >
math.round(str.tonumber(endHour))-1
if time_now - targetstartTimeX >= 0
targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
adjusted := true
targetendTimeX
[targetstartTimeX,targetendTimeX]
draw_open_range(sessXTime, sessXcol, show_orX, gmt)=>
if show_orX
// Initialize variables on bar zero only, so they preserve their values
across bars.
var hi = float(na)
var lo = float(na)
var box hiLoBox = na
// Detect changes in timeframe.
session = time(timeframe.period, sessXTime, gmt)
bool newTF = session and not session[1]
if newTF
// New bar in higher timeframe; reset values and create new lines and
box.
[targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime,
gmt)
sessionDuration = math.round(math.abs(time -
targetendTimeX)/(timeframe.multiplier*60*1000))
hi := high
lo := low
hiLoBox := box.new(bar_index, hi, timeframe.multiplier == 1?
bar_index : bar_index+sessionDuration, lo, border_color = na, bgcolor = sessXcol)
int(na)
else
if timeframe.multiplier == 1 and (na(session[1]) and not na(session) or
session[1] < session)
box.set_right(hiLoBox, bar_index+1)
int(na)
draw_session_hilo(sessXTime, show_rectangleX, show_labelX, sessXcolLabel,
sessXLabel, gmt)=>
if show_rectangleX
// Initialize variables on bar zero only, so they preserve their values
across bars.
var hi = float(0)
var lo = float(10000000000.0)
if newTF
beginIndex = bar_index
[targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime,
gmt)
sessionDuration = math.round(math.abs(time -
targetendTimeX)/(timeframe.multiplier*60*1000))
int(na)
else
if na(session[1]) and not na(session) or session[1] < session
if timeframe.multiplier == 1
line.set_x2(line_t,bar_index+1)
line.set_x2(line_b,bar_index+1)
line.set_y1(line_t,hi)
line.set_y2(line_t,hi)
line.set_y1(line_b,lo)
line.set_y2(line_b,lo)
if show_labelX and not na(line_label)
label.set_y(line_label, hi)
int(na)
//*****************************//
// Daylight Savings Time Flags //
//*****************************//
if ukDST
draw_open_range(sess1Time,sess1col,show_or1,'GMT+1')
draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel,
sess1Label, 'GMT+1')
else
draw_open_range(sess1Time,sess1col,show_or1,'GMT+0')
draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel,
sess1Label, 'GMT+0')
if nyDST
draw_open_range(sess2Time,sess2col,show_or2,'GMT+1')
draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel,
sess2Label, 'GMT+1')
else
draw_open_range(sess2Time,sess2col,show_or2,'GMT+0')
draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel,
sess2Label, 'GMT+0')
// Tokyo
draw_open_range(sess3Time,sess3col,show_or3,'GMT+0')
draw_session_hilo(sess3Time, show_rectangle3, show_label3, sess3colLabel,
sess3Label, 'GMT+0')
// Hong Kong
draw_open_range(sess4Time,sess4col,show_or4,'GMT+0')
draw_session_hilo(sess4Time, show_rectangle4, show_label4, sess4colLabel,
sess4Label, 'GMT+0')
if sydDST
draw_open_range(sess5Time,sess5col,show_or5,'GMT+1')
draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel,
sess5Label, 'GMT+1')
else
draw_open_range(sess5Time,sess5col,show_or5,'GMT+0')
draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel,
sess5Label, 'GMT+0')
if nyDST
draw_open_range(sess7Time,sess7col,show_or7,'GMT+1')
draw_session_hilo(sess7Time, show_rectangle7, show_label7, sess7colLabel,
sess7Label, 'GMT+1')
else
draw_open_range(sess7Time,sess7col,show_or7,'GMT+0')
draw_session_hilo(sess7Time, show_rectangle7, show_label7, sess7colLabel,
sess7Label, 'GMT+0')
//////////////////////////////////////////////////
////QQE MOD
/////////////////////////////////////////////////
qqe_gorup = "██████████ QQE ██████████"
RSI_Period = input(6, title='RSI Length', group=qqe_gorup)
SF = input(5, title='RSI Smoothing', group=qqe_gorup)
QQE = input(3, title='Fast QQE Factor', group=qqe_gorup)
ThreshHold = input(3, title='Thresh-hold', group=qqe_gorup)
//
//
Wilders_Period = RSI_Period * 2 - 1
longband = 0.0
shortband = 0.0
trend = 0
DeltaFastAtrRsi = dar
RSIndex = RsiMa
newshortband = RSIndex + DeltaFastAtrRsi
newlongband = RSIndex - DeltaFastAtrRsi
longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ?
math.max(longband[1], newlongband) : newlongband
shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ?
math.min(shortband[1], newshortband) : newshortband
cross_1 = ta.cross(longband[1], RSIndex)
trend := ta.cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1)
FastAtrRsiTL = trend == 1 ? longband : shortband
//
// Zero cross
QQEzlong = 0
QQEzlong := nz(QQEzlong[1])
QQEzshort = 0
QQEzshort := nz(QQEzshort[1])
QQEzlong := RSIndex >= 50 ? QQEzlong + 1 : 0
QQEzshort := RSIndex < 50 ? QQEzshort + 1 : 0
//
////////////////////////////////////////////////////////////////
//
Wilders_Period2 = RSI_Period2 * 2 - 1
DeltaFastAtrRsi2 = dar2
RSIndex2 = RsiMa2
newshortband2 = RSIndex2 + DeltaFastAtrRsi2
newlongband2 = RSIndex2 - DeltaFastAtrRsi2
longband2 := RSIndex2[1] > longband2[1] and RSIndex2 > longband2[1] ?
math.max(longband2[1], newlongband2) : newlongband2
shortband2 := RSIndex2[1] < shortband2[1] and RSIndex2 < shortband2[1] ?
math.min(shortband2[1], newshortband2) : newshortband2
cross_2 = ta.cross(longband2[1], RSIndex2)
trend2 := ta.cross(RSIndex2, shortband2[1]) ? 1 : cross_2 ? -1 : nz(trend2[1], 1)
FastAtrRsi2TL = trend2 == 1 ? longband2 : shortband2
//
// Zero cross
QQE2zlong = 0
QQE2zlong := nz(QQE2zlong[1])
QQE2zshort = 0
QQE2zshort := nz(QQE2zshort[1])
QQE2zlong := RSIndex2 >= 50 ? QQE2zlong + 1 : 0
QQE2zshort := RSIndex2 < 50 ? QQE2zshort + 1 : 0
//
qqeline = FastAtrRsi2TL - 50
// hcolor2 = RsiMa2 - 50 > ThreshHold2 ? color.silver : RsiMa2 - 50 < 0 -
ThreshHold2 ? color.silver : na
upAndDownVolume() =>
posVol = 0.0
negVol = 0.0
switch
close > open => posVol += volume
close < open => negVol -= volume
close >= close[1] => posVol += volume
close < close[1] => negVol -= volume
[posVol, negVol]
lowerTimeframe = switch
useCustomTimeframeInput => lowerTimeframeInput
timeframe.isintraday => "1"
timeframe.isdaily => "5"
=> "60"
upVolume = array.sum(upVolumeArray)
downVolume = array.sum(downVolumeArray)
delta = upVolume + downVolume
prevdelta = delta[1]
var cumVol = 0.
cumVol += nz(volume)
if barstate.islast and cumVol == 0
runtime.error("The data vendor doesn't provide volume data for this symbol.")
if dvtype == 'Threshold'
dvup := vol > t and vol>=1.1
else if dvtype == '10p Difference'
dvup := vol > t and (vol - t >= 0.1)
else
dvup := vol > t
longvol = bool(na)
shortvol = bool (na)
if volumetype == 'Delta'
longvol := delta > 0 and delta > delta[1]
shortvol := delta < 0 and delta < delta[1]
else if volumetype == 'volume above MA'
longvol := volume_abovema_signal
shortvol := volume_abovema_signal
else
longvol := upVolume > upVolume[1]
shortvol := downVolume < downVolume[1]
longCond = bool(na)
shortCond = bool(na)
longCond2 = bool(na)
shortCond2 = bool(na)
vipcondition = bool(na)
vimcondition = bool(na)
if vitype == 'Simple'
vipcondition := vip > vim
vimcondition := vip < vim
else
vipcondition := vip > vim and vip > viupper and vip > vip[1] and vim < vim[1]
and vim[1] <= vilower and vip[1] >= viupper
vimcondition := vip < vim and vim > viupper and vim > vim[1] and vip < vip [1]
and vip[1] <= vilower and vim [1] >= viupper
///////////////////////////////////ADX
Condition ////////////////////////////////////////
adxcycle = 0
adxup = ta.crossover(adx, keyLevel)
adxdown = ta.crossunder(adx, keyLevel)
adxcycle := adxup ? 1 : adxdown ? -1 : adxcycle[1]
adxcondition = string(na)
adxupcondition = bool(na)
adxdowncondition = bool (na)
if adxtype == 'Adx & +Di -Di'
adxupcondition := diplus > diminus and adx>=keyLevel
adxdowncondition := diplus < diminus and adx>=keyLevel
if adxtype == 'Adx Only'
adxupcondition := adx>keyLevel
adxdowncondition := adx>keyLevel
else
if adxcycle == -1
adxupcondition := diplus > diminus and adx>=keyLevel and diplus - diminus >
1
adxdowncondition := diplus < diminus and adx>=keyLevel and diminus - diplus
> 1
else if adxcycle==1
adxupcondition := diplus > diminus and adx>=keyLevel and adx<55 and
(adx>adx[1] or (diplus > diplus[1] and diminus < diminus[1])) and diplus - diminus
> 1
adxdowncondition := diplus < diminus and adx>=keyLevel and adx<55 and
(adx>adx[1] or (diplus < diplus[1] and diminus > diminus[1])) and diminus - diplus
> 1
///////////////adx condition
end/////////////////////////////////////////////////////
justcontinue = bool(true)
isstup = bool(na)
isstdown = bool(na)
isstup := sttrend == 1
isstdown := sttrend != 1
ismacdup = bool(na)
ismacddown = bool(na)
isqqeabove = bool(na)
isqqebelow = bool(na)
if qqetype == 'Line'
isqqeabove := qqeline>0
isqqebelow := qqeline<0
else if qqetype == 'Bar'
isqqeabove := RsiMa2 - 50 > 0 and (Greenbar1 and Greenbar2)
isqqebelow := RsiMa2 - 50 < 0 and (Redbar1 and Redbar2)
else if qqetype == 'Line & Bar'
isqqeabove := RsiMa2 - 50 > 0 and (Greenbar1 and Greenbar2) and qqeline>0
isqqebelow := RsiMa2 - 50 < 0 and (Redbar1 and Redbar2) and qqeline<0
rsimalong2 = bool(na)
rsimashort2 = bool(na)
leadinglongcond = bool(na)
leadingshortcond = bool(na)
if rftype == 'Default'
leadinglongcond := src > filt and src > src[1] and upward > 0 or src > filt
and src < src[1] and upward > 0
leadingshortcond := src < filt and src < src[1] and downward > 0 or src <
filt and src > src[1] and downward > 0
else if rftype == 'DW'
leadinglongcond := rfupward
leadingshortcond := rfdownward
if vitype == 'Simple'
leadinglongcond := vip > vim
leadingshortcond := vip < vim
else
leadinglongcond := vip > vim and vip > viupper and vip > vip[1] and vim <
vim[1] and vim[1] <= vilower and vip[1] >= viupper
leadingshortcond := vip < vim and vim > viupper and vim > vim[1] and vip <
vip [1] and vip[1] <= vilower and vim [1] >= viupper
leadinglongcond := sttrend == 1
leadingshortcond := sttrend != 1
leadinglongcond := halftrend_long
leadingshortcond := halftrend_short
leadinglongcond := wae_long
leadingshortcond := wae_short
tmup = bool(na)
tmdown = bool(na)
hullup = bool(na)
hulldown = bool(na)
if respecthull
hullup := HULL > HULL[2]
hulldown := HULL < HULL[2]
rsiup = bool (na)
rsidown = bool (na)
if rftype == 'Default'
uprf := src > filt and src > src[1] and upward > 0 or src > filt and src <
src[1] and upward > 0
downrf := src < filt and src < src[1] and downward > 0 or src < filt and src >
src[1] and downward > 0
else if rftype == 'DW'
uprf := rfupward
downrf := rfdownward
//and (respecttm?tmup:justcontinue)
//and (respecttm?tmdown:justcontinue)
if leadinglongcond
leadinglong_count := leadinglong_count + 1
leadinglong_count2 := leadinglong_count
for i = 1 to 100
if leadinglongcond[i]
leadinglong_count := leadinglong_count + 1
leadinglong_count2 := leadinglong_count
else
leadinglong_count := 0
break
if leadingshortcond
leadingshort_count := leadingshort_count + 1
leadingshort_count2 := leadingshort_count
for i = 1 to 100
if leadingshortcond[i]
leadingshort_count := leadingshort_count + 1
leadingshort_count2 := leadingshort_count
else
leadingshort_count := 0
break
CondIni = 0
log.info("leadinglong_count2 : {0}",leadinglong_count2)
log.info("leadingshort_count2: {0}",leadingshort_count2)
//without expiry
longCondition := longcond_withexpiry and CondIni[1] == -1
shortCondition := shortcond_withexpiry and CondIni[1] == 1
if alternatesignal
longCondition := longcond_withexpiry and CondIni[1] == -1
shortCondition := shortcond_withexpiry and CondIni[1] == 1
else
longCondition := longcond_withexpiry
shortCondition := shortcond_withexpiry
rsitype2 = rsitype
if rsitype2 == "RSI Level"
rsitype2 := "RSI Level (" + str.tostring(respectrsilevel) +")"
confirmation_counter = array.new_string(0)
confirmation_val = array.new_string(0)
confirmation_val_short = array.new_string(0)
getFalseShortConditionItems(arrShort) =>
sShort = ""
if array.size(arrShort) > 0
for i = 0 to array.size(arrShort) - 1
if array.get(arrShort, i) == "❌"
sShort := sShort + array.get(confirmation_counter, i) + "\n"
sShort
falseShortConditionString = getFalseShortConditionItems(confirmation_val_short)
if labelShortCondition
label.new(bar_index, low, "🔴", color=color.new(#dd1111, 0),
textcolor=color.white, style=label.style_none, yloc=yloc.belowbar, size=size.small,
tooltip=tooltipS)
getFalseLongConditionItems(arr) =>
s = ""
if array.size(arr) > 0
for i = 0 to array.size(arr) - 1
if array.get(arr, i) == "❌"
s := s + array.get(confirmation_counter, i) + "\n"
s
falseLongConditionString = getFalseLongConditionItems(confirmation_val)
if labelCondition
label.new(bar_index, high, "🔴", color=color.new(color.green, 0),
textcolor=color.white, style=label.style_none, yloc=yloc.abovebar, size=size.small,
tooltip=tooltipL)
rowcount = int(na)
if array.size(confirmation_counter) ==0
rowcount := 5
else
rowcount := array.size(confirmation_counter)+4
if showdashboard
var table tab1 = table.new(i_tab1Ypos + '_' + i_tab1Xpos, 3, rowcount,
color.rgb(42, 46, 57), color.rgb(204, 204, 204), 0, color.rgb(77, 71, 71), 1)
if array.size(confirmation_counter) > 0
for i=0 to array.size(confirmation_counter)-1
table.cell(tab1, 0, 4+i, array.get(confirmation_counter,i),
text_halign=text.align_left, text_size=table_size(in_dashboardtab_size),
text_color=color.white)
else
table.cell(tab1, 0, 4, "None Selected", text_halign=text.align_left,
text_size=table_size(in_dashboardtab_size), text_color=color.white)
if array.size(confirmation_val) > 0
for j=0 to array.size(confirmation_val)-1
table.cell(tab1, 1, 4+j, array.get(confirmation_val,j),
text_halign=text.align_left, text_size=table_size(in_dashboardtab_size),
text_color=color.white)
table.cell(tab1, 2, 4+j, array.get(confirmation_val_short,j),
text_halign=text.align_left, text_size=table_size(in_dashboardtab_size),
text_color=color.white)