Buy side or sell side liquidity sweep

acom

New member
Looking for custom tos indicator which can alert with chart highlight upon buyside or sellside liquidity sweep on 2 min chart. Consideration should be taken for break of wick in prior 1 hour price action. This will be used for ES chart primarily. Can someone help in making this custom indicator?
 
Solution
Looking for custom tos indicator which can alert with chart highlight upon buyside or sellside liquidity sweep on 2 min chart. Consideration should be taken for break of wick in prior 1 hour price action. This will be used for ES chart primarily. Can someone help in making this custom indicator?

i started out using normal 2nd aggregation price data for this, but i abandoned it.
in the code i had, when checking for,
2min chart candles crossing price levels from a 2nd agg time period of 1 hour,
only the first 2min bar in the period was triggering. the other bars were ignored.

---------------------------

i used secondsfromTime() to determine how many chart minutes have elapsed. then divided that by a number, to determine the...
Looking for custom tos indicator which can alert with chart highlight upon buyside or sellside liquidity sweep on 2 min chart. Consideration should be taken for break of wick in prior 1 hour price action. This will be used for ES chart primarily. Can someone help in making this custom indicator?

in future postings, please come up with a simpler, more descriptive titles and descriptions.
liquidity sweep ?? that has no meaning.
all you needed to say was in your 2nd sentence, look for price crossing some level.

more to come...............
 
Looking for custom tos indicator which can alert with chart highlight upon buyside or sellside liquidity sweep on 2 min chart. Consideration should be taken for break of wick in prior 1 hour price action. This will be used for ES chart primarily. Can someone help in making this custom indicator?

i started out using normal 2nd aggregation price data for this, but i abandoned it.
in the code i had, when checking for,
2min chart candles crossing price levels from a 2nd agg time period of 1 hour,
only the first 2min bar in the period was triggering. the other bars were ignored.

---------------------------

i used secondsfromTime() to determine how many chart minutes have elapsed. then divided that by a number, to determine the periods.
i kept the 2nd agg input, but i didn't use it to read a price. it is used just for choosing the quantity of minutes in 2nd time period. i like it better than entering in a number. it limits the choices so oddball numbers can't be entered.

if the chart time divides evenly into the 2nd agg time, this should work.
(agg time of hour / 2 min chart min ) = integer


default use,
it draws arrows when,
.. high crosses above a previous hours highest price
.. or low crosses below a previous hours lowest price.
an alert will sound when a crossing happens


options,
. show previous time period lines
. show current time period lines
. labels that show period and bar stats



Code:
# prev_hour_exceed_00e

# https://usethinkscript.com/threads/buy-side-or-sell-side-liquidity-sweep.14735/
#Buy side or sell side liquidity sweep
# acom  mar 5, 2023
#Looking for custom tos indicator which can alert with chart highlight upon buyside or sellside liquidity sweep on 2 min chart. Consideration should be taken for break of wick in prior 1 hour price action. This will be used for ES chart primarily. Can someone help in making this custom indicator?

#wick exceeding prior 1 hour price action range

def na = double.nan;
def bn = barnumber();

input sym2 = "/ES:XCME";

#---------------------------------
# get chart agg time
def chartagg = getaggregationperiod();
def chartmin = chartagg/(1000*60);
#---------------------------------
# pick an agg time for the longer time period
input agg = AggregationPeriod.HOUR;
def aggmin = agg/60000;
#---------------------------------
def data = close(period = agg);
def aggratio = aggmin/chartmin;
def daybars = 390 / chartmin;
def dayaggbars = 390/aggmin;
#---------------------------------
input agg_labels = yes;
addlabel(agg_labels, " ", color.black);
addlabel(agg_labels, "chart min " + chartmin, color.yellow);
addlabel(agg_labels, "day bars " + daybars, color.yellow);
addlabel(agg_labels, " ", color.black);
addlabel(agg_labels, "agg min " + aggmin, color.yellow);
addlabel(agg_labels, "agg day bars " + dayaggbars, color.yellow);
addlabel(agg_labels, " ", color.black);
addlabel(agg_labels, "agg ratio " + aggratio, color.yellow);
addlabel(agg_labels, " ", color.black);
#---------------------------------


def start3 = 0000;
def tminoff = if getsymbol() == sym2 then 0 else 30;
# if normal trading hours, add offset so an hour period starts at xx:30
def start3_min = (secondsfromTime(start3)/60) + tminoff;

def t1 = (start3_min % aggmin);
def t2 = if t1 == 0 then 1 else 0;
def t3 = if bn == 1 then 1
 else if t2 then t3[1] + 1
 else t3[1];


# find hi and lo of a time period, 
def big = 99999;
def thi;
def tlo;
if t2 then {
 thi = fold i1 = 0 to 200
 with p1
 while getvalue(t3, -i1) == t3
 do if getvalue(high, -i1) > p1 then getvalue(high, -i1) else p1;

 tlo = fold i2 = 0 to 200
 with p2 = big
 while getvalue(t3, -i2) == t3
 do if getvalue(low, -i2) < p2 then getvalue(low, -i2) else p2;

} else {
 thi = thi[1];
 tlo = tlo[1];
}

# current period lines
input show_current_period_lines = no;
plot z1 = if show_current_period_lines then thi else na;
plot z2 = if show_current_period_lines then tlo else na;
z1.SetDefaultColor(Color.green);
z2.SetDefaultColor(Color.red);
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#------------------------------

# prev period lines
def t2hi = getvalue(thi, aggratio);
def t2lo = getvalue(tlo, aggratio);

input show_previous_period_lines = yes;
plot z3 = if show_previous_period_lines then t2hi else na;
plot z4 = if show_previous_period_lines then t2lo else na;
z3.SetDefaultColor(Color.cyan);
z4.SetDefaultColor(Color.yellow);
z3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#-----------------------------

def xup = if high crosses above t2hi then 1 else 0;
def xdwn = if low crosses below t2lo then 1 else 0;

def vert = 0.0004;
plot z2u = if xup then (low*(1-vert)) else na;
z2u.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z2u.SetDefaultColor(Color.green);
z2u.setlineweight(3);
z2u.hidebubble();

plot z2d = if xdwn then (high*(1+vert)) else na;
z2d.SetPaintingStrategy(PaintingStrategy.ARROW_down);
z2d.SetDefaultColor(Color.red);
z2d.setlineweight(2);
z2d.hidebubble();


alert(xup, "crossed up" ,alert.BAR, sound.DING);
alert(xdwn, "crossed down" ,alert.BAR, sound.bell);


#-------------------------------------------

input test1 = no;
addchartbubble(test1, low*0.996,
#start2_min + "\n" +
#start2_hr + "\n" +
(secondsfromTime(start3)/60)  + "\n" +
start3_min + "\n" +
t1 + "\n" +
t2 + "\n" +
t3 + "\n" +
(start3_min / aggmin)
, color.yellow, no);
#, (if x > 0 then color.yellow else color.gray), no);


# used this to get actual symbol for /es
input test2 = no;
addlabel(test2,  tminoff );
addlabel(test2, getsymbol());
#
#

BK 2min 3/16
period of 1 hour
kWtFr1l.jpg
 
Solution
If you're looking for a rolling 1h period, putting donchian channels on (in TOS, it's called price channels) 30 period on 2m chart will show you highs and lows of the last hour. It would be easy to visualize a move above or below the line.
 
i started out using normal 2nd aggregation price data for this, but i abandoned it.
in the code i had, when checking for,
2min chart candles crossing price levels from a 2nd agg time period of 1 hour,
only the first 2min bar in the period was triggering. the other bars were ignored.

---------------------------

i used secondsfromTime() to determine how many chart minutes have elapsed. then divided that by a number, to determine the periods.
i kept the 2nd agg input, but i didn't use it to read a price. it is used just for choosing the quantity of minutes in 2nd time period. i like it better than entering in a number. it limits the choices so oddball numbers can't be entered.

if the chart time divides evenly into the 2nd agg time, this should work.
(agg time of hour / 2 min chart min ) = integer


default use,
it draws arrows when,
.. high crosses above a previous hours highest price
.. or low crosses below a previous hours lowest price.
an alert will sound when a crossing happens


options,
. show previous time period lines
. show current time period lines
. labels that show period and bar stats



Code:
# prev_hour_exceed_00e

# https://usethinkscript.com/threads/buy-side-or-sell-side-liquidity-sweep.14735/
#Buy side or sell side liquidity sweep
# acom  mar 5, 2023
#Looking for custom tos indicator which can alert with chart highlight upon buyside or sellside liquidity sweep on 2 min chart. Consideration should be taken for break of wick in prior 1 hour price action. This will be used for ES chart primarily. Can someone help in making this custom indicator?

#wick exceeding prior 1 hour price action range

def na = double.nan;
def bn = barnumber();

input sym2 = "/ES:XCME";

#---------------------------------
# get chart agg time
def chartagg = getaggregationperiod();
def chartmin = chartagg/(1000*60);
#---------------------------------
# pick an agg time for the longer time period
input agg = AggregationPeriod.HOUR;
def aggmin = agg/60000;
#---------------------------------
def data = close(period = agg);
def aggratio = aggmin/chartmin;
def daybars = 390 / chartmin;
def dayaggbars = 390/aggmin;
#---------------------------------
input agg_labels = yes;
addlabel(agg_labels, " ", color.black);
addlabel(agg_labels, "chart min " + chartmin, color.yellow);
addlabel(agg_labels, "day bars " + daybars, color.yellow);
addlabel(agg_labels, " ", color.black);
addlabel(agg_labels, "agg min " + aggmin, color.yellow);
addlabel(agg_labels, "agg day bars " + dayaggbars, color.yellow);
addlabel(agg_labels, " ", color.black);
addlabel(agg_labels, "agg ratio " + aggratio, color.yellow);
addlabel(agg_labels, " ", color.black);
#---------------------------------


def start3 = 0000;
def tminoff = if getsymbol() == sym2 then 0 else 30;
# if normal trading hours, add offset so an hour period starts at xx:30
def start3_min = (secondsfromTime(start3)/60) + tminoff;

def t1 = (start3_min % aggmin);
def t2 = if t1 == 0 then 1 else 0;
def t3 = if bn == 1 then 1
 else if t2 then t3[1] + 1
 else t3[1];


# find hi and lo of a time period,
def big = 99999;
def thi;
def tlo;
if t2 then {
 thi = fold i1 = 0 to 200
 with p1
 while getvalue(t3, -i1) == t3
 do if getvalue(high, -i1) > p1 then getvalue(high, -i1) else p1;

 tlo = fold i2 = 0 to 200
 with p2 = big
 while getvalue(t3, -i2) == t3
 do if getvalue(low, -i2) < p2 then getvalue(low, -i2) else p2;

} else {
 thi = thi[1];
 tlo = tlo[1];
}

# current period lines
input show_current_period_lines = no;
plot z1 = if show_current_period_lines then thi else na;
plot z2 = if show_current_period_lines then tlo else na;
z1.SetDefaultColor(Color.green);
z2.SetDefaultColor(Color.red);
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#------------------------------

# prev period lines
def t2hi = getvalue(thi, aggratio);
def t2lo = getvalue(tlo, aggratio);

input show_previous_period_lines = yes;
plot z3 = if show_previous_period_lines then t2hi else na;
plot z4 = if show_previous_period_lines then t2lo else na;
z3.SetDefaultColor(Color.cyan);
z4.SetDefaultColor(Color.yellow);
z3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#-----------------------------

def xup = if high crosses above t2hi then 1 else 0;
def xdwn = if low crosses below t2lo then 1 else 0;

def vert = 0.0004;
plot z2u = if xup then (low*(1-vert)) else na;
z2u.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z2u.SetDefaultColor(Color.green);
z2u.setlineweight(3);
z2u.hidebubble();

plot z2d = if xdwn then (high*(1+vert)) else na;
z2d.SetPaintingStrategy(PaintingStrategy.ARROW_down);
z2d.SetDefaultColor(Color.red);
z2d.setlineweight(2);
z2d.hidebubble();


alert(xup, "crossed up" ,alert.BAR, sound.DING);
alert(xdwn, "crossed down" ,alert.BAR, sound.bell);


#-------------------------------------------

input test1 = no;
addchartbubble(test1, low*0.996,
#start2_min + "\n" +
#start2_hr + "\n" +
(secondsfromTime(start3)/60)  + "\n" +
start3_min + "\n" +
t1 + "\n" +
t2 + "\n" +
t3 + "\n" +
(start3_min / aggmin)
, color.yellow, no);
#, (if x > 0 then color.yellow else color.gray), no);


# used this to get actual symbol for /es
input test2 = no;
addlabel(test2,  tminoff );
addlabel(test2, getsymbol());
#
#

BK 2min 3/16
period of 1 hour
kWtFr1l.jpg
Thanks @halcyonguy. I will take a look.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
249 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

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

Frequently Asked Questions

What is useThinkScript?

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

How do I get started?

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

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

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