Please Convert Master Pattern [LuxAlgo] to PROREALTIME
Forums › ProRealTime English forum › ProBuilder support › Please Convert Master Pattern [LuxAlgo] to PROREALTIME
- This topic has 2 replies, 2 voices, and was last updated 1 week ago by
yas.
-
-
07/17/2025 at 9:37 AM #248908
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo//@version=5
indicator(“Master Pattern [LuxAlgo]”, “LuxAlgo – Master Pattern Indicator”, overlay = true, max_boxes_count = 500, max_lines_count = 500)
//——————————————————————————
//Settings
//—————————————————————————–{
length = input.int(3, ‘Contraction Detection Lookback’, minval = 1)
liqLength = input.int(20, ‘Liquidity Levels’, minval = 1)showMajor = input(true, ‘Show Major Pattern’)
showMinor = input(true, ‘Show Minor Pattern’)//Style
bullCss = input.color(color.teal, ‘Bullish Pattern’, inline = ‘bull’, group = ‘Pattern Style’)
showBullBox = input(true, ‘Area’, inline = ‘bull’, group = ‘Pattern Style’)
showBullLvl = input(true, ‘Line’, inline = ‘bull’, group = ‘Pattern Style’)bearCss = input.color(color.red, ‘Bearish Pattern’, inline = ‘bear’, group = ‘Pattern Style’)
showBearBox = input(true, ‘Area’, inline = ‘bear’, group = ‘Pattern Style’)
showBearLvl = input(true, ‘Line’, inline = ‘bear’, group = ‘Pattern Style’)//Liquidity Style
showLiq = input(true, ‘Show Liquidity Levels’, group = ‘Liquidity’)
bullLiqCss = input.color(color.teal, ‘Upper Liquidity’, group = ‘Liquidity’)
bearLiqCss = input.color(color.red, ‘Lower Liquidity’, group = ‘Liquidity’)//—————————————————————————–}
//UDT
//—————————————————————————–{
type mp
box area
line avg
bool breakup
bool breakdn//—————————————————————————–}
//Detect contraction
//—————————————————————————–{
var phy = 0., var phx = 0, var pht = 0.
var ply = 0., var plx = 0, var plt = 0.var float top = na
var float btm = nan = bar_index
ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)if ph
pht := math.sign(ph – phy)
phy := phif pht == -1 and plt == 1
top := ph
btm := ply
phx := n-lengthif pl
plt := math.sign(pl – ply)
ply := plif pht == -1 and plt == 1
top := phy
btm := pl
plx := n-length//—————————————————————————–}
//Set pattern
//—————————————————————————–{
var mp master = mp.new()//Detect master pattern
isbull = high[length] > top and top > btm
isbear = low[length] < btm and top > btmif isbull or isbear
css = isbull ? bullCss : bearCssmaster.avg.set_x2(n-length)
val = math.avg(top, btm)
//Create new master pattern object
master := mp.new(
(isbull and showBullBox) or (isbear and showBearBox) ? box.new(math.max(phx, plx), top, n-length, btm, na, bgcolor = showMinor ? color.new(css, 50) : na) : na
, (isbull and showBullLvl) or (isbear and showBearLvl) ? line.new(n-length, val, n, val, color = showMinor ? css : na) : na
, isbull
, isbear)top := na
btm := na//Determine if pattern switch to major
if master.breakup
if low < master.area.get_bottom()
if not showMajor
master.area.delete()
master.avg.delete()
else
master.area.set_border_color(bullCss)
if not showMinor
master.area.set_bgcolor(color.new(bullCss, 50))
master.avg.set_color(bullCss)
else if master.breakdn
if high > master.area.get_top()
if not showMajor
master.area.delete()
master.avg.delete()
else
master.area.set_border_color(bearCss)
if not showMinor
master.area.set_bgcolor(color.new(bearCss, 50))
master.avg.set_color(bearCss)//Set friction level x2 coordinate to current bar
if not na(master.avg)
master.avg.set_x2(n)//—————————————————————————–}
//Liquidity levels
//—————————————————————————–{
var line liqup = na, var liqup_reach = false
var line liqdn = na, var liqdn_reach = falseliqph = ta.pivothigh(liqLength, liqLength)
liqpl = ta.pivotlow(liqLength, liqLength)//Set upper liquidity
if liqph and showLiq
if not liqup_reach
liqup.set_x2(n-liqLength)liqup := line.new(n-liqLength, liqph, n, liqph, color = bullLiqCss, style = line.style_dotted)
liqup_reach := false
else if not liqup_reach and showLiq
liqup.set_x2(n)if high > liqup.get_y1()
liqup_reach := true//Set lower liquidity
if liqpl and showLiq
if not liqdn_reach
liqdn.set_x2(n-liqLength)liqdn := line.new(n-liqLength, liqpl, n, liqpl, color = bearLiqCss, style = line.style_dotted)
liqdn_reach := false
else if not liqdn_reach and showLiq
liqdn.set_x2(n)if low < liqdn.get_y1()
liqdn_reach := true//—————————————————————————–}
07/17/2025 at 2:12 PM #248935Here you have:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134//--------------------------------------------////PRC_Master Pattern [LuxAlgo]//version = 0//17.07.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//--------------------------------------------//// --- inputs//--------------------------------------------//length=3 //contraction detection lookbackliqlength=20 //liquidity levelsshowliq=1//--------------------------------------------//// --- detect contraction//--------------------------------------------//newpivothi=high[length]=highest[length*2+1](high)newpivotlo=low[length]=lowest[length*2+1](low)if newpivothi thenph=high[length]if ph-phy > 0 thenpht=1elsif ph-phy < 0 thenpht=-1elsepht=0endifphy=phif pht=-1 and plt=1 thenitop=phbtm=plyphx=barindex[length]endifendifif newpivotlo thenpl=low[length]if pl-ply > 0 thenplt=1elsif pl-ply < 0 thenplt=-1elseplt=0endifply=plif pht=-1 and plt=1 thenitop=phybtm=plplx=barindex[length]endifendif//--------------------------------------------//// --- Detect master pattern//--------------------------------------------//isbull=high[length]>itop and itop>btmisbear=low[length]<btm and itop>btmif isbull or isbear thenprevval=valprevx2=boxx2val=(itop+btm)/2boxx1=max(phx,plx)boxx2=barindex[length]boxy1=itopboxy2=btmlinex1=barindex[length]linex2=barindexliney=valbreakup=isbullbreakdn=isbearitop=undefinedbtm=undefinedendifif breakup thendrawrectangle(boxx1,boxy1,boxx2,boxy2)coloured("green")fillcolor("green",30)drawsegment(linex1,prevval,prevx2,prevval)coloured("blue")style(dottedline)breakup=0endifif breakdn thendrawrectangle(boxx1,boxy1,boxx2,boxy2)coloured("red")fillcolor("red",30)drawsegment(linex1,prevval,prevx2,prevval)coloured("blue")style(dottedline)breakdn=0endif//--------------------------------------------//// --- Liquidity Levels//--------------------------------------------//newliqpivothi=high[liqlength]=highest[liqlength*2+1](high)newliqpivotlo=low[liqlength]=lowest[liqlength*2+1](low)if newliqpivothi and showliq thendrawsegment(liqplx,liqpl,liqplx2,liqpl)style(dottedline2)liqph=high[liqlength]liqphx=barindex[liqlength]liqphx2=barindexliqupreach=0elsif liqupreach=0 and showliq thenliqphx2=barindexif high>liqph thenliqupreach=1drawsegment(liqphx,liqph,liqphx2,liqph)style(dottedline2)endifendifif newliqpivotlo and showliq thendrawsegment(liqphx,liqph,liqphx2,liqph)style(dottedline2)liqpl=low[liqlength]liqplx=barindex[liqlength]liqplx2=barindexliqdnreach=0elsif liqdnreach=0 and showliq thenliqplx2=barindexif low<liqpl thenliqdnreach=1drawsegment(liqplx,liqpl,liqplx2,liqpl)style(dottedline2)endifendif//--------------------------------------------//// --- Draw last//--------------------------------------------//if islastbarupdate thendrawsegment(liqplx,liqpl,barindex,liqpl)style(dottedline2)drawsegment(liqphx,liqph,barindex,liqph)style(dottedline2)drawsegment(linex1,val,barindex,val)coloured("blue")style(dottedline)endif//--------------------------------------------//return07/17/2025 at 2:16 PM #248936 -
AuthorPosts
Find exclusive trading pro-tools on