Range Filter - B&S Signals+OB+SND// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// Credits to the original Script - Range Filter DonovanWall
// This version is the old version of the Range Filter with less settings to tinker with
//@version=5
indicator(title='Range Filter - B&S; Signals+OB+SND', shorttitle='RF - B&S; Signals+OB+SND', overlay=true, max_labels_count = 500, max_boxes_count = 500, max_lines_count = 500)
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Functions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Range Size Function
rng_size(x, qty, n) =>
// AC = Cond_EMA(abs(x - x ), 1, n)
wper = n * 2 - 1
avrng = ta.ema(math.abs(x - x ), n)
AC = ta.ema(avrng, wper) * qty
rng_size = AC
rng_size
//Range Filter Function
rng_filt(x, rng_, n) =>
r = rng_
var rfilt = array.new_float(2, x)
array.set(rfilt, 1, array.get(rfilt, 0))
if x - r > array.get(rfilt, 1)
array.set(rfilt, 0, x - r)
if x + r < array.get(rfilt, 1)
array.set(rfilt, 0, x + r)
rng_filt1 = array.get(rfilt, 0)
hi_band = rng_filt1 + r
lo_band = rng_filt1 - r
rng_filt = rng_filt1
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Range Source
rng_src = input(defval=close, title='Swing Source')
//Range Period
rng_per = input.int(defval=200, minval=1, title='Swing Period')
//Range Size Inputs
rng_qty = input.float(defval=7.5, minval=0.0000001, title='Swing Multiplier')
//Bar Colors
use_barcolor = input(defval=true, title='Bar Colors On/Off')
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Range Filter Values
= rng_filt(rng_src, rng_size(rng_src, rng_qty, rng_per), rng_per)
//Direction Conditions
var fdir = 0.0
fdir := filt > filt ? 1 : filt < filt ? -1 : fdir
upward = fdir == 1 ? 1 : 0
downward = fdir == -1 ? 1 : 0
//Trading Condition
longCond = rng_src > filt and rng_src > rng_src and upward > 0 or rng_src > filt and rng_src < rng_src and upward > 0
shortCond = rng_src < filt and rng_src < rng_src and downward > 0 or rng_src < filt and rng_src > rng_src and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni
longCondition = longCond and CondIni == -1
shortCondition = shortCond and CondIni == 1
//Colors
filt_color = upward ? #2adf06e5 : downward ? #ec0606e0 : #cccccc
bar_color = upward and rng_src > filt ? rng_src > rng_src ? #76ff05 : #76ff05 : downward and rng_src < filt ? rng_src < rng_src ? #ff0505 : #ff0505 : #109404
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Outputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Filter Plot
filt_plot = plot(filt, color=filt_color, linewidth=3, title='Filter', transp=67)
//Band Plots
h_band_plot = plot(h_band, color=color.new(#05ff9b, 100), title='High Band')
l_band_plot = plot(l_band, color=color.new(#ff0583, 100), title='Low Band')
//Band Fills
fill(h_band_plot, filt_plot, color=#00b36b00, title='High Band Fill')
fill(l_band_plot, filt_plot, color=#b8005c00, title='Low Band Fill')
//Bar Color
barcolor(use_barcolor ? bar_color : na)
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ---------------------------------------------- Order Blocks ------------------------------------------------
// Order Blocks
const color colup = #089981
const color coldn = #f23645
const string tm = " Use Length to adjust cordinate of the orderblocks Use whole candle body"
const string tn = "Mitigation method for when to trigger order blocks"
const string tj = "Order block Metrics text size"
const string ta = 'Display internal buy & sell activity'
const string tsorder = 'Show Last number of orderblocks'
const string gv = "Volumetric Order Blocks"
obshow = input.bool (false , "Show Last" , tsorder, '1', gv)
oblast = input.int (3 , "" , 0, 50, 1 , inline = '1', group = gv)
obupcs = input.color (color.new(colup, 90), "" , inline = '1', group = gv)
obdncs = input.color (color.new(coldn, 90), "" , inline = '1', group = gv)
obshowactivity = input.bool (true , "Show Buy/Sell Activity ", ta, '2', gv)
obactup = input.color (color.new(colup, 50), "" , inline = '2', group = gv)
obactdn = input.color (color.new(coldn, 50), "" , inline = '2', group = gv)
obmode = input.string("Length" , "Construction " , , tm, '3', gv)
len = input.int (5 , "" , 1, 20, 1 , inline = '3', group = gv)
obmiti = input.string("Close" , "Mitigation Method" , , tn, group = gv)
obtxt = input.string("Normal" , "Metric Size" , , tj, group = gv)
showmetric = input.bool (false , "Show Metrics" , group = gv)
showline = input.bool (false , "Show Mid-Line" , group = gv)
overlap = input.bool (true , "Hide Overlap" , group = gv, tooltip = "Most recent order block will be preserved")
bull = input.bool(true , "Buy signal" , inline = "Inside" , group = "ANY ALERT")
bear = input.bool(true , "Sell Signal" , inline = "Formed" , group = "ANY ALERT")
blcreated = input.bool(false , "Bullish OB Formed " , inline = "Formed" , group = "ANY ALERT")
brcreated = input.bool(false , "Bearish OB Formed" , inline = "Formed" , group = "ANY ALERT")
blmitigated = input.bool(false , "Bullish OB Mitigated " , inline = "Mitigated" , group = "ANY ALERT")
brmitigated = input.bool(false , "Bearish OB Mitigated" , inline = "Mitigated" , group = "ANY ALERT")
blinside = input.bool(true , "Price Inside Bullish OB" , inline = "Inside" , group = "ANY ALERT")
brinside = input.bool(true , "Price Inside Bearish OB" , inline = "Inside" , group = "ANY ALERT")
type bar
float o = open
float h = high
float l = low
float c = close
float v = volume
int i = bar_index
int t = time
type ob
float top
float btm
float avg
int loc
color css
float vol
int dir
int move
int blPOS
int brPOS
int xlocbl
int xlocbr
type alert
bool created = false
bool inside = false
bool mitigated = false
type cross
bool reset = false
bar b = bar .new()
alert blal = alert.new()
alert bral = alert.new()
var cross blIS = cross.new()
var cross brIS = cross.new()
method txSz(string s) =>
out = switch s
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
out
method display(ob id, ob full, int i) =>
box.new (top = id.top, bottom = id.btm, left = id.loc, right = b.t , border_color = na, bgcolor = id.css, xloc = xloc.bar_time)
box.new (top = id.top, bottom = id.btm, left = b.t , right = b.t + 1 , border_color = na, bgcolor = id.css, xloc = xloc.bar_time, extend = extend.right)
if obshowactivity
box.new(top = id.top, bottom = id.avg, left = id.loc, right = id.xlocbl, border_color = na, bgcolor = obactup, xloc = xloc.bar_time)
box.new(top = id.avg, bottom = id.btm, left = id.loc, right = id.xlocbr, border_color = na, bgcolor = obactdn, xloc = xloc.bar_time)
if showline
line.new(
x1 = id.loc
, x2 = b.t
, y1 = id.avg
, y2 = id.avg
, color = color.new(id.css, 0)
, xloc = xloc.bar_time
, style = line.style_dashed
)
if showmetric
if i == math.min(oblast - 1, full.size() - 1)
float tV = 0
float dV = array.new()
seq = math.min(oblast - 1, full.size() - 1)
for j = 0 to seq
cV = full.get(j)
tV += cV.vol
if j == seq
for y = 0 to seq
dV.push(
math.floor(
(full.get(y).vol / tV) * 100)
)
id = full.get(y)
label.new(
b.i + 1
, id.avg
, textcolor = color.new(id.css, 0)
, style = label.style_label_left
, size = obtxt.txSz()
, color = #ffffff00
, text =
str.tostring(
math.round(full.get(y).vol, 3), format = format.volume) + " (" + str.tostring(dV.get(y)) + "%)"
)
method overlap(ob id) =>
if id.size() > 1
for i = id.size() - 1 to 1
stuff = id.get(i)
current = id.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top => id.remove(i)
stuff.top < current.top and stuff.btm > current.btm => id.remove(i)
stuff.top > current.top and stuff.btm < current.btm => id.remove(i)
stuff.top < current.top and stuff.top > current.btm => id.remove(i)
method umt(ob metric) =>
switch metric.dir
1 =>
switch metric.move
1 => metric.blPOS := metric.blPOS + 1, metric.move := 2
2 => metric.blPOS := metric.blPOS + 1, metric.move := 3
3 => metric.brPOS := metric.brPOS + 1, metric.move := 1
-1 =>
switch metric.move
1 => metric.brPOS := metric.brPOS + 1, metric.move := 2
2 => metric.brPOS := metric.brPOS + 1, metric.move := 3
3 => metric.blPOS := metric.blPOS + 1, metric.move := 1
if (b.t - b.t ) == (b.t - b.t )
metric.xlocbl := metric.loc + (b.t - b.t ) * metric.blPOS
metric.xlocbr := metric.loc + (b.t - b.t ) * metric.brPOS
fnOB() =>
var ob blob = array.new()
var ob brob = array.new()
var int dir = 0
up = ta.highest ( len )
dn = ta.lowest ( len )
pv = ta.pivothigh(b.v, len, len)
dir := b.h > up ? -1 : b.l < dn ? 1 : dir
atr = ta.atr(len)
btmP = obmode == "Length" ? (b.h - 1 * atr ) < b.l ? b.l : (b.h - 1 * atr ) : b.l
topP = obmode == "Length" ? (b.l + 1 * atr ) > b.h ? b.h : (b.l + 1 * atr ) : b.h
if pv and dir == 1
blob.unshift(
ob.new(topP, b.l , math.avg(topP, b.l ), b.t , obupcs, b.v , b.c > b.o ? 1 : -1, 1, 0, 0, b.t ))
blal.created := true
blIS.reset := false
if pv and dir == -1
brob.unshift(
ob.new(
b.h
, btmP
, math.avg(btmP, b.h )
, b.t
, obdncs
, b.v
, b.c > b.o ? 1 : -1
, 1
, 0
, 0
, b.t
)
)
bral.created := true
brIS.reset := false
if blob.size() > 0 and barstate.isconfirmed
for in blob
for j = 0 to len - 1
if obmiti == "Close" ? math.min(b.c , b.o ) < ob.btm : obmiti == "Wick" ? b.l < ob.btm : obmiti == "Avg" ? b.l < ob.avg : na
blob.remove(i)
blal.mitigated := true
break
if brob.size() > 0 and barstate.isconfirmed
for in brob
for j = 0 to len - 1
if obmiti == "Close" ? math.max(b.c , b.o ) > ob.top : obmiti == "Wick" ? b.h > ob.top : obmiti == "Avg" ? b.h > ob.avg : na
brob.remove(i)
bral.mitigated := true
break
if blob.size() > 0
for in blob
metric.umt()
if brob.size() > 0
for in brob
metric.umt()
if overlap
blob.overlap()
brob.overlap()
if barstate.isconfirmed
if blob.size() > 0
ob = blob.get(0)
if low < ob.top and blIS.reset == false
blal.inside := true
blIS.reset := true
if brob.size() > 0
ob = brob.get(0)
if high > ob.btm and brIS.reset == false
bral.inside := true
brIS.reset := true
if barstate.islast
for bx in box.all
bx.delete()
for ln in line.all
ln.delete()
// for lb in label.all //Razzere Fixed!
// lb.delete() //Razzere Fixed!
if blob.size() > 0
for i = 0 to math.min(oblast - 1, blob.size() - 1)
blob.get(i).display(blob, i)
if brob.size() > 0
for i = 0 to math.min(oblast - 1, brob.size() - 1)
brob.get(i).display(brob, i)
if obshow
fnOB()
if bull and longCondition
alert("Buy Signal")
if bear and shortCondition
alert("Sell Signal")
if blinside and blal.inside
alert("Price Inside Bullish OB")
if blcreated and blal.created
alert("Bullish OB Formed")
if blmitigated and blal.mitigated
alert("Bullish OB Mitigated")
if brinside and bral.inside
alert("Price Inside Bearish OB")
if brcreated and bral.created
alert("Bearish OB Formed")
if brmitigated and bral.mitigated
alert("Bearish OB Mitigated")
// Risk Management
levels = input.bool(true, "Show TP/SL Levels" , group = "Risk Management" , inline = "MMDB2")
lvlLines = input.bool(false, "Show Lines ", inline="levels", group = "Risk Management")
linesStyle = input.string("SOLID", "", , inline="levels", group = "Risk Management")
lvlDistance = input.int(105, "Distance", 1, inline="levels2", group = "Risk Management")
lvlDecimals = input.int(2, " Decimals", 1, 8, inline="levels2", group = "Risk Management")
atrRisk = input.int(5, "Risk % ", 1, group = "Risk Management" , inline="levels3")
atrLen = input.int(14, " ATR Length", 1, group = "Risk Management" , inline="levels3")
decimals = lvlDecimals == 1 ? "#.#" : lvlDecimals == 2 ? "#.##" : lvlDecimals == 3 ? "#.###" : lvlDecimals == 4 ? "#.####" : lvlDecimals == 5 ? "#.#####" : lvlDecimals == 6 ? "#.######" : lvlDecimals == 7 ? "#.#######" : "#.########"
trigger2 = longCondition ? 1 : 0
countBull = ta.barssince(longCondition)
countBear = ta.barssince(shortCondition)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
atrBand = ta.atr(atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
lastTrade(close) => ta.valuewhen(longCondition or shortCondition, close, 0)
entry = levels ? label.new(time, close, "ENTRY " + str.tostring(lastTrade(close), decimals), xloc.bar_time, yloc.price, #e0ad06, label.style_label_left, color.white, size.normal) : na
label.set_x(entry, label.get_x(entry) + math.round(ta.change(time) * lvlDistance))
label.set_y(entry, lastTrade(close))
label.delete(entry )
stop_y = lastTrade(atrStop)
stop = levels ? label.new(time, close, "SL " + str.tostring(stop_y, decimals), xloc.bar_time, yloc.price, #ff00008c, label.style_label_left, color.white, size.normal) : na
label.set_x(stop, label.get_x(stop) + math.round(ta.change(time) * lvlDistance))
label.set_y(stop, stop_y)
label.delete(stop )
tp1Rl_y = (lastTrade(close)-lastTrade(atrStop))*1 + lastTrade(close)
tp1Rl = levels ? label.new(time, close, "1:1 TP " + str.tostring(tp1Rl_y, decimals), xloc.bar_time, yloc.price, #00cf4b8c, label.style_label_left, color.white, size.normal ) : na
label.set_x(tp1Rl, label.get_x(tp1Rl) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp1Rl, tp1Rl_y)
label.delete(tp1Rl )
tp2RL_y = (lastTrade(close)-lastTrade(atrStop))*2 + lastTrade(close)
tp2RL = levels ? label.new(time, close, "2:1 TP " + str.tostring(tp2RL_y, decimals), xloc.bar_time, yloc.price, #00cf4b8c, label.style_label_left, color.white, size.normal) : na
label.set_x(tp2RL, label.get_x(tp2RL) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp2RL, tp2RL_y)
label.delete(tp2RL )
tp3RL_y = (lastTrade(close)-lastTrade(atrStop))*3 + lastTrade(close)
tp3RL = levels ? label.new(time, close, "3:1 TP " + str.tostring(tp3RL_y, decimals), xloc.bar_time, yloc.price, #00cf4b8c, label.style_label_left, color.white, size.normal) : na
label.set_x(tp3RL, label.get_x(tp3RL) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp3RL, tp3RL_y)
label.delete(tp3RL )
style = linesStyle == "SOLID" ? line.style_solid : linesStyle == "DASHED" ? line.style_dashed : line.style_dotted
lineEntry = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), lastTrade(close), bar_index + lvlDistance, lastTrade(close), xloc.bar_index, extend.none, #e0ad06, style, 2) : na, line.delete(lineEntry )
lineStop = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), stop_y, bar_index + lvlDistance, stop_y, xloc.bar_index, extend.none, #ff00008c, style, 2) : na, line.delete(lineStop )
lineTp1Rl = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), tp1Rl_y, bar_index + lvlDistance, tp1Rl_y, xloc.bar_index, extend.none, #00cf4b8c, style, 2) : na, line.delete(lineTp1Rl )
lineTp2RL = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), tp2RL_y, bar_index + lvlDistance, tp2RL_y, xloc.bar_index, extend.none, #00cf4b8c, style, 2) : na, line.delete(lineTp2RL )
lineTp3RL = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), tp3RL_y, bar_index + lvlDistance, tp3RL_y, xloc.bar_index, extend.none, #00cf4b8c, style, 2) : na, line.delete(lineTp3RL )
//Plot Buy and Sell Labels
plotshape(longCondition, title='Buy Signal', text='Buy ▲+ ', textcolor=color.white, style=shape.labelup, size=size.normal, location=location.belowbar, color=#00cf4b8c)
plotshape(shortCondition, title='Sell Signal', text='Sell ▼+', textcolor=color.white, style=shape.labeldown, size=size.normal, location=location.abovebar, color=#ff00008c)
//Alerts
alertcondition(longCondition, title='Buy Alert', message='BUY')
alertcondition(shortCondition, title='Sell Alert', message='SELL')
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ---------------------------------------------- SR ------------------------------------------------
//
show_current_sr = input.bool(true, title = "Show Current TF S/R", group = "Setting")
swing_length = input.int(10, title = 'Swing Length', group = 'Setting', minval = 1, maxval = 50)
history_of_demand_to_keep = input.int(20, title = 'Lookback', minval = 5, maxval = 50, group = "Setting")
box_width = input.float(10, title = 'S/R Range', group = 'Setting', minval = 1, maxval = 10, step = 0.5)
string group3 = "TF Setting"
enableHtf1 = input.bool(false, group = group3, inline = "htf1", title = "")
htf1 = input.timeframe("W", "TF1", group = group3, inline = "htf1")
enableHtf2 = input.bool(false, group = group3, inline = "htf2", title = "")
htf2 = input.timeframe("D", "TF2", group = group3, inline = "htf2")
enableHtf3 = input.bool(false, group = group3, inline = "htf3", title = "")
htf3 = input.timeframe("240", "TF3", group = group3, inline = "htf3")
enableHtf4 = input.bool(false, group = group3, inline = "htf4", title = "")
htf4 = input.timeframe("180", "TF4", group = group3, inline = "htf4")
enableHtf5 = input.bool(false, group = group3, inline = "htf5", title = "")
htf5 = input.timeframe("120", "TF5", group = group3, inline = "htf5")
enableHtf6 = input.bool(false, group = group3, inline = "htf6", title = "")
htf6 = input.timeframe("60", "TF6", group = group3, inline = "htf6")
enableHtf7 = input.bool(false, group = group3, inline = "htf7", title = "")
htf7 = input.timeframe("45", "TF7", group = group3, inline = "htf7")
enableHtf8 = input.bool(true, group = group3, inline = "htf8", title = "")
htf8 = input.timeframe("30", "TF8", group = group3, inline = "htf8")
enableHtf9 = input.bool(false, group = group3, inline = "htf9", title = "")
htf9 = input.timeframe("15", "TF9", group = group3, inline = "htf9")
supply_color = input.color(#f236468a, title = 'Support Zone', group = 'Color Settings', inline = '3')
supply_outline_color = input.color(#f236468a, title = 'BoS', group = 'Color Settings', inline = '3')
demand_color = input.color(#2962ff8a, title = 'Resistance Zone', group = 'Color Settings', inline = '4')
demand_outline_color = input.color(#2962ff8a, title = 'BoR', group = 'Color Settings', inline = '4')
// bos_label_color = input.color(color.white, title = 'Fracture Zone', group = 'Color Settings', inline = '5')
poi_label_color = input.color(#b9b9b9, title = 'S/R Zone Label', group = 'Color Settings', inline = '7')
type zone_with_strength
box zone
int count = 0
string tf
// FUNCTION TO ADD NEW AND REMOVE LAST IN ARRAY
array_add_pop(array, new_value_to_add) =>
array.unshift(array, new_value_to_add)
array.pop(array)
// FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING
check_overlapping(new_poi, box_array, atr) =>
atr_threshold = atr * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
zone_with_strength zws = array.get(box_array, i)
if not na(zws)
box b = zws.zone
top = box.get_top(b)
bottom = box.get_bottom(b)
poi = (top + bottom) / 2
upper_boundary = poi + atr_threshold
lower_boundary = poi - atr_threshold
if new_poi >= lower_boundary and new_poi <= upper_boundary
okay_to_draw := false
break
else
okay_to_draw := true
okay_to_draw
// FUNCTION TO DRAW SUPPLY OR DEMAND ZONE
support_resistance(value_array, bn_array, box_array, label_array, count_array, box_type, atr, tf_label, tfbarindex, is_htf) =>
atr_buffer = atr * (box_width / 10)
box_left = is_htf ? bar_index : array.get(bn_array, 0)
box_right = bar_index
var float box_top = 0.00
var float box_bottom = 0.00
var float poi = 0.00
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
okay_to_draw = check_overlapping(poi, box_array, atr)
// okay_to_draw = true
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw
zone_with_strength last = array.get(box_array, array.size(box_array) - 1)
if not na(last)
box.delete(last.zone)
box b = box.new(left = box_left, top = box_top, right = bar_index, bottom = box_bottom, border_color = supply_outline_color,
bgcolor = color.new(supply_color, 80), extend = extend.none, text = tf_label, text_halign = text.align_right, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)
zone_with_strength zws = zone_with_strength.new(b, 0, tf_label)
array_add_pop(box_array, zws)
else if box_type == -1 and okay_to_draw
zone_with_strength last = array.get(box_array, array.size(box_array) - 1)
if not na(last)
box.delete(last.zone)
box b = box.new(left = box_left, top = box_top, right = bar_index, bottom = box_bottom, border_color = demand_outline_color,
bgcolor = color.new(demand_color, 80), extend = extend.none, text = tf_label, text_halign = text.align_right, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)
zone_with_strength zws = zone_with_strength.new(b, 0, tf_label)
array_add_pop(box_array, zws)
// FUNCTION TO CHANGE SUPPLY/DEMAND TO A BOS IF BROKEN
sd_to_bos(box_array, bos_array, count_array, label_array, zone_type, tfclose, tfbarindex) =>
for i = 0 to array.size(box_array) - 1
zone_with_strength zws = array.get(box_array, i)
if not na(zws)
box b = zws.zone
level_to_break_top = box.get_top(b)
level_to_break_bottom = box.get_bottom(b)
// if ta.crossover(close, level_to_break)
if (zone_type == 1 and close >= level_to_break_top) or (zone_type == -1 and close <= level_to_break_bottom)
copied_zone = zone_with_strength.copy(zws)
box cz = copied_zone.zone
mid = (box.get_top(b) + box.get_bottom(b)) / 2
line bosline = line.new(box.get_left(cz), mid, bar_index, mid, xloc.bar_index, extend.none, zone_type == 1 ? supply_outline_color : demand_outline_color, line.style_dotted)
array_add_pop(bos_array, bosline)
// box bos = array.get(bos_array, 0)
// box.set_top(bos, mid)
// box.set_bottom(bos, mid)
// box.set_right(bos, bar_index)
// box.set_extend(bos, extend.none)
// box.set_text(bos, '')
// box.set_text_color( bos, bos_label_color)
// box.set_text_size(bos, size.small)
// box.set_text_halign(bos, text.align_center)
// box.set_text_valign(bos, text.align_center)
box.delete(b)
array.set(box_array, i, na)
// array.remove(box_array, i)
// box.delete(array.get(label_array, i))
// FUNCTION MANAGE CURRENT BOXES BY CHANGING ENDPOINT
extend_box_endpoint(box_array, count_array, tfbarindex, tfhigh, tflow) =>
for i = 0 to array.size(box_array) - 1
zone_with_strength zws = array.get(box_array, i)
if not na(zws)
box b = zws.zone
top = box.get_top(b)
bottom = box.get_bottom(b)
count = zws.count
if (high >= bottom and high <= top) or (low >= bottom and low <= top)
count := count + 1
zws.count := count
// count := count + 1
// zws.count := count
box.set_right(b, bar_index + 40)
box.set_text(b, str.format("{0} / {1}", count, zws.tf))
zws.zone := b
array.set(box_array, i, zws)
//
//END FUNCTIONS
//
//
// CALCULATIONS FOR SUPPORT AND RESISTANCE
//
calculateSR(swing_high_values, swing_low_values, swing_high_bns, swing_low_bns, supply_zone, demand_zone, current_supply_touch_count, current_demand_touch_count, current_supply_poi, current_demand_poi, supply_bos, demand_bos, series1, series2, tf_label, tfbarindex, tfclose, atr, is_htf, swing_high, swing_low, swing_index) =>
// NEW SWING HIGH
if not na(swing_high)
//MANAGE SWING HIGH VALUES
array_add_pop(swing_high_values, swing_high)
array_add_pop(swing_high_bns, swing_index)
support_resistance(swing_high_values, swing_high_bns, supply_zone, current_supply_poi, current_supply_touch_count, 1, atr, tf_label, tfbarindex, is_htf)
// NEW SWING LOW
else if not na(swing_low)
//MANAGE SWING LOW VALUES
array_add_pop(swing_low_values, swing_low)
array_add_pop(swing_low_bns, swing_index)
support_resistance(swing_low_values, swing_low_bns, demand_zone, current_demand_poi, current_demand_touch_count, -1, atr, tf_label, tfbarindex, is_htf)
sd_to_bos(supply_zone, supply_bos, current_supply_touch_count, current_supply_poi, 1, tfclose, tfbarindex)
sd_to_bos(demand_zone, demand_bos, current_demand_touch_count, current_demand_poi, -1, tfclose, tfbarindex)
extend_box_endpoint(supply_zone, current_supply_touch_count, tfbarindex, series1, series2)
extend_box_endpoint(demand_zone, current_demand_touch_count, tfbarindex, series1, series2)
var swing_high_values = array.new_float(5,0.00)
var swing_low_values = array.new_float(5,0.00)
var swing_high_bns = array.new_int(5,0)
var swing_low_bns = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi = array.new_box(history_of_demand_to_keep, na)
var supply_zones = array.new(history_of_demand_to_keep, na)
var demand_zones = array.new(history_of_demand_to_keep, na)
var touches_for_supply = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR BOS
var supply_bos = array.new_line(5, na)
var demand_bos = array.new_line(5, na)
var swing_high_values1 = array.new_float(5,0.00)
var swing_low_values1 = array.new_float(5,0.00)
var swing_high_bns1 = array.new_int(5,0)
var swing_low_bns1 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones1 = array.new(history_of_demand_to_keep, na)
var demand_zones1 = array.new(history_of_demand_to_keep, na)
var touches_for_supply1 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand1 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi1 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi1 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos1 = array.new_line(5, na)
var demand_bos1 = array.new_line(5, na)
var swing_high_values2 = array.new_float(5,0.00)
var swing_low_values2 = array.new_float(5,0.00)
var swing_high_bns2 = array.new_int(5,0)
var swing_low_bns2 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones2 = array.new(history_of_demand_to_keep, na)
var demand_zones2 = array.new(history_of_demand_to_keep, na)
var touches_for_supply2 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand2 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi2 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi2 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos2 = array.new_line(5, na)
var demand_bos2 = array.new_line(5, na)
var swing_high_values3 = array.new_float(5,0.00)
var swing_low_values3 = array.new_float(5,0.00)
var swing_high_bns3 = array.new_int(5,0)
var swing_low_bns3 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones3 = array.new(history_of_demand_to_keep, na)
var demand_zones3 = array.new(history_of_demand_to_keep, na)
var touches_for_supply3 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand3 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi3 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi3 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos3 = array.new_line(5, na)
var demand_bos3 = array.new_line(5, na)
var swing_high_values4 = array.new_float(5,0.00)
var swing_low_values4 = array.new_float(5,0.00)
var swing_high_bns4 = array.new_int(5,0)
var swing_low_bns4 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones4 = array.new(history_of_demand_to_keep, na)
var demand_zones4 = array.new(history_of_demand_to_keep, na)
var touches_for_supply4 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand4 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi4 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi4 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos4 = array.new_line(5, na)
var demand_bos4 = array.new_line(5, na)
var swing_high_values5 = array.new_float(5,0.00)
var swing_low_values5 = array.new_float(5,0.00)
var swing_high_bns5 = array.new_int(5,0)
var swing_low_bns5 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones5 = array.new(history_of_demand_to_keep, na)
var demand_zones5 = array.new(history_of_demand_to_keep, na)
var touches_for_supply5 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand5 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi5 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi5 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos5 = array.new_line(5, na)
var demand_bos5 = array.new_line(5, na)
var swing_high_values6 = array.new_float(5,0.00)
var swing_low_values6 = array.new_float(5,0.00)
var swing_high_bns6 = array.new_int(5,0)
var swing_low_bns6 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones6 = array.new(history_of_demand_to_keep, na)
var demand_zones6 = array.new(history_of_demand_to_keep, na)
var touches_for_supply6 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand6 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi6 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi6 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos6 = array.new_line(5, na)
var demand_bos6 = array.new_line(5, na)
var swing_high_values7 = array.new_float(5,0.00)
var swing_low_values7 = array.new_float(5,0.00)
var swing_high_bns7 = array.new_int(5,0)
var swing_low_bns7 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones7 = array.new(history_of_demand_to_keep, na)
var demand_zones7 = array.new(history_of_demand_to_keep, na)
var touches_for_supply7 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand7 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi7 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi7 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos7 = array.new_line(5, na)
var demand_bos7 = array.new_line(5, na)
var swing_high_values8 = array.new_float(5,0.00)
var swing_low_values8 = array.new_float(5,0.00)
var swing_high_bns8 = array.new_int(5,0)
var swing_low_bns8 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones8 = array.new(history_of_demand_to_keep, na)
var demand_zones8 = array.new(history_of_demand_to_keep, na)
var touches_for_supply8 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand8 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi8 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi8 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos8 = array.new_line(5, na)
var demand_bos8 = array.new_line(5, na)
var swing_high_values9 = array.new_float(5,0.00)
var swing_low_values9 = array.new_float(5,0.00)
var swing_high_bns9 = array.new_int(5,0)
var swing_low_bns9 = array.new_int(5,0)
// ARRAYS FOR SUPPORT / RESISTANCE
var supply_zones9 = array.new(history_of_demand_to_keep, na)
var demand_zones9 = array.new(history_of_demand_to_keep, na)
var touches_for_supply9 = array.new_int(history_of_demand_to_keep, 0)
var touches_for_demand9 = array.new_int(history_of_demand_to_keep, 0)
// ARRAYS FOR SUPPORT / RESISTANCE POI LABELS
var current_supply_poi9 = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi9 = array.new_box(history_of_demand_to_keep, na)
// ARRAYS FOR BOS
var supply_bos9 = array.new_line(5, na)
var demand_bos9 = array.new_line(5, na)
atr = ta.atr(50)
if show_current_sr
cur_tf_label = timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period
swing_high = ta.pivothigh(swing_length, swing_length)
swing_low = ta.pivotlow(swing_length, swing_length)
swing_index = bar_index
calculateSR(swing_high_values, swing_low_values, swing_high_bns, swing_low_bns, supply_zones, demand_zones, touches_for_supply, touches_for_demand, current_supply_poi, current_demand_poi, supply_bos, demand_bos, high, low, cur_tf_label, bar_index, close, atr, false, swing_high, swing_low, swing_index)
// SUPPORT / RESISTANCE FOR HTF1
= request.security(syminfo.tickerid, htf1, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF2
= request.security(syminfo.tickerid, htf2, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF3
= request.security(syminfo.tickerid, htf3, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF4
= request.security(syminfo.tickerid, htf4, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF5
= request.security(syminfo.tickerid, htf5, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF6
= request.security(syminfo.tickerid, htf6, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF7
= request.security(syminfo.tickerid, htf7, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF8
= request.security(syminfo.tickerid, htf8, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
// SUPPORT / RESISTANCE FOR HTF9
= request.security(syminfo.tickerid, htf9, [high, low, close, bar_index, ta.atr(50), timeframe.isintraday ? str.tostring(timeframe.in_seconds() / 60, "#.## MIN") : timeframe.period, ta.pivothigh(swing_length, swing_length), ta.pivotlow(swing_length, swing_length), bar_index ])
if enableHtf1 and htf1 != ""
calculateSR(swing_high_values1, swing_low_values1, swing_high_bns1, swing_low_bns1, supply_zones1, demand_zones1, touches_for_supply1, touches_for_demand1, current_supply_poi1, current_demand_poi1, supply_bos1, demand_bos1, high1, low1, timeframe1, barindex1, close1, atr1, true, swing_high1, swing_low1, swing_index1)
if enableHtf2 and htf2 != ""
calculateSR(swing_high_values2, swing_low_values2, swing_high_bns2, swing_low_bns2, supply_zones2, demand_zones2, touches_for_supply2, touches_for_demand2, current_supply_poi2, current_demand_poi2, supply_bos2, demand_bos2, high2, low2, timeframe2, barindex2, close2, atr2, true, swing_high2, swing_low2, swing_index2)
if enableHtf3 and htf3 != ""
calculateSR(swing_high_values3, swing_low_values3, swing_high_bns3, swing_low_bns3, supply_zones3, demand_zones3, touches_for_supply3, touches_for_demand3, current_supply_poi3, current_demand_poi3, supply_bos3, demand_bos3, high3, low3, timeframe3, barindex3, close3, atr3, true, swing_high3, swing_low3, swing_index3)
if enableHtf4 and htf4 != ""
calculateSR(swing_high_values4, swing_low_values4, swing_high_bns4, swing_low_bns4, supply_zones4, demand_zones4, touches_for_supply4, touches_for_demand4, current_supply_poi4, current_demand_poi4, supply_bos4, demand_bos4, high4, low4, timeframe4, barindex4, close4, atr4, true, swing_high4, swing_low4, swing_index4)
if enableHtf5 and htf5 != ""
calculateSR(swing_high_values5, swing_low_values5, swing_high_bns5, swing_low_bns5, supply_zones5, demand_zones5, touches_for_supply5, touches_for_demand5, current_supply_poi5, current_demand_poi5, supply_bos5, demand_bos5, high5, low5, timeframe5, barindex5, close5, atr5, true, swing_high5, swing_low5, swing_index5)
if enableHtf6 and htf6 != ""
calculateSR(swing_high_values6, swing_low_values6, swing_high_bns6, swing_low_bns6, supply_zones6, demand_zones6, touches_for_supply6, touches_for_demand6, current_supply_poi6, current_demand_poi6, supply_bos6, demand_bos6, high6, low6, timeframe6, barindex6, close6, atr6, true, swing_high6, swing_low6, swing_index6)
if enableHtf7 and htf7 != ""
calculateSR(swing_high_values7, swing_low_values7, swing_high_bns7, swing_low_bns7, supply_zones7, demand_zones7, touches_for_supply7, touches_for_demand7, current_supply_poi7, current_demand_poi7, supply_bos7, demand_bos7, high7, low7, timeframe7, barindex7, close7, atr7, true, swing_high7, swing_low7, swing_index7)
if enableHtf8 and htf8 != ""
calculateSR(swing_high_values8, swing_low_values8, swing_high_bns8, swing_low_bns8, supply_zones8, demand_zones8, touches_for_supply8, touches_for_demand8, current_supply_poi8, current_demand_poi8, supply_bos8, demand_bos8, high8, low8, timeframe8, barindex8, close8, atr8, true, swing_high8, swing_low8, swing_index8)
if enableHtf9 and htf9 != ""
calculateSR(swing_high_values9, swing_low_values9, swing_high_bns9, swing_low_bns9, supply_zones9, demand_zones9, touches_for_supply9, touches_for_demand9, current_supply_poi9, current_demand_poi9, supply_bos9, demand_bos9, high9, low9, timeframe9, barindex9, close9, atr9, true, swing_high9, swing_low9, swing_index9)
Buy
PM_BUY SELL//@version=5
indicator(title="PM_BUY SELL", shorttitle="PM_BUY_SELL", overlay=true)
// PMI_LA Indicator Parameters
sm = input(6, title="PMI Smoothing Period")
cd = input(0.4, title="PMI Constant D")
ebc = input(false, title="PMI Color Bars")
ribm = input(false, title="PMI Ribbon Mode")
// Buy Sell Indicator Parameters
a = input(4, title="BSI Multiplier")
c = input(30, title="BSI ATR Period")
h = input(false, title="BSI Heikin Ashi Candles")
// Inputs for EMAs
len1 = input.int(15, minval=1, title="Length (EMA 1)")
offset1 = input.int(1, title="Offset (EMA 1)", defval=0, minval=-500, maxval=500, display=display.data_window)
len2 = input.int(15, minval=1, title="Length (EMA 2)")
offset2 = input.int(title="Offset (EMA 2)", defval=0, minval=-500, maxval=500, display=display.data_window)
// Source for both EMAs
src = input(close, title="Source")
// Heikin-Ashi Calculation
var float haOpen = na
haClose = (open + high + low + close) / 4
haOpen := na(haOpen ) ? (open + close) / 2 : (haOpen + haClose ) / 2
haHigh = math.max(high, math.max(haOpen, haClose))
haLow = math.min(low, math.min(haOpen, haClose))
// PMI_LA Calculation
var float i1 = na
var float i2 = na
var float i3 = na
var float i4 = na
var float i5 = na
var float i6 = na
var float bfr = na
var color bfrC = na
var float di = na
var float c1 = na
var float c2 = na
var float c3 = na
var float c4 = na
var float c5 = na
src_pmi = close
di := (sm - 1.0) / 2.0 + 1.0
c1 := 2 / (di + 1.0)
c2 := 1 - c1
c3 := 3.0 * (cd * cd + cd * cd * cd)
c4 := -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
c5 := 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
i1 := c1 * src_pmi + c2 * nz(i1 )
i2 := c1 * i1 + c2 * nz(i2 )
i3 := c1 * i2 + c2 * nz(i3 )
i4 := c1 * i3 + c2 * nz(i4 )
i5 := c1 * i4 + c2 * nz(i5 )
i6 := c1 * i5 + c2 * nz(i6 )
bfr := -cd * cd * cd * i6 + c3 * i5 + c4 * i4 + c5 * i3
bfrC := bfr > nz(bfr ) ? color.green : bfr < nz(bfr ) ? color.red : color.blue
// Buy Sell Indicator Calculation
xATR = ta.atr(c)
nLoss = a * xATR
src_bsi = h ? haClose : close
var float xATRTrailingStop = na
if src_bsi > nz(xATRTrailingStop , 0) and src_bsi > nz(xATRTrailingStop , 0)
xATRTrailingStop := math.max(nz(xATRTrailingStop ), src_bsi - nLoss)
else if src_bsi < nz(xATRTrailingStop , 0) and src_bsi < nz(xATRTrailingStop , 0)
xATRTrailingStop := math.min(nz(xATRTrailingStop ), src_bsi + nLoss)
else if src_bsi > nz(xATRTrailingStop , 0)
xATRTrailingStop := src_bsi - nLoss
else
xATRTrailingStop := src_bsi + nLoss
var int pos = na
pos := src_bsi < nz(xATRTrailingStop , 0) and src_bsi > nz(xATRTrailingStop , 0) ? 1 :
src_bsi > nz(xATRTrailingStop , 0) and src_bsi < nz(xATRTrailingStop , 0) ? -1 :
nz(pos , 0)
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src_bsi, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = src_bsi > xATRTrailingStop and above
sell = src_bsi < xATRTrailingStop and below
// Plotting PMI_LA and Buy Sell
plot(ribm ? na : bfr, title="PMI Trend", linewidth=3, color=bfrC)
bgcolor(ribm ? bfrC : na, transp=50)
plotshape(buy, title="Buy Signal", text="Buy", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, transp=0, size=size.tiny)
plotshape(sell, title="Sell Signal", text="Sell", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, transp=0, size=size.tiny)
barcolor(buy ? color.green : sell ? color.red : na)
alertcondition(buy, "Buy Alert", "Buy Signal Triggered")
alertcondition(sell, "Sell Alert", "Sell Signal Triggered")
// Calculate the first EMA
out1 = ta.ema(src, len1)
plot(out1, title="EMA 1", color=color.blue, offset=offset1)
// Calculate the second EMA
out2 = ta.ema(src, len2)
plot(out2, title="EMA 2", color=color.red, offset=offset2)
// Function to calculate moving averages with different types
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
// Inputs for smoothing line
typeMA = input.string(title="Method", defval="SMA", options= , group="Smoothing", display=display.data_window)
smoothingLength = input.int(title="Length", defval=5, minval=1, maxval=100, group="Smoothing", display=display.data_window)
// Calculate smoothing line for EMA 1
smoothingLine1 = ma(out1, smoothingLength, typeMA)
plot(smoothingLine1, title="Smoothing Line (EMA 1)", color=#f37f20, offset=offset1, display=display.none)
// Calculate smoothing line for EMA 2
smoothingLine2 = ma(out2, smoothingLength, typeMA)
plot(smoothingLine2, title="Smoothing Line (EMA 2)", color=#FF5733, offset=offset2, display=display.none)
VWAP + 2 Moving Averages + RSI + Buy and SellIndicator: VWAP + 2 Moving Averages + RSI + Buy and Sell
Buy and Sell Arrows (Great for use alone or in conjunction with other scripts on the chart)
This indicator displays BUY (BUY) and SELL (SELL) arrows on the chart based on a combination of moving averages, VWAP and RSI. Arrows are a visual way to identify trading opportunities and can be useful for traders who want to follow a strategy based on these conditions.
The indicator uses two moving averages (20 and 50 periods) to identify upward crosses (buy) and downward crosses (sell). In addition, it takes into account VWAP (Volume Weighted Average Price) and RSI (Relative Strength Index) as additional filters to confirm buy and sell signals.
This script is great for use both independently and in conjunction with other indicators and strategies. You can combine it with other indicators and customize it to your preferences to create a more comprehensive trading strategy.
Please remember that this indicator is provided for educational purposes only and does not constitute financial advice. It is always recommended to carry out a thorough analysis before making any trading decisions.
Give this indicator a try and enjoy clear visualization of buy and sell arrows on your chart. Happy trading!
Buy/Sell Ei - Premium Edition (Fixed Momentum)**📈 Buy/Sell Ei Indicator - Smart Trading System with Price Pattern Detection 📉**
**🔍 What is it?**
The **Buy/Sell Ei** indicator is a professional tool designed to identify **buy and sell signals** based on a combination of **candlestick patterns** and **moving averages**. With high accuracy, it pinpoints optimal entry and exit points in **both bullish and bearish trends**, making it suitable for forex pairs, stocks, and cryptocurrencies.
---
### **🌟 Key Features:**
✅ **Advanced Candlestick Pattern Detection**
✅ **Momentum Filter (Customizable consecutive candle count)**
✅ **Live Trade Mode (Instant signals for active trading)**
✅ **Dual MA Support (Fast & Slow MA with multiple types: SMA, EMA, WMA, VWMA)**
✅ **Date Filter (Focus on specific trading periods)**
✅ **Win/Loss Tracking (Performance analytics with success rate)**
---
### **🚀 Why Choose Buy/Sell Ei?**
✔ **Precision:** Reduces false signals with strict pattern rules.
✔ **Flexibility:** Works in both live trading and backtesting modes.
✔ **User-Friendly:** Clear labels and alerts for easy decision-making.
✔ **Adaptive:** Compatible with all timeframes (M1 to Monthly).
---
### **🛠 How It Works:**
1. **Trend Confirmation:** Uses MAs to filter trades in the trend’s direction.
2. **Pattern Recognition:** Detects "Ready to Buy/Sell" and confirmed signals.
3. **Momentum Check:** Optional filter for consecutive bullish/bearish candles.
4. **Live Alerts:** Labels appear instantly in Live Trade Mode.
---
### **📊 Ideal For:**
- **Day Traders** (Scalping & Intraday)
- **Swing Traders** (Medium-term setups)
- **Technical Analysts** (Backtesting strategies)
**🔧 Designed by Sahar Chadri | Optimized for TradingView**
**🎯 Trade Smarter, Not Harder!**
Savitzky Flow Bands [ChartPrime]An advanced trend-following tool that applies the Savitzky-Golay smoothing algorithm to price and dynamically adapts trend bands to visualize directional bias and trend strength.
savitzky_golay_filter_w_15_vectors(source) =>
float sum = 0.0
float polynomial = 0.0
float coefficients = array.new(16)
// Predefined 15 coefficients
for i = -4 to 4
coefficients.set(i + 4, i) // from -4 to 5
if i == 4
for j = 5 to -4
for g = 8 to 15
coefficients.set(g, j) // from 5 to -4
// Calculate normalization factor as the sum of absolute values of coefficients
float norm_factor = coefficients.sum()
// Loop through coefficients and calculate the weighted sum
for i = 0 to coefficients.size()-1
sum := sum + coefficients.get(i) * source
// Calculate the smoothed value
for i = 1 to length-1
polynomial := math.sum(sum / norm_factor, i) / i
polynomial
⯁ KEY FEATURES & HOW TO USE
Savitzky-Golay Filtered Line (Basis):
Smooths out price noise using the Savitzky-Golay method, offering a more refined trend path than traditional moving averages. This centerline acts as the trend anchor and visually changes color depending on its slope to reflect the active trend direction.
Dynamic Trend Bands (Upper/Lower):
Constructed from the filtered line with a dynamic offset based on recent price volatility (ATR). These bands shift based on price pressure and are locked once price closes beyond them.
Helpful for identifying breakout moments or exhaustion areas where reversals are likely.
Trend Direction Detection:
A directional signal is confirmed when price breaks and closes above the upper band (uptrend) or below the lower band (downtrend).
Provides a clear and systematic way to identify when a trend begins.
Trend Duration Counter (Visual Decay Line):
A fading overlay line shows how long a trend has been active since the last reversal. The longer the trend persists, the more transparent this extension becomes.
This visual fading effect helps traders anticipate potential trend exhaustion and prepare for reversals or take-profit zones.
Reversal Signals (Diamond Markers):
Diamond shapes are plotted at each market shift, allowing users to visually pinpoint when the trend has flipped.
These markers act as decision zones for entry, exit, or stop-loss adjustments based on directional flow changes.
Color-Based Bar and Candle Painting:
Candles are painted green in uptrends and orange in downtrends, providing an intuitive glance at trend state without needing to interpret numbers.
Helps users stay aligned with the trend visually and avoid counter-trend entries.
⯁ CONCLUSION
The Savitzky Flow Bands indicator offers a modernized, visually rich way to track trend shifts using a scientific smoothing method. With dynamic trend envelopes, color-coded cues, and visual markers, it equips traders with a structured framework to follow the market's flow and make data-driven decisions. Ideal for swing traders, momentum strategists, or any trader looking to trade in sync with the prevailing trend.
Volumatic Trend [ChartPrime]
A unique trend-following indicator that blends trend logic with volume visualization, offering a dynamic view of market momentum and activity. It automatically detects trend shifts and paints volume histograms at key levels, allowing traders to easily spot strength or weakness within trends.
⯁ KEY FEATURES
Trend Detection System:
Uses a custom combination of weighted EMA (swma) and regular EMA to detect trend direction.
A diamond appears on trend shift, indicating the starting point of a new bullish or bearish phase.
Volume Histogram Zones:
At each new trend, the indicator draws two horizontal zones (top and bottom) and visualizes volume activity within that trend using dynamic histogram candles.
Gradient-Based Candle Coloring:
Candle color is blended with a gradient based on volume intensity. This helps highlight where volume spikes occurred, making it easy to identify pressure points.
Volume Summary Labels:
A label at the end of each trend zone displays two critical values:
- Delta: net volume difference between bullish and bearish bars.
- Total: overall volume accumulated during the trend.
⯁ HOW TO USE
Monitor diamond markers to identify when a new trend begins.
Use volume histogram spikes to assess if the trend is supported by strong volume or lacking participation.
A high delta with strong total volume in a trend indicates institutional support.
Compare gradient strength of candles—brighter areas represent higher-volume trading activity.
Can be used alone or combined with other confirmation tools like structure breaks, liquidity sweeps, or order blocks.
⯁ CONCLUSION
Volumatic Trend gives you more than just trend direction—it provides insight into the force behind it. With volume-graded candles and real-time histogram overlays, traders can instantly assess whether a trend is backed by conviction or fading strength. A perfect tool for swing traders and intraday strategists looking to add volume context to their directional setups.
Lowess Channel + (RSI) [ChartPrime]The Lowess Channel + (RSI) indicator applies the LOWESS (Locally Weighted Scatterplot Smoothing) algorithm to filter price fluctuations and construct a dynamic channel. LOWESS is a non-parametric regression method that smooths noisy data by fitting weighted linear regressions at localized segments. This technique is widely used in statistical analysis to reveal trends while preserving data structure.
In this indicator, the LOWESS algorithm is used to create a central trend line and deviation-based bands. The midline changes color based on trend direction, and diamonds are plotted when a trend shift occurs. Additionally, an RSI gauge is positioned at the end of the channel to display the current RSI level in relation to the price bands.
lowess_smooth(src, length, bandwidth) =>
sum_weights = 0.0
sum_weighted_y = 0.0
sum_weighted_xy = 0.0
sum_weighted_x2 = 0.0
sum_weighted_x = 0.0
for i = 0 to length - 1
x = float(i)
weight = math.exp(-0.5 * (x / bandwidth) * (x / bandwidth))
y = nz(src , 0)
sum_weights := sum_weights + weight
sum_weighted_x := sum_weighted_x + weight * x
sum_weighted_y := sum_weighted_y + weight * y
sum_weighted_xy := sum_weighted_xy + weight * x * y
sum_weighted_x2 := sum_weighted_x2 + weight * x * x
mean_x = sum_weighted_x / sum_weights
mean_y = sum_weighted_y / sum_weights
beta = (sum_weighted_xy - mean_x * mean_y * sum_weights) / (sum_weighted_x2 - mean_x * mean_x * sum_weights)
alpha = mean_y - beta * mean_x
alpha + beta * float(length / 2) // Centered smoothing
⯁ KEY FEATURES
LOWESS Price Filtering – Smooths price fluctuations to reveal the underlying trend with minimal lag.
Dynamic Trend Coloring – The midline changes color based on trend direction (e.g., bullish or bearish).
Trend Shift Diamonds – Marks points where the midline color changes, indicating a possible trend shift.
Deviation-Based Bands – Expands above and below the midline using ATR-based multipliers for volatility tracking.
RSI Gauge Display – A vertical gauge at the right side of the chart shows the current RSI level relative to the price channel.
Fully Customizable – Users can adjust LOWESS length, band width, colors, and enable or disable the RSI gauge and adjust RSIlength.
⯁ HOW TO USE
Use the LOWESS midline as a trend filter —bullish when green, bearish when purple.
Watch for trend shift diamonds as potential entry or exit signals.
Utilize the price bands to gauge overbought and oversold zones based on volatility.
Monitor the RSI gauge to confirm trend strength—high RSI near upper bands suggests overbought conditions, while low RSI near lower bands indicates oversold conditions.
⯁ CONCLUSION
The Lowess Channel + (RSI) indicator offers a powerful way to analyze market trends by applying a statistically robust smoothing algorithm. Unlike traditional moving averages, LOWESS filtering provides a flexible, responsive trendline that adapts to price movements. The integrated RSI gauge enhances decision-making by displaying momentum conditions alongside trend dynamics. Whether used for trend-following or mean reversion strategies, this indicator provides traders with a well-rounded perspective on market behavior.
Cumulative Price Change AlertCumulative Price Change Alert
Version: 1.0
Author: QCodeTrader 🚀
Overview 🔍
The Cumulative Price Change Alert indicator analyzes the percentage change between the current and previous open prices and sums these changes over a user-defined number of bars. It then generates visual buy and sell signals using arrows and labels on the chart, helping traders spot cumulative price momentum and potential trading opportunities.
Key Features ⚙️
Customizable Timeframe 🕒:
Use a custom timeframe or default to the chart's timeframe for price data.
User-Defined Summation 🔢:
Specify the number of bars to sum, allowing you to analyze cumulative price changes.
Custom Buy & Sell Conditions 🔔:
Set individual percentage change thresholds and cumulative sum thresholds to tailor signals for
your strategy.
Visual Alerts 🚀:
Displays green upward arrows for buy signals and red downward arrows for sell signals directly
on the chart.
Informative Labels 📝:
Provides labels with formatted percentage change and cumulative sum details for the analyzed
bars.
Versatile Application 📊:
Suitable for stocks, forex, crypto, commodities, and more.
How It Works ⚡
Price Change Calculation ➗:
The indicator calculates the percentage change between the current bar's open price and the
previous bar's open price.
Cumulative Sum ➕:
It then sums these percentage changes over the last N bars (as specified by the user).
Signal Generation 🚦:
Buy Signal 🟢: When both the individual percentage change and the cumulative sum exceed
their respective buy thresholds, a green arrow and label are displayed.
Sell Signal 🔴: Conversely, if the individual change and cumulative sum fall below the sell
thresholds, a red arrow and label are shown.
How to Use 💡
Add the Indicator ➕:
Apply the indicator to your chart.
Customize Settings ⚙️:
Set a custom timeframe if desired.
Define the number of bars to sum.
Adjust the buy/sell percentage change and cumulative sum thresholds to match your trading
strategy.
Interpret Visual Cues 👀:
Monitor the chart for green or red arrows and corresponding labels that signal potential buy or
sell opportunities based on cumulative price movements.
Settings Explained 🛠️
Custom Timeframe:
Select an alternative timeframe for analysis, or leave empty to use the current chart's timeframe.
Number of Last Bars to Sum:
Determines how many bars are used to compute the cumulative percentage change.
Buy Condition - Min % Change:
The minimum individual percentage change required to consider a buy signal.
Buy Condition - Min Sum of Bars:
The minimum cumulative percentage change over the defined bars needed for a buy signal.
Sell Condition - Max % Change:
The maximum individual percentage change threshold for a sell signal.
Sell Condition - Max Sum of Bars:
The maximum cumulative percentage change over the defined bars for triggering a sell signal.
Best Use Cases 🎯
Momentum Identification 📈:
Quickly spot strong cumulative price movements and momentum shifts.
Entry/Exit Signals 🚪:
Use the visual signals to determine potential entry and exit points in your trading.
Versatile Strategy Application 🔄:
Effective for scalping, swing trading, and longer-term analysis across various markets.
UPD: uncheck labels for better performance
Monthly Buy IndicatorIt shows us the the total balance when buying monthly, ploting the total invested amount and total current balance along the time.
Opening the Data Window, it displays the profit (%) and the number of trades.
The "Allow Fractional Purchase" flag can be used to check the the performance of the ticker, disregarding how much the monthly amount is set vs the price of the ticker.
The trades are considering buying the available amount on the 1st candle of each month, at the Open price. The "Total Balance" considers the close price of each candle.
Multi-Indicator Signals with Selectable Options by DiGetMulti-Indicator Signals with Selectable Options
Script Overview
This Pine Script is a multi-indicator trading strategy designed to generate buy/sell signals based on combinations of popular technical indicators: RSI (Relative Strength Index) , CCI (Commodity Channel Index) , and Stochastic Oscillator . The script allows you to select which combination of signals to display, making it highly customizable and adaptable to different trading styles.
The primary goal of this script is to provide clear and actionable entry/exit points by visualizing buy/sell signals with arrows , labels , and vertical lines directly on the chart. It also includes input validation, dynamic signal plotting, and clutter-free line management to ensure a clean and professional user experience.
Key Features
1. Customizable Signal Types
You can choose from five signal types:
RSI & CCI : Combines RSI and CCI signals for confirmation.
RSI & Stochastic : Combines RSI and Stochastic signals.
CCI & Stochastic : Combines CCI and Stochastic signals.
RSI & CCI & Stochastic : Requires all three indicators to align for a signal.
All Signals : Displays individual signals from each indicator separately.
This flexibility allows you to test and use the combination that works best for your trading strategy.
2. Clear Buy/Sell Indicators
Arrows : Buy signals are marked with upward arrows (green/lime/yellow) below the candles, while sell signals are marked with downward arrows (red/fuchsia/gray) above the candles.
Labels : Each signal is accompanied by a label ("BUY" or "SELL") near the arrow for clarity.
Vertical Lines : A vertical line is drawn at the exact bar where the signal occurs, extending from the low to the high of the candle. This ensures you can pinpoint the exact entry point without ambiguity.
3. Dynamic Overbought/Oversold Levels
You can customize the overbought and oversold levels for each indicator:
RSI: Default values are 70 (overbought) and 30 (oversold).
CCI: Default values are +100 (overbought) and -100 (oversold).
Stochastic: Default values are 80 (overbought) and 20 (oversold).
These levels can be adjusted to suit your trading preferences or market conditions.
4. Input Validation
The script includes built-in validation to ensure that oversold levels are always lower than overbought levels for each indicator. If the inputs are invalid, an error message will appear, preventing incorrect configurations.
5. Clean Chart Design
To avoid clutter, the script dynamically manages vertical lines:
Only the most recent 50 buy/sell lines are displayed. Older lines are automatically deleted to keep the chart clean.
Labels and arrows are placed strategically to avoid overlapping with candles.
6. ATR-Based Offset
The vertical lines and labels are offset using the Average True Range (ATR) to ensure they don’t overlap with the price action. This makes the signals easier to see, especially during volatile market conditions.
7. Scalable and Professional
The script uses arrays to manage multiple vertical lines, ensuring scalability and performance even when many signals are generated.
It adheres to Pine Script v6 standards, ensuring compatibility and reliability.
How It Works
Indicator Calculations :
The script calculates the values of RSI, CCI, and Stochastic Oscillator based on user-defined lengths and smoothing parameters.
It then checks for crossover/crossunder conditions relative to the overbought/oversold levels to generate individual signals.
Combined Signals :
Depending on the selected signal type, the script combines the individual signals logically:
For example, a "RSI & CCI" buy signal requires both RSI and CCI to cross into their respective oversold zones simultaneously.
Signal Plotting :
When a signal is generated, the script:
Plots an arrow (upward for buy, downward for sell) at the corresponding bar.
Adds a label ("BUY" or "SELL") near the arrow for clarity.
Draws a vertical line extending from the low to the high of the candle to mark the exact entry point.
Line Management :
To prevent clutter, the script stores up to 50 vertical lines in arrays (buy_lines and sell_lines). Older lines are automatically deleted when the limit is exceeded.
Why Use This Script?
Versatility : Whether you're a scalper, swing trader, or long-term investor, this script can be tailored to your needs by selecting the appropriate signal type and adjusting the indicator parameters.
Clarity : The combination of arrows, labels, and vertical lines ensures that signals are easy to spot and interpret, even in fast-moving markets.
Customization : With adjustable overbought/oversold levels and multiple signal options, you can fine-tune the script to match your trading strategy.
Professional Design : The script avoids clutter by limiting the number of lines displayed and using ATR-based offsets for better visibility.
How to Use This Script
Add the Script to Your Chart :
Copy and paste the script into the Pine Editor in TradingView.
Save and add it to your chart.
Select Signal Type :
Use the "Signal Type" dropdown menu to choose the combination of indicators you want to use.
Adjust Parameters :
Customize the lengths of RSI, CCI, and Stochastic, as well as their overbought/oversold levels, to match your trading preferences.
Interpret Signals :
Look for green arrows and "BUY" labels for buy signals, and red arrows and "SELL" labels for sell signals.
Vertical lines will help you identify the exact bar where the signal occurred.
Tips for Traders
Backtest Thoroughly : Before using this script in live trading, backtest it on historical data to ensure it aligns with your strategy.
Combine with Other Tools : While this script provides reliable signals, consider combining it with other tools like support/resistance levels or volume analysis for additional confirmation.
Avoid Overloading the Chart : If you notice too many signals, try tightening the overbought/oversold levels or switching to a combined signal type (e.g., "RSI & CCI & Stochastic") for fewer but higher-confidence signals.
Zerg range filter credit to Kivanc turkish pinecoder for base indicator i reworked with chatgpt and some common sense
this indicator similar to the ADX but i think its better visually to keep you out of market conditions that are unfavorable.
i made original indicator to work in a 0-100 enviroment (before it was a zero middle line oscillator) and added background coloring that has a lower and higher threshold setting. i also added a smoothing moving average. this will trigger threshold levels (not the core oscillator)
above higher level would indicate trending market conditions and its purple. these are the areas where you might want to buy low period moving average bounces like 10 or 21 ema
lower band will paint indicator background blue and its cold, meaning range bound trade ideas are likely play out better. selling resistance and buying horizontal supports for example.
you are encourage to play with lookback period and change thresholds until you find something that works for your trading.
on the picture above it illustrates how i intended its usage.
it also shows divergences which was not intended but also a function.
you can also observe as the oscillator likes to coil up into a tight range (horizontal or a wedge formation) and when these break their trendlines explosive moves are incoming usually.
if you have a trading system and can generate a lot of signals but want to filter out some loser trades this could be the indicator you were looking for.
i hope this will be inline with community guidelines. my other publishing got removed unfortunately
Volume EquilibriumThe intent behind this indicator is to provide comprehensive information relating to volume compared to multiple timeframes. This indicator allows one to see what the market 'theoretically' sees as 'fair-value' whilst also allowing one to gauge where the price of a stock is headed.
Volume Equilibrium
The main indicator finds the difference between buying volume and selling volume, under the basic presumption that more buying volume indicates greater bullish sentiment and vice versa.
Buying Volume = volume when close price is higher than open price.
Selling Volume = volume when close price is lower than open price.
Volume Balance = Cumulative Buying Volume − Cumulative Selling Volume
Volume Balance is then expressed as a percentage by dividing by total volume
This indicator is composed of three different lengths of the same indicator. Short, Mid, and Long term representations of Volume Equilibrium. The difference between the mid and long term are highlighted so to make it easy to see where volume is going relative to a longer time frame.
HOW TO USE:
At 0 ---> Equilibrium ---> Equal Buying/Selling Volume
Above 0 ---> More buying Volume
Below 0 ---> More selling Volume
Using theory, it is assumed that the price is at a 'fair-value' when the buying/selling volume is at 0. This is of course relative to the respective timeframe of your choosing. More weight given to larger timeframes.
Volume Histogram
It is a basic volume chart that represents the total volume though has highlighted bars so to indicate buying(green) and selling(red) volume. This allows one to see what the indicator is based off of.
Open-Close Oscillator(not needed)
Calculates the average open-close for a selected timeframe and then provides the current closing price relative to that average open-close. Very simply put, values below 0 indicate bearish and values above 0 generally indicate bullishness. This indicator is for a quick reference of price action relative to volume.
Another way to use this indicator, though unique, is to analyze the separate open-close lines themselves. Using the open-close bands, bullishness is defined as increasing closing prices and bearish as decreasing closing prices. So, in regard to this indicator, bear sessions can be indicated by the opening line being below the closing line and bull sessions as the opening line being above. Use the 'flip' of these lines to your advantage, they are very helpful at capturing long continuous sentiment.
This indicator is composed of great information though I still think it best to use many different indicators to help you with your trades.
NOTE: Be aware of what we are trying to analyze, Volume. This means that one should also look out for divergences to capture early indications of reversals. This indicator can be leveraged greatly.
Optimus trader Optimus Trader
Indicator Description:
The Optimus Trader indicator is designed for technical traders looking for entry and exit points in financial markets. It combines signals based on volume, moving averages, VWAP (Volume Weighted Average Price), as well as the recognition of candlestick patterns such as Pin Bar and Inside Bars. This indicator helps identify opportune moments to buy or sell based on trends, volumes, and recent liquidity zones.
Parameters and Features:
1. Simple Moving Average (MA) and VWAP:
- Optimus Trader uses a 50-period simple moving average to determine the underlying trend. It also includes VWAP for precise price analysis based on traded volumes.
- These two indicators help identify whether the market is in an uptrend or downtrend, enhancing the reliability of buy and sell signals.
2. Volume :
- To avoid false signals, a volume threshold is set using a 20-period moving average, adjusted to 1.2 times the average volume. This filters signals by considering only high-volume periods, indicating heightened market interest.
3. Candlestick Pattern Recognition:
- Pin Bar: This sought-after candlestick pattern is detected for both bullish and bearish setups. A bullish or bearish *Pin Bar* often signals a possible reversal or continuation.
- *Inside Bar*: This price compression pattern is also detected, indicating a zone of indecision before a potential movement.
4. Trend:
- An uptrend is confirmed when the price is above the MA and VWAP, while a downtrend is identified when the price is below both indicators.
5. Liquidity Zones:
- Optimus Trader includes an approximate liquidity zone detection feature. By identifying recent support and resistance levels, the indicator detects if the price is near these zones. This feature strengthens the relevance of buy or sell signals.
6. Buy and Sell Signals:
- Buy: A buy signal is generated when the indicator detects a bullish *Pin Bar* or *Inside Bar* in an uptrend with high volume, and the price is close to a liquidity zone.
- Sell: A sell signal is generated when a bearish *Pin Bar* or *Inside Bar* is detected in a downtrend with high volume, and the price is near a liquidity zone.
Signal Display:
The signals are visible directly on the chart:
- A "BUY" label in green is displayed below the bar for buy signals.
- A "SELL" label in red is displayed above the bar for sell signals.
Summary:
This indicator is intended for traders seeking precise entry and exit points by integrating trend analysis, volume, and candlestick patterns. With liquidity zones, *Optimus Trader* helps minimize false signals, providing clear and accurate alerts.
---
This description can be directly added to TradingView to help users quickly understand the features and logic of this indicator.
Future Trend Channel [ChartPrime]The Future Trend Channel indicator is a dynamic tool for identifying trends and projecting future prices based on channel formations. The indicator uses SMA (Simple Moving Average) and volatility calculations to plot channels that visually represent trends. It also detects moments of lower momentum, indicated by neutral color changes in the channels, and projects future price levels for up to 50 bars ahead.
⯁ KEY FEATURES AND HOW TO USE
⯌ Dynamic Trend Channels :
The indicator draws channels when a trend is identified. It uses a combination of SMA and volatility to determine the direction and strength of the trend. Each channel is visualized with a specific color, where green indicates an uptrend and orange represents a downtrend.
Example of channels during uptrend and downtrend:
⯌ Momentum-Based Color Shifts :
The indicator adapts its channel colors based on momentum changes. When the starting point (Y1) of a channel is higher than its ending point (Y2) during an uptrend, the channel turns neutral, indicating lower momentum and a possible ranging market. The same applies in a downtrend, where the channel turns neutral if Y1 is lower than Y2.
Example of neutral momentum channels:
⯌ Future Price Projection :
At the end of each channel, the indicator generates a projected future price based on the midpoint of the channel. By default, this projection is made 50 bars into the future, but users can adjust the number of bars to their preference.
Example of future price projection:
⯌ Diamond Signals for Valid Trends :
Lime-colored diamonds appear when an uptrend channel is confirmed, while orange diamonds indicate valid downtrend channels. These signals confirm the presence of a strong trend and help identify valid entry and exit points. Neutral channels, which indicate lower momentum, do not show diamond signals.
Example of trend confirmation signals:
⯌ Customizable Settings :
Users can adjust the channel length (how far back the trend is analyzed) and the width (which determines the channel boundaries based on volatility). The future price projection can also be customized to forecast further or fewer bars into the future.
⯁ USER INPUTS
Trend Length : Sets the number of bars used to calculate the trend channels.
Channel Width : Adjusts the width of the channels, based on volatility (ATR multiplier).
Up and Down Colors : Allows customization of the colors used for uptrend and downtrend channels.
Future Bars : Sets the number of bars used for future price projection.
⯁ CONCLUSION
The Future Trend Channel indicator is a versatile tool for identifying and trading trends. With its ability to detect momentum shifts and project future prices, it provides traders with key insights for making more informed decisions. The use of diamond signals for trend validation adds an extra layer of confirmation, helping traders act with greater confidence during volatile or trending markets.
Trend Levels [ChartPrime]The Trend Levels indicator is designed to identify key trend levels (High, Mid, and Low) during market trends, based on real-time calculations of highest, lowest, and mid-level values over a customizable length. Additionally, the indicator calculates trend strength by measuring the ratio of candles closing above or below the midline, providing a clear view of the ongoing trend dynamics and strength.
⯁ KEY FEATURES AND HOW TO USE
⯌ Trend Shift Signals :
Trend shifts, based on highest and lowest values during input length. When high is == to highest it will change trend to up when low == lowest value it will be shift to down trend.
// Calculate highest and lowest over the specified length
h = ta.highest(length)
l = ta.lowest(length)
// Determine trend direction: if the current high is the highest value, set trend to true
if h == high
trend := true
// If the current low is the lowest value, set trend to false
if l == low
trend := false
Whenever the trend changes direction (from uptrend to downtrend or vice versa), the indicator provides visual cues in the form of arrows. This gives traders clear signals to identify potential trend reversals, enabling them to adjust their strategies accordingly.
⯌ Trend Level Calculation :
As soon as a trend is detected (uptrend or downtrend), the indicator starts calculating the highest, lowest, and mid-level values over the defined period. These levels are plotted on the chart as color-coded lines for easy visualization, allowing traders to quickly spot the key levels within a trend.
⯌ Midline Retests :
Throughout the trend, the mid-level line is often retested, acting as a potential zone for pullbacks or rejections. Traders can use these retests as opportunities for entering positions or confirming trend continuation. The chart shows how price frequently interacts with the midline, helping to identify important reaction levels.
⯌ Trend Strength Calculation :
The indicator measures the trend strength by calculating the delta between the number of candles closing above and below the midline. This percentage-based delta is displayed in real-time, providing a clear indication of whether the trend is gaining or losing momentum.
⯁ USER INPUTS
Length : Specifies the lookback period for calculating the highest and lowest values, which determines the key trend levels.
Candle Counting : Measures the number of candles closing above and below the midline to calculate the trend strength delta.
⯁ CONCLUSION
The Trend Levels indicator provides traders with a powerful tool for visualizing trend dynamics, key levels of support and resistance, and real-time trend strength. By identifying midline retests, tracking candle counts, and providing trend shift signals, this indicator can help traders make well-informed decisions during market trends.
Regression Indicator [BigBeluga]Regression Indicator
Indicator Overview:
The Regression Indicator is designed to help traders identify trends and potential reversals in price movements. By calculating a regression line and a normalized regression indicator, it provides clear visual signals for market direction, aiding in making informed trading decisions. The indicator dynamically updates with the latest market data, ensuring timely and relevant signals.
Key Features:
⦾ Calculations
Regression Indicator: Calculates the linear regression coefficients (slope and intercept) and derives the normalized distance close from the regression line.
// @function regression_indicator is a Normalized Ratio of Regression Lines with close
regression_indicator(src, length) =>
sum_x = 0.0
sum_y = 0.0
sum_xy = 0.0
sum_x_sq = 0.0
distance = 0.0
// Calculate Sum
for i = 0 to length - 1 by 1
sum_x += i + 1
sum_y += src
sum_xy += (i + 1) * src
sum_x_sq += math.pow(i + 1, 2)
// Calculate linear regression coefficients
slope = (length * sum_xy - sum_x * sum_y)
/ (length * sum_x_sq - math.pow(sum_x, 2))
intercept = (sum_y - slope * sum_x) / length
// Calculate Regression Indicator
y1 = intercept + slope
distance := (close - y1)
distance_n = ta.sma((distance - ta.sma(distance, length1))
/ ta.stdev(distance, length1), 10)
⦿ Reversion Signals:
Marks potential trend reversal points.
⦿ Trend Identification:
Highlights when the regression indicator crosses above or below the zero line, signaling potential trend changes.
⦿ Color-Coded Candles:
Changes candle colors based on the regression indicator's value.
⦿ Arrow Markers:
Indicate trend directions on the chart.
⦿ User Inputs
Regression Length: Defines the period for calculating the regression line.
Normalization Length: Period used to normalize the regression indicator.
Signal Line: Length for averaging the regression indicator to generate signals.
Main Color: Color used for plotting the regression line and signals.
The Regression Indicator is a powerful tool for analyzing market trends and identifying potential reversal points. With customizable inputs and clear visual aids, it enhances the trader's ability to make data-driven decisions. The dynamic nature of the indicator ensures it remains relevant with up-to-date market information, making it a valuable addition to any trading strategy."
Multi Asset Histogram [ChartPrime]Multi Asset Histogram Indicator
Overview:
The "Multi Asset Histogram" indicator provides a comprehensive visualization of the performance of multiple assets relative to each other. By calculating a score for each asset and displaying it in a histogram format, this indicator helps traders quickly identify the trends, dominant asset and the average performance of the assets in the selected group.
Key Features:
◆ Multi-Asset Score Calculation:
The indicator calculates a trend score for each selected asset based on the price source (e.g., hl2).
The trend score is determined by comparing the current price to the prices over the past bars back defined by user, adding or subtracting points based on whether the current price is higher or lower than previous prices.
// Score Function
trscore(src) =>
total = 0.0
for i = 1 to 50
total += (src >= nz(src ) ? 1 : -1)
total
◆ Flexible Symbol Input:
Traders can input up to 10 different symbols (e.g., BTCUSD, ETHUSD, etc.) to be included in the histogram analysis.
◆ Dynamic Visualization:
A histogram is plotted for each asset, with bars colored based on the score, providing a clear visual representation of the relative performance.
Color gradients from red to aqua indicate the performance, with red representing negative scores and aqua representing positive scores.
◆ Adaptive Histogram Lines:
The width and placement of histogram lines adapt based on the calculated scores, ensuring clear visualization regardless of the values.
Dashed lines represent the mean score of all assets, helping traders identify the overall market trend.
◆Detailed Labels and Values:
Labels are placed on the histogram to display the exact score for each asset.
Mean value and zero line labels provide additional context for the overall performance.
◆ Visual Scaling Lines:
Zero line and mean line are clearly marked, helping traders understand the distribution and scale of scores.
Scales on the left and right of the histogram indicate the performance range.
◆ Informative Table:
A table is displayed on the chart, showing the dominant asset (the one with the highest score) and the mean score of all assets.
The table updates dynamically to reflect real-time changes in asset performance.
◆ Settings:
Length: The value of number bars back is greater or less than the current value of the source
Source: The price source to be used for score calculation (e.g., hl2).
Symbols: Up to 10 different asset symbols can be input for analysis.
Usage Notes:
This indicator is useful for traders who monitor multiple assets simultaneously and need a quick visual reference to identify the strongest and weakest performers.
The color coding and dynamic labels make it easy to interpret the relative performance and make informed trading decisions.
This indicator is designed to enhance multi-asset analysis by providing a clear, visual representation of each asset's performance relative to the others, making it easier to identify trends and dominant assets in the market.
Volume Positive & Negative Levels [ChartPrime]Volume Positive & Negative Levels
Overview:
The Volume Positive & Negative Levels indicator by ChartPrime is designed to provide traders with a clear visualization of volume activity across different price levels. By plotting volume levels as histograms, this tool helps identify significant areas of buying (positive volume) and selling (negative volume) pressure, enhancing the ability to spot potential support and resistance zones.
Key Features:
⯁ Lookback Period:
- The `lookbackPeriod` parameter, set to 500 bars, determines the range over which the volume analysis is conducted, ensuring a comprehensive view of the market’s volume activity. The maximum lookback period is 500 bars or the bars currently visible on the chart, whichever is smaller.
⯁ Dynamic Volume Calculation:
- Volume is calculated dynamically based on the price action, with positive volume indicating buying pressure (close > open) and negative volume indicating selling pressure (close < open).
⯁ Color Coding for Clarity:
- Positive Volume: Represented with a distinct color (`#ad9a2c`), making it easy to identify areas of buying interest.
- Negative Volume: Highlighted with another color (`#ad2cad`), simplifying the detection of selling pressure.
Volume Threshold and Bins:
- The indicator allows users to set a volume threshold (`volume_level`) to highlight significant volume levels, with the default set at 70.
- The number of bins (`numBins`) defines the granularity of the volume profile, with a higher number providing more detail.
⯁ Volume Profile Visualization:
- The volume profile is plotted as a histogram, with the height of each bar proportional to the volume at that price level. This visualization helps in quickly assessing the strength of volume at various price points.
⯁ Interactive Labels and Threshold Indicators:
- Labels: The indicator uses labels to mark significant volume levels, providing quick reference points for traders.
- Threshold Lines: Lines are drawn at specified volume thresholds, with colors and widths dynamically adjusted based on the volume levels.
⯁ User Inputs:
- Volume Threshold (`volume_level`): Sets the minimum volume required to highlight significant levels.
- Number of Bins (`numBins`): Determines the resolution of the volume profile.
- Line Width (`line_withd`): Specifies the width of the lines used in the visualization.
The Volume Positive & Negative Levels indicator is a powerful tool for traders looking to gain deeper insights into market dynamics. By providing a clear visual representation of volume activity across different price levels, it helps traders identify key support and resistance zones, spot trends, and make more informed trading decisions. Whether you are a day trader or a swing trader, this indicator enhances your ability to analyze volume data effectively, improving your overall trading strategy.
Higher Timeframe High & Low [ChartPrime]The Higher Timeframe High & Low Indicator plots key levels (high, low, and average price) from a higher timeframe onto the current chart, aiding traders in identifying significant support and resistance zones.
The indicator also detects and labels breakout points and can display trend directions based on these higher timeframe levels breakout points.
Key Features:
◆ Higher Timeframe Levels:
Plots the high, low, and average price from a selected higher timeframe onto the current chart.
Extends these levels into the future for better visualization.
◆ Breakout Detection:
Identifies and labels breakouts above the higher timeframe high or below the higher timeframe low.
Breakout points are clearly marked with labels indicating "High Break" or "Low Break" with timeframe mark.
If the following break out type is the same that previous, it does not marked by labels, but still marked by bar color.
◆ Trend Visualization:
Optionally displays trend direction by changing bar colors and line styles based on breakout conditions.
Trend indication helps in identifying bullish or bearish market conditions.
◆ Support and Resistance Indication:
Marks support and resistance points with '◆' symbols when the current timeframe's high or low interacts with the higher timeframe's levels.
◆ Period separation:
Background color changes to indicate period separation if enabled.
◆ Inputs:
Extension to the right of High and Low: Sets the number of bars to extend the high and low lines into the future.
Timeframe: Selects the higher timeframe (e.g., Daily) to use for plotting high and low levels.
Period Separator: Toggles the visual separator for periods.
Show Trend?: Toggles the trend visualization, changing bar colors and plot styles based on breakouts.
Show Breakout Labels?: Toggles the Breakout Labels visualization.
Indicator Logic:
Historical vs. Real-Time Bars: Adjusts values based on whether the bar is historical or real-time to ensure accurate plotting.
High and Low Prices: Retrieves the high and low prices from the selected higher timeframe.
Breakout Conditions: Determines if the current price has crossed above the higher timeframe high (high break) or below the higher timeframe low (low break).
Color and Trend Logic: Adjusts colors and checks for breakouts to avoid multiple labels and indicate trend direction.
Usage Notes:
This indicator is ideal for traders looking to integrate multi-timeframe analysis into their strategy.
The higher timeframe levels act as significant support and resistance zones, helping traders identify potential reversal or continuation points.
The breakout labels and trend visualization provide additional context for trading decisions, indicating when the price has breached key levels and is likely to continue in that direction.
This indicator enhances chart analysis by providing clear, visual cues from higher timeframe data, helping traders make more informed decisions based on a broader market perspective.
IchimokuBuy Sell With Stoch RSIIchimoku Kumo Cloud Crossover Indicator
The "Ichimoku Kumo Cloud Crossover" indicator is a custom technical analysis tool designed for use in the TradingView platform. This indicator is built to assist traders in identifying potential buy and sell signals based on a combination of Ichimoku Cloud analysis, Moving Average Convergence Divergence (MACD), Exponential Moving Average (EMA), Relative Strength Index (RSI), and Stochastic RSI.
Key Components and Parameters:
Ichimoku Kumo Cloud Calculation:
The Ichimoku Kumo Cloud is calculated using the Ichimoku Cloud's Conversion Line and Base Line.
Conversion Line, Base Line, Leading Span 1, and Leading Span 2:
These are key components of the Ichimoku Cloud, and they help identify trends and potential support/resistance levels in the market.
MACD Oscillator:
The Moving Average Convergence Divergence (MACD) is used to gauge the strength and direction of the trend.
EMA 200 (Exponential Moving Average):
The EMA 200 is a long-term moving average used to identify the overall trend direction.
RSI (Relative Strength Index):
The RSI is a momentum oscillator that measures the speed and change of price movements, helping to identify overbought and oversold conditions.
Stochastic RSI (Stoch RSI):
Stoch RSI is calculated based on the RSI values and helps to identify overbought and oversold conditions in a more dynamic manner.
Signal Generation:
The indicator generates buy and sell signals based on the following criteria:
Buy Signal (Long Position):
The Conversion Line crosses above the Base Line (Ichimoku Cloud crossover).
The closing price is above the EMA 200, indicating a bullish bias.
The RSI is between 50 and 70, suggesting the potential for an uptrend.
The MACD Histogram is positive, indicating increasing bullish momentum.
The high price is at least 25% above the EMA 200.
Sell Signal (Short Position):
The Conversion Line crosses below the Base Line (Ichimoku Cloud crossover).
The closing price is below the EMA 200, indicating a bearish bias.
The RSI is between 20 and 50, suggesting the potential for a downtrend.
The MACD Histogram is negative, indicating increasing bearish momentum.
The low price is at least 25% below the EMA 200.
Stoch RSI Filter:
Additionally, a filter based on Stoch RSI slope is applied. The indicator will only open a position if the Stoch RSI is declining for short positions (sell) and rising for long positions (buy).
Visualization:
Buy signals are marked with green triangles below the bars.
Sell signals are marked with red triangles above the bars.
The Ichimoku Cloud is plotted in the background, with cloud colors changing based on whether the Conversion Line or Base Line is higher.
This indicator can be a valuable tool for traders looking to combine multiple technical analysis techniques to make informed trading decisions in the financial markets.
VWAP angle TrendThe VWAP Angle Trend is an indicator built with the aim of providing valuable insights into the reversal points of the #VWAP using Angle
This is achieved by calculating the angle between the current VWAP and its previous value over a customizable lookback period and normalizing it with ATR
By analyzing the angle, we can gain an understanding of the strength and direction of the VWAP, which can help them identify potential trend reversals or continuations.
After observing the market over a lengthy period, I have come to realize that as the angle increases above 65 or decreases under -65 , it confirms a higher likelihood of a trend reversal.
the indicator highlights these zones where a trend reversal is more likely to occur.
The indicator can help you to assess the strength and direction of VWAP, enabling you to make more informed trading decisions.
By identifying periods of strong momentum or potential exhaustion, you can seek opportunities for entering or exiting positions, and potentially capitalize on trend movements in the market.
RSI Momentum TrendThe "RSI Momentum Trend" indicator is a valuable tool for traders seeking to identify momentum trends.
By utilizing the Relative Strength Index (RSI) and customizable momentum thresholds, this indicator helps traders spot potential bullish and bearish signals.
you can adjust input parameters such as the RSI period, positive and negative momentum thresholds, and visual settings to align with their trading strategies.
The indicator calculates the RSI and evaluates two momentum conditions: positive and negative.
The positive condition considers the previous RSI value, current RSI value, and positive change in the 5-period exponential moving average (EMA) of the closing price.
The negative condition looks at the current RSI value and negative change in the 5-period EMA.
Once a momentum condition is met, the indicator visually represents the signal on the chart.
The "RSI Momentum Trend" indicator provides you with a quick and effective way to identify momentum trends using RSI calculations.
By incorporating visual cues and customizable parameters, it assists traders in making informed decisions about potential market movements.
Parabolic SAR + EMA 200 + MACD SignalsParabolic SAR + EMA 200 + MACD Signals Indicator, a powerful tool designed to help traders identify optimal entry points in the market.
This indicator combines three popular technical indicators: Parabolic SAR (Stop and Reverse), EMA200 (Exponential Moving Average 200) and MACD (Moving Average Convergence Divergence) - to provide clear and concise buy and sell signals based on market trends.
The MACD component of this indicator calculates the difference between two exponentially smoothed moving averages, providing insight into the trend strength of the market. The Parabolic SAR component helps identify potential price reversals, while the EMA200 acts as a key level of support and resistance, providing additional confirmation of the overall trend direction.
Whether you're a seasoned trader or just starting out, the MACD-Parabolic SAR-EMA200 Indicator is a must-have tool for anyone looking to improve their trading strategy and maximize profits in today's dynamic markets.
Buy conditions
The price should be above the EMA 200
Parabolic SAR should show an upward trend
MACD Delta should be positive
ُSell conditions
The price should be below the EMA 200
Parabolic SAR should show an downward trend
MACD Delta should be negative
B/S Volume with Timeframe InputDaytrading For Success's volume indicator with timeframe input selection added. Example shown is 1 minute time frame with 5 minute input selected.