Buy side or sell side liquidity sweep - useThinkScript Community (2024)

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 rangedef na = double.nan;def bn = barnumber();input sym2 = "/ES:XCME";#---------------------------------# get chart agg timedef chartagg = getaggregationperiod();def chartmin = chartagg/(1000*60);#---------------------------------# pick an agg time for the longer time periodinput 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:30def 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 linesinput 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 linesdef 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 /esinput test2 = no;addlabel(test2, tminoff );addlabel(test2, getsymbol());##

BK 2min 3/16
period of 1 hour

Buy side or sell side liquidity sweep - useThinkScript Community (1)

Buy side or sell side liquidity sweep - useThinkScript Community (2024)
Top Articles
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 5942

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.