Renko PRT Renko PRC
Forums › ProRealTime English forum › ProBuilder support › Renko PRT Renko PRC
- This topic has 9 replies, 2 voices, and was last updated 2 years ago by Nicolas.
Tagged: renko
-
-
01/28/2022 at 10:47 AM #186812
Hello everyone,
I’m trying to replicate the same Renko as PRT. I chose Boxsize 100 on Dow H1 and used the code provided by Nicolas here https://www.prorealcode.com/prorealtime-indicators/renko-boxes-on-price-chart/
However, the values are sometimes identical and sometimes different. I’d like to have the exact same values than PRT. Can someone please help?
Thanks
01/28/2022 at 11:51 AM #186824I think your problem come that the price can “jump” 2 or more renko bars size during 1 code read, and you can only paint 1 bar on a single period. That’s tricky to code, I know this product from the marketplace replicate the same exact values with quantity of boxes, on a classic chart: https://market.prorealcode.com/product/prt-renko/
1 user thanked author for this post.
01/28/2022 at 1:55 PM #186839After searching a bit, I found this free code on TradingView (Pine). It’s way beyond my conversion skills. If someone is interested to convert it.
//@version=4
study(“Renko”, max_bars_back = 5000)
get_renko(box_size) =>
var float base_price = input(title=”Base price”, type=input.source, defval=close)
var float r_open = base_price – box_size
var float r_close = close
var int up_list = 0
var int down_list = 0
var int up_move = 0
var int down_move = 0
var int built_bricks_up = 0
var int built_bricks_down = 0
var int counter_up_series = 0
var int counter_down_series = 0
var int required_series_up = 0
var int required_series_down = 0
var int required_bricks_up = 0
var int required_bricks_down = 0
var bool b_up_list = false
var bool b_down_list = false
var bool b_up_move = false
var bool b_down_move = false
var bool in_the_range_up = false
var bool in_the_range_down = false
var int up_stop_index = 0
var int down_stop_index = 0
var int up_temporary_index = 0
var int down_temporary_index = 0
// creating lists
if bar_index > 0
if close > open
down_move := 0
if b_up_list
up_move := int((close – base_price) / box_size)
if up_move > up_list
up_list := up_move
down_list := na
else if b_down_list
up_move := int((close – (base_price – down_list * box_size)) / box_size)
else
down_list := na
up_list := na
else if close < open
up_move := 0
if b_down_list
down_move := int((base_price – close) / box_size)
if down_move > down_list
down_list := down_move
up_list := na
else if b_up_list
down_move := int(((base_price + up_list * box_size) – close) / box_size)
else
down_list := na
up_list := na
if b_up_list and down_move >= 2
base_price := base_price + (up_list – 1) * box_size
b_up_list := false
up_list := na
b_down_list := true
down_list := down_move – 1else if b_down_list and up_move >= 2
base_price := base_price – (down_list – 1) * box_size
b_down_list := false
down_list := na
b_up_list := true
up_list := up_move – 1if not b_up_list and not b_down_list
up_move := int((close – base_price) / box_size)
down_move := int((base_price – close) / box_size)
if up_move > 0
down_move := 0
b_up_list := true
b_up_move := true
up_list := up_move
down_list := na
else if down_move > 0
up_move := 0
b_down_list := true
b_down_move := true
down_list := down_move
up_list := na
else
up_list := na
down_list := na
r_close := na
// creating open and close series
if b_up_move
for i = 0 to bar_index – up_stop_index – 1
if not na(up_list[i]) and na(up_list[i+1])
counter_up_series := counter_up_series + 1
required_bricks_up := up_list[i]
if i == bar_index – up_stop_index – 1
for j = i to 0
up_temporary_index := bar_index[j]
required_bricks_up := up_list[j]
if j == 0
break
if not na(up_list[j]) and na(up_list[j-1])
up_temporary_index := bar_index[j-1]
break
break
if counter_up_series == 1 and not na(up_list[0])
in_the_range_up := true
counter_up_series := 0
if built_bricks_up < required_bricks_up
r_open := r_open + box_size
r_close := r_open + box_size
built_bricks_up := built_bricks_up + 1else if in_the_range_up and built_bricks_up == required_bricks_up
r_close := na
else
up_stop_index := up_temporary_index
built_bricks_up := 0
built_bricks_down := 1
b_up_move := false
b_down_move := true
r_close := r_open – box_sizein_the_range_up := false
else if b_down_move
for i = 0 to bar_index – down_stop_index – 1
if not na(down_list[i]) and na(down_list[i+1])
counter_down_series := counter_down_series + 1
required_bricks_down := down_list[i]
if i == bar_index – down_stop_index – 1
for j = i to 0
down_temporary_index := bar_index[j]
required_bricks_down := down_list[j]
if j == 0
break
if not na(down_list[j]) and na(down_list[j-1])
down_temporary_index := bar_index[j-1]
break
break
if counter_down_series == 1 and not na(down_list[0])
in_the_range_down := true
counter_down_series := 0
if built_bricks_down < required_bricks_down
if up_stop_index == 0 and down_stop_index == 0 and built_bricks_down == 0
r_open := r_open + box_size
r_close := r_open – box_size
built_bricks_down := built_bricks_down + 1
else
r_open := r_open – box_size
r_close := r_open – box_size
built_bricks_down := built_bricks_down + 1
else if in_the_range_down and built_bricks_down == required_bricks_down
r_close := na
else
down_stop_index := down_temporary_index
built_bricks_down := 0
built_bricks_up := 1
b_down_move := false
b_up_move := true
r_close := r_open + box_size
in_the_range_down := false
else
r_close := na
[r_open, r_open > r_close ? r_open : r_close, r_open < r_close ? r_open : r_close, r_close]
[r_open, r_high, r_low, r_close] = get_renko(input(defval = 200.0, title = “Box size”, type = input.float, minval = 0.00000001))
plotcandle(r_open, r_high, r_low, r_close, color = r_close > r_open ? color.green : color.red)01/28/2022 at 5:23 PM #186865I tried my best to convert the above code. I’m stuck in the loops where I think I didn’t place the “endif” in the appropriate location.
I need a bit of help PLEEEEEEEAAAASE!
Thanks a million!
Conversion Renko attempt123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191DEFPARAM CALCULATEONLASTBARS = 1000boxsize = 100Baseprice = closeropen = baseprice - boxsizerclose = closeuplist = 0downlist = 0upmove = 0downmove = 0builtbricksup = 0builtbricksdown = 0counterupseries = 0counterdownseries = 0requiredseriesup = 0requiredseriesdown = 0requiredbricksup = 0requiredbricksdown = 0boolbupist = 0boolbdownlist = 0boolbupmove = 0boolbdownmove = 0boolintherangeup = 0boolintherangedown = 0intupstopindex = 0intdownstopindex = 0intuptemporaryindex = 0intdowntemporaryindex = 0if barindex>0 thenif close > open thendownmove = 0if buplist >0 thenupmove = abs((close - baseprice) / boxsize)if upmove > uplist thenuplist = upmovedownlist = 0elsif bdownlist >0 thenupmove = abs((close - (baseprice - downlist * boxsize)) / boxsize)elsedownlist = 0uplist = 0endifelsif close < open thenupmove = 0if bdownlist > 0 thendownmove = abs((baseprice - close) / boxsize)if downmove > downlist thendownlist = downmoveuplist = 0elsif buplist>0 thendownmove = abs(((baseprice + uplist * boxsize) - close) / boxsize)elsedownlist = 0uplist = 0if buplist and downmove >= 2 thenbaseprice = baseprice + (uplist - 1) * boxsizebuplist = 0uplist = 0bdownlist = 1downlist = downmove - 1elsif bdownlist=1 and upmove >= 2 thenbaseprice = baseprice - (downlist - 1) * boxsizebdownlist = 0downlist = 0buplist = 1uplist = upmove - 1if not buplist and not bdownlist thenupmove = abs((close - baseprice) / boxsize)downmove = abs((baseprice - close) / boxsize)if upmove > 0 thendownmove = 0buplist = 1bupmove = 1uplist = upmovedownlist = 1elsif downmove > 0 thenupmove = 0bdownlist = 1bdownmove = 1downlist = downmoveuplist = 0elseuplist = 0downlist = 0rclose = 0endifendifendifendifendifendifendifendif// creating open and close seriesif barindex>0 thenif bupmove = 1 thenif (uplist[i])<>0 and (uplist[i+1])<>0 thenfor i = 0 to barindex - upstopindex - 1counterupseries = counterupseries + 1requiredbricksup = uplist[i]breakif i = barindex - upstopindex - 1 thenfor j = i to 0uptemporaryindex = barindex[j]requiredbricksup = uplist[j]if j = 0 thenbreakelsif (uplist[j])<>0 and (uplist[j-1])<>0 thenuptemporaryindex = barindex[j-1]//breakendif//breakif counterupseries = 1 and (uplist[0])<>0 thenintherangeup = 1counterupseries = 0if builtbricksup < requiredbricksup thenropen = ropen + boxsizerclose = ropen + boxsizebuiltbricksup = builtbricksup + 1elsif intherangeup and builtbricksup = requiredbricksup thenrclose = 0endifelseupstopindex = uptemporaryindexbuiltbricksup = 0builtbricksdown = 1bupmove = 0bdownmove = 1rclose = ropen - boxsizeintherangeup = 0endifif bdownmove=1 thenfor i = 0 to barindex - downstopindex - 1if (downlist[i])<>0 and (downlist[i+1])<>0 thencounterdownseries = counterdownseries + 1requiredbricksdown = downlist[i]if i = barindex - downstopindex - 1 thenfor j = i to 0downtemporaryindex = barindex[j]requiredbricksdown = downlist[j]if j = 0 thenbreakif (downlist[j])<>0 and (downlist[j-1])<>0 thendowntemporaryindex = barindex[j-1]//break//breakif counterdownseries = 1 and (downlist[0])<>0 thenintherangedown = 1counterdownseries = 0if builtbricksdown < requiredbricksdown thenif upstopindex = 0 and downstopindex = 0 and builtbricksdown = 0 thenropen = ropen + boxsizerclose = ropen - boxsizebuiltbricksdown = builtbricksdown + 1elseropen = ropen - boxsizerclose = ropen - boxsizebuiltbricksdown = builtbricksdown + 1endifelsif intherangedown and builtbricksdown = requiredbricksdown thenrclose = 0elsedownstopindex = downtemporaryindexbuiltbricksdown = 0builtbricksup = 1bdownmove = 0bupmove = 1rclose = ropen + boxsizeintherangedown = 0endifelse//rclose = na//endifendifendifendifDRAWCANDLE(ropen, high, low, rclose)coloured(0,0,255)RETURN01/28/2022 at 6:18 PM #186870The best I could with my limited coding skills. Except a few exceptions, all the open and close match the PRT Renko. Can you please Nicolas have a look if it’s correct and why I have gaps between certain Renko candles?
Renko123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214DEFPARAM CALCULATEONLASTBARS = 1000boxsize = 50Baseprice = closeropen = baseprice - boxsizerclose = closeuplist = 0downlist = 0upmove = 0downmove = 0builtbricksup = 0builtbricksdown = 0counterupseries = 0counterdownseries = 0requiredseriesup = 0requiredseriesdown = 0requiredbricksup = 0requiredbricksdown = 0boolbupist = 0boolbdownlist = 0boolbupmove = 0boolbdownmove = 0boolintherangeup = 0boolintherangedown = 0intupstopindex = 0intdownstopindex = 0intuptemporaryindex = 0intdowntemporaryindex = 0if barindex>0 thenif close > open thendownmove = 0if buplist >0 thenupmove = abs((close - baseprice) / boxsize)if upmove > uplist thenuplist = upmovedownlist = 0elsif bdownlist >0 thenupmove = abs((close - (baseprice - downlist * boxsize)) / boxsize)elsedownlist = 0uplist = 0endifelsif close < open thenupmove = 0endifif bdownlist > 0 thendownmove = abs((baseprice - close) / boxsize)if downmove > downlist thendownlist = downmoveuplist = 0elsif buplist>0 thendownmove = abs(((baseprice + uplist * boxsize) - close) / boxsize)elsedownlist = 0uplist = 0if buplist and downmove >= 2 thenbaseprice = baseprice + (uplist - 1) * boxsizebuplist = 0uplist = 0bdownlist = 1downlist = downmove - 1elsif bdownlist=1 and upmove >= 2 thenbaseprice = baseprice - (downlist - 1) * boxsizebdownlist = 0downlist = 0buplist = 1uplist = upmove - 1if not buplist and not bdownlist thenupmove = abs((close - baseprice) / boxsize)downmove = abs((baseprice - close) / boxsize)if upmove > 0 thendownmove = 0buplist = 1bupmove = 1uplist = upmovedownlist = 1elsif downmove > 0 thenupmove = 0bdownlist = 1bdownmove = 1downlist = downmoveuplist = 0elseuplist = 0downlist = 0rclose = 0endifendifendifendifendifendifendif// creating open and close seriesif barindex>0 thenif bupmove = 1 thenif (uplist[i])<>0 and (uplist[i+1])<>0 thenfor i = 0 to barindex - upstopindex - 1counterupseries = counterupseries + 1requiredbricksup = uplist[i]//breaknextif i = barindex - upstopindex - 1 thenfor j = i to 0uptemporaryindex = barindex[j]requiredbricksup = uplist[j]nextif j = 0 thenbreakendifelsif (uplist[j])<>0 and (uplist[j-1])<>0 thenuptemporaryindex = barindex[j-1]//breakendif//breakif counterupseries = 1 and (uplist[0])<>0 thenintherangeup = 1counterupseries = 0if builtbricksup < requiredbricksup thenropen = ropen + boxsizerclose = ropen + boxsizebuiltbricksup = builtbricksup + 1elsif intherangeup and builtbricksup = requiredbricksup thenrclose = 0endifelseupstopindex = uptemporaryindexbuiltbricksup = 0builtbricksdown = 1bupmove = 0bdownmove = 1rclose = ropen - boxsizeintherangeup = 0endifendifendifif bdownmove=1 thenfor i = 0 to barindex - downstopindex - 1if (downlist[i])<>0 and (downlist[i+1])<>0 thencounterdownseries = counterdownseries + 1requiredbricksdown = downlist[i]if i = barindex - downstopindex - 1 thenfor j = i to 0downtemporaryindex = barindex[j]requiredbricksdown = downlist[j]if j = 0 thenendifnext //breakendifendifnextif (downlist[j])<>0 and (downlist[j-1])<>0 thendowntemporaryindex = barindex[j-1]//break//breakif counterdownseries = 1 and (downlist[0])<>0 thenintherangedown = 1counterdownseries = 0if builtbricksdown < requiredbricksdown thenif upstopindex = 0 and downstopindex = 0 and builtbricksdown = 0 thenropen = ropen + boxsizerclose = ropen - boxsizebuiltbricksdown = builtbricksdown + 1elseropen = ropen - boxsizerclose = ropen - boxsizebuiltbricksdown = builtbricksdown + 1endifelsif intherangedown and builtbricksdown = requiredbricksdown thenrclose = 0elsedownstopindex = downtemporaryindexbuiltbricksdown = 0builtbricksup = 1bdownmove = 0bupmove = 1rclose = ropen + boxsizeintherangedown = 0endifelse//rclose = na//endifendifendifendifendifif rclose>=rclose[1] thenDRAWCANDLE(ropen, high, low, rclose)coloured(0,255,0)endifif rclose<rclose[1] thenDRAWCANDLE(ropen, high, low, rclose)coloured(255,0,0)endifRETURN01/28/2022 at 7:45 PM #186877Sorry if I’m posting too much. I hope you can review this very last version, which seems to replicate exactly the PRT Renko, with no gaps between boxes.
the graph in blue is the version with %, changing boxsize from 50pts to “close*.1/100”
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209DEFPARAM CALCULATEONLASTBARS = 500boxsize = 50Baseprice = closeropen = baseprice - boxsizerclose = closeuplist = 0downlist = 0upmove = 0downmove = 0builtbricksup = 0builtbricksdown = 0counterupseries = 0counterdownseries = 0requiredseriesup = 0requiredseriesdown = 0requiredbricksup = 0requiredbricksdown = 0boolbupist = 0boolbdownlist = 0boolbupmove = 0boolbdownmove = 0boolintherangeup = 0boolintherangedown = 0intupstopindex = 0intdownstopindex = 0intuptemporaryindex = 0intdowntemporaryindex = 0if barindex>0 thenif close > open thendownmove = 0if buplist >0 thenupmove = abs((close - baseprice) / boxsize)if upmove > uplist thenuplist = upmovedownlist = 0elsif bdownlist >0 thenupmove = abs((close - (baseprice - downlist * boxsize)) / boxsize)elsedownlist = 0uplist = 0endifelsif close < open thenupmove = 0endifif bdownlist > 0 thendownmove = abs((baseprice - close) / boxsize)if downmove > downlist thendownlist = downmoveuplist = 0elsif buplist>0 thendownmove = abs(((baseprice + uplist * boxsize) - close) / boxsize)elsedownlist = 0uplist = 0if buplist and downmove >= 2 thenbaseprice = baseprice + (uplist - 1) * boxsizebuplist = 0uplist = 0bdownlist = 1downlist = downmove - 1elsif bdownlist=1 and upmove >= 2 thenbaseprice = baseprice - (downlist - 1) * boxsizebdownlist = 0downlist = 0buplist = 1uplist = upmove - 1if not buplist and not bdownlist thenupmove = abs((close - baseprice) / boxsize)downmove = abs((baseprice - close) / boxsize)if upmove > 0 thendownmove = 0buplist = 1bupmove = 1uplist = upmovedownlist = 1elsif downmove > 0 thenupmove = 0bdownlist = 1bdownmove = 1downlist = downmoveuplist = 0elseuplist = 0downlist = 0rclose = 0endifendifendifendifendifendifendif// creating open and close seriesif barindex>0 thenif bupmove = 1 thenif (uplist[i])<>0 and (uplist[i+1])<>0 thenfor i = 0 to barindex - upstopindex - 1counterupseries = counterupseries + 1requiredbricksup = uplist[i]//breaknextif i = barindex - upstopindex - 1 thenfor j = i to 0uptemporaryindex = barindex[j]requiredbricksup = uplist[j]nextif j = 0 thenbreakendifelsif (uplist[j])<>0 and (uplist[j-1])<>0 thenuptemporaryindex = barindex[j-1]//breakendif//breakif counterupseries = 1 and (uplist[0])<>0 thenintherangeup = 1counterupseries = 0if builtbricksup < requiredbricksup thenropen = ropen + boxsizerclose = ropen + boxsizebuiltbricksup = builtbricksup + 1elsif intherangeup and builtbricksup = requiredbricksup thenrclose = 0endifelseupstopindex = uptemporaryindexbuiltbricksup = 0builtbricksdown = 1bupmove = 0bdownmove = 1rclose = ropen - boxsizeintherangeup = 0endifendifendifif bdownmove=1 thenfor i = 0 to barindex - downstopindex - 1if (downlist[i])<>0 and (downlist[i+1])<>0 thencounterdownseries = counterdownseries + 1requiredbricksdown = downlist[i]if i = barindex - downstopindex - 1 thenfor j = i to 0downtemporaryindex = barindex[j]requiredbricksdown = downlist[j]if j = 0 thenendifnext //breakendifendifnextif (downlist[j])<>0 and (downlist[j-1])<>0 thendowntemporaryindex = barindex[j-1]//break//breakif counterdownseries = 1 and (downlist[0])<>0 thenintherangedown = 1counterdownseries = 0if builtbricksdown < requiredbricksdown thenif upstopindex = 0 and downstopindex = 0 and builtbricksdown = 0 thenropen = ropen + boxsizerclose = ropen - boxsizebuiltbricksdown = builtbricksdown + 1elseropen = ropen - boxsizerclose = ropen - boxsizebuiltbricksdown = builtbricksdown + 1endifelsif intherangedown and builtbricksdown = requiredbricksdown thenrclose = 0elsedownstopindex = downtemporaryindexbuiltbricksdown = 0builtbricksup = 1bdownmove = 0bupmove = 1rclose = ropen + boxsizeintherangedown = 0endifelse//rclose = na//endifendifendifendifendifif rclose>=rclose[1] and ropen>ropen[1] thenDRAWCANDLE(ropen, high, low, rclose)coloured(0,255,0)endifif rclose<rclose[1] and ropen<ropen[1] thenDRAWCANDLE(high, high, low, rclose)coloured(255,0,0)endifRETURN02/02/2022 at 11:28 AM #18732202/02/2022 at 11:37 AM #18732402/02/2022 at 12:13 PM #187327Indeed. Just wanted to use this code in a strategy as Exit when the Renko changes color. As you know the PRT native Renko cannot be added in ProOrder. So, if you can please check if this code is consistent with PRT native Renko. Many Thanks
02/02/2022 at 12:58 PM #187338 -
AuthorPosts
Find exclusive trading pro-tools on