Request for Recoding Pine Script to RealCode – Market Profile
Forums › ProRealTime English forum › ProBuilder support › Request for Recoding Pine Script to RealCode – Market Profile
- This topic has 0 replies, 1 voice, and was last updated 2 years ago by scoot3r83.
Viewing 1 post (of 1 total)
-
-
01/06/2022 at 1:06 PM #184751
Hi I was wondering if Nicolas, Xel or anyone with more Pine Script experience than myself would be able to recode this into PRT code.
Market Profile - Basic123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © LonesomeTheBlue//@version=4study("Market Profile", "MP/TPO", overlay = true, max_lines_count = 500, max_bars_back = 1000)TimeframeU = input(defval = 'Auto', title ="Higher Time Frame", options = ['Auto', '1', '5', '10', '15', '30', '60', '120', '180', '240', '360', '480', '720', 'D', 'W', '2W', 'M', '3M', '6M', '12M'])percent = input(70.0, title="Percent for Value Area %", type = input.float, minval = 1, maxval = 100) / 100showpocline = input(true, title="Show POC Line")keepoldmp = input(true, title="Keep Old MPs")showwhat = input(defval = "Show All Channels", title="Show", options = ["Don't Show Value Area", "Show Value Area High", "Show All Channels"])linewdth = input(defval = 2, title = "Line Width", minval = 1, maxval = 4)srate = input(defval = 100., title = "Sizing Rate %", minval = 10, maxval = 500) / 100poc_col = input(defval = color.yellow, title = "POC Line Color", type = input.color)vah_col = input(defval = color.blue, title = "Value Area Color", type = input.color)nonva_col = input(defval = color.gray, title = "Non-Value Area Color", type = input.color)Timeframe = timeframe.periodif TimeframeU == 'Auto'Timeframe := timeframe.period == '1' ? '120' :timeframe.period == '2' ? '180' :timeframe.period == '3' ? '240' :timeframe.period == '5' ? 'D' :timeframe.period == '10' ? 'W' :timeframe.period == '15' ? 'W' :timeframe.period == '30' ? 'W' :timeframe.period == '45' ? 'W' :timeframe.period == '60' ? 'W' :timeframe.period == '120' ? 'M' :timeframe.period == '180' ? 'M' :timeframe.period == '240' ? 'M' :timeframe.period == 'D' ? '12M' :timeframe.period == 'W' ? '12M' :'D'elseTimeframe := TimeframeUvar float highesthtf = navar float lowesthtf = navar float highest = highvar float lowest = lowvar int barnum = 0var int len = 0bool newbar = change(time(Timeframe)) != 0if newbar // new bar in htfhighesthtf := highlowesthtf := lowbarnum := 0elsehighesthtf := max(highesthtf, high)lowesthtf := min(lowesthtf, low)barnum := barnum + 1if newbar // new bar in htfhighest := highesthtf[1]lowest := lowesthtf[1]len := barnum[1]float channel = (highest - lowest) / 20included(t1, t2, t3, t4)=>_ret = t3 >= t1 and t3 <= t2 or t4 >= t1 and t4 <= t2 or t3 <= t1 and t4 >= t2get_tpo(lower, upper)=>float ret = 0.for x = 1 to lenif included(lower, upper, low[x], high[x])ret := ret + 1retch = array.new_float(22, 0.)if newbarfor x = 1 to 20array.set(ch, x, get_tpo(lowest + (x - 1) * channel, lowest + x * channel))get_index(up, down)=>float upval = array.get(ch, up)float downval = array.get(ch, down)[iff(upval >= downval, up, down), max(upval, downval)]float total = 0.int poc_loc = 0float poc_val = 0.var int gl_poc_loc = 0if newbarfor x = 1 to 20cval = array.get(ch, x)total := total + cvalif cval >= poc_valpoc_val := cvalpoc_loc := xgl_poc_loc := poc_locfloat va_val = poc_valint vahind = poc_locint valind = poc_locif newbarfor x = 1 to 20if va_val >= total * percentbreak[ind, chval] = get_index(vahind + 1, valind - 1)if chval == 0breakif ind == vahind + 1vahind := indva_val := va_val + chvalelsevalind := indva_val := va_val + chvalget_middle(x)=>float ret = (lowest + (x-1) * channel + lowest + x * channel) / 2get_base(x)=>float ret = (lowest + (x-1) * channel)var int bartime = nabartime := na(bartime) ? time - time[1] : min(bartime, time - time[1])draw_mp(y, chval, is_va)=>rchval = round(srate * chval)linecol = is_va ? vah_col : nonva_colret = line.new(x1 = bar_index, y1 = y, x2 = bar_index + rchval, y2 = y, color = linecol, width = linewdth)draw_mpd(y1_, y2_, chval, is_va)=>rchval = round(srate * chval)linecol = is_va ? vah_col : nonva_colret = line.new(x1 = bar_index + rchval, y1 = y1_, x2 = bar_index + rchval, y2 = y2_, color = linecol, width = linewdth)var float midpoc = navar all_lines = array.new_line(0)if newbarif keepoldmp and array.size(all_lines) > 0line.set_x2(array.get(all_lines, array.size(all_lines) - 1), bar_index - 1)line.set_extend(array.get(all_lines, array.size(all_lines) - 1), extend = extend.none)array.clear(all_lines)if not keepoldmpfor x = 0 to (array.size(all_lines) > 0 ? array.size(all_lines) - 1 : na)line.delete(array.pop(all_lines))if showwhat == "Show Value Area High" or showwhat == "Show All Channels"str = showwhat == "Show All Channels" ? 1 : valindend = showwhat == "Show All Channels" ? 20 : vahindfor x = str to endis_va = x >= valind and x <= vahindis_poc = x == poc_locint lwdhm = int(array.get(ch, x))int lwdh = lwdhmif x > strint mytmp = int(array.get(ch, x - 1))if mytmp > lwdhlwdh := mytmpis_va := x - 1 >= valind and x - 1<= vahindarray.push(all_lines, draw_mp(get_base(x), lwdh, is_va))is_va := x >= valind and x <= vahindarray.push(all_lines, draw_mpd(get_base(x), get_base(x + 1), lwdhm, is_va))array.push(all_lines, draw_mp(get_base(end + 1), int(array.get(ch, end)), end >= valind and end <= vahind))if showpoclinemidpoc := get_middle(poc_loc)array.push(all_lines, line.new(x1 = bar_index, y1 = midpoc, x2 = bar_index + 1, y2 = get_middle(poc_loc), color = poc_col, width = linewdth, extend = extend.right))price_in_poc = close >= get_base(gl_poc_loc + 0) and close <= get_base(gl_poc_loc + 1)price_above_poc = close > get_base(gl_poc_loc + 1)price_below_poc = close <= get_base(gl_poc_loc + 0)alertcondition(price_in_poc , title='Price in POC', message='Price in POC')alertcondition((price_in_poc[1] or price_below_poc[1]) and price_above_poc, title='Price went above POC', message='Price went above POC')alertcondition((price_in_poc[1] or price_above_poc[1]) and price_below_poc, title='Price went below POC', message='Price went below POC') -
AuthorPosts
Viewing 1 post (of 1 total)