Please Convert Master Pattern [LuxAlgo] to PROREALTIME
Forums › ProRealTime English forum › ProBuilder support › Please Convert Master Pattern [LuxAlgo] to PROREALTIME
- This topic has 11 replies, 5 voices, and was last updated 1 month ago by
JS.
-
-
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 #24893608/04/2025 at 11:53 PM #24935608/05/2025 at 11:15 AM #249364Did you add it ON the price chart (not below)?
08/05/2025 at 8:42 PM #249415yes, but the box is so faint, mainly because i have a FVG indicaot, in the background with the same colours, is ther any chance , we can add some variable to change the box colour and line colour so that we can see it according to the rest of the chart. Please?
08/06/2025 at 8:48 AM #249419Try hiding the other indicators.
Anyhow, you can use the colours at this link (by either their names or the RGB values) https://www.prorealcode.com/documentation/coloured/, replacing those used in the code with the instructions coloured and fillcolor.
The last parameter after the name of the colour, just before the closing paranthesis, is the optional transparency (sometimes called Alpha) which ranges from 0 to 255 and is the visibility gradient, 0=invisible, 255=max visibility. Try first increasing that value.
1 user thanked author for this post.
08/06/2025 at 9:17 AM #24942108/13/2025 at 12:08 AM #249688Thank Roberto , you are a real star. Is there a cahnce you can give me the code so that i can change colours (and transparency)of boxes and also to change the dotted line to full line or dashes and contraol thickness please . As there is a mess on my screens with colours and sometimes i cant tell if the box has appeared or not. Also can i set an alert as when a new box has occured? Your help is amzingly helpful , many thanks.
08/13/2025 at 5:57 PM #24970808/13/2025 at 6:06 PM #24971008/14/2025 at 3:21 AM #249714Hi,
In the code itself you can make the various adjustments…
Wherever “drawrectangle or drawsegment” is located, you can adjust the color and style…
For example, the first drawrectangle is in line 82:
drawrectangle(boxx1,boxy1,boxx2,boxy2)coloured(“green”)fillcolor(“green”,30)
You can change the color here, for example from green to yellow…
drawrectangle(boxx1,boxy1,boxx2,boxy2)coloured(“yellow”)fillcolor(“yellow”,30)
Next example in line 83:
drawsegment(linex1,prevval,prevx2,prevval)coloured(“blue”)style(dottedline)
You can change the color and style here, for example from blue to red…
drawsegment(linex1,prevval,prevx2,prevval)coloured(“red”)style(dottedline)
You can also change the style from a dotted line to a solid line, for example…
drawsegment(linex1,prevval,prevx2,prevval)coloured(“red”)style(line)
You can also modify lines 88, 89, 99, 108, 113, 122, 129, 130 and 131…
2 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on