Conversion d’un code pour PRT
Forums › ProRealTime forum Français › Support ProBuilder › Conversion d’un code pour PRT
- This topic has 4 replies, 2 voices, and was last updated 2 days ago by
Manu L..
Viewing 5 posts - 1 through 5 (of 5 total)
-
-
06/10/2025 at 9:34 PM #248166
Bonjour à tous,
serait-il possible de transposer ce code Traving View en code PRT ?
Merci d’avance
indicator(“Dynamic Support/Resistance Zones [ChartPrime]”, overlay = true, max_labels_count = 500, max_boxes_count = 500, max_lines_count = 500, max_bars_back = 4000)sq(float source) => math.pow(source, 2)sinc(float source, float bandwidth) =>if source == 01elsemath.sin(math.pi * source / bandwidth) / (math.pi * source / bandwidth)sinc_filter(float[] source, float length)=>if length > 0 and source.size() > 0src_size = array.size(source)estimate_array=array.new<float>(src_size)float current_price = nafori=0tosrc_size-1float sum = 0float sumw = 0forj=0tosrc_size-1diff = i – jweight = sinc(diff, length + 1)sum += array.get(source, j) * weightsumw += weightcurrent_price := sum / sumwarray.set(estimate_array, i, current_price >= 0 ? current_price : 0)estimate_arrayelsesourcepeak_detection(source, int scale, float real_minimum, bool enable) =>peak_idx = array.new<float>()i = -1if enable and source.size() > 0max = source.max() – real_minimumwhile i < array.size(source) – 1i += 1center = int((source.get(i) – real_minimum) / max * (scale – 1) + 1)previous = i > 0 ? int((source.get(i – 1) – real_minimum) / max * (scale – 1) + 1) : 0next = i < array.size(source) – 1 ? int((source.get(i + 1) – real_minimum) / max * (scale – 1) + 1) : 0if center > previousj = i + 1if center == nextwhile j <= array.size(source) – 1j += 1vary_previous = int((source.get(j – 1) – real_minimum) / max * (scale – 1) + 1)very_next = j <= source.size() – 1 ? int((source.get(j) – real_minimum) / max * (scale – 1) + 1) : 0if very_next != vary_previousif center > very_nextp_idx = int((i + j) / 2.0)peak_idx.push((j – i) > 2 and (j – i) % 2 != 0 ? p_idx : p_idx – 0.5)i:=jelsei := j – 1breakif center > nextpeak_idx.push(i)peak_idxmethod add_to_score(float[] self, float[] source, float[] weight, string weight_style, float min_range, float bin_size, int precision)=>if source.size() > 0for i = 0 to source.size() – 1w = weight.get(i)W = weight_style == “Time” ? 1 + (bar_index – weight.min()) – (bar_index – w) : widx = math.min(math.floor((source.get(i) – min_range) / bin_size), precision – 1)self.set(idx, self.get(idx) + W)ma(float[] scores, float min_range, float bin_size, bool enable)=>float ma = naif enableweight = 0.sum = 0.if scores.max() > 0for i = 0 to scores.size() – 1score = scores.get(i)if score == 0continuebin_top = min_range + bin_size * (i + 1)bin_bottom = min_range + bin_size * iprice = math.avg(bin_top, bin_bottom)weight += scoresum += price * scorema := sum / weightmamethod hit(label[] self, float level, int lookback, float atr, color bear_bounce, color bull_bounce)=>for i = 0 to lookback – 1h = high[i]l = low[i]candle_range = h – lp_level = level – lpercent = p_level / candle_rangeif percent <= 1 and percent >= 0o = open[i]c = close[i]c_next = close[math.max(i – 1, 0)]polarity = c > obody_top = math.max(o, c)body_bottom = math.min(o, c)top_wick_range = h – body_toptw_level = level – body_toptw_percent = tw_level / top_wick_rangebottom_wick_range = body_bottom – lbw_percent = p_level / bottom_wick_rangetop_wick_portion = top_wick_range / candle_rangebottom_wick_portion = bottom_wick_range / candle_rangetop_wick_bounce = (tw_percent <= 1 and tw_percent >= 0 and tw_percent >= 0.5) or (top_wick_portion <= 0.25 and level < h and level > body_top) or (candle_range <= atr * 2 and level <= h and level >= body_top)bottom_wick_bounce = (bw_percent <= 1 and bw_percent >= 0 and bw_percent <= 0.5) or (bottom_wick_portion <= 0.25 and level > l and level < body_bottom) or (candle_range <= atr * 2 and level <= body_bottom and level >= l)bear_condition = o < level and c_next < levelbull_condition = o > level and c_next > levelcandle_bear_bounce = polarity and percent >= 0.7candle_bull_bounce = not polarity and percent <= 0.3if (top_wick_bounce or candle_bear_bounce) and bear_conditionself.push(label.new(bar_index – i, h, “⬤”, xloc.bar_index, yloc.price, color.new(color.black, 100), label.style_label_down, bear_bounce))continueif (bottom_wick_bounce or candle_bull_bounce) and bull_conditionself.push(label.new(bar_index – i, l, “⬤”, xloc.bar_index, yloc.price, color.new(color.black, 100), label.style_label_up, bull_bounce))continueelsecontinueweight_style = input.string(“Linear”, “Weighting”, [“Linear”, “Time”, “Volume”], group = “Settings”, tooltip =” Linear: Each pivot in is treated equally.\nTime: Newer pivots will have a greater impact.\nVolume: Each pivot will be scored based on its volume.”)pivot_lookback = input.int(50, “Number of Pivots”, minval = 1, group = “Settings”, tooltip = “The number of pivots to take into account. Pivot high and low are treated separately so you will have that number of each.”)filter = input.float(3, “Filtering”, minval = 0, maxval = 12, group = “Settings”, tooltip = “When this is greater than 0 it will smooth the distribution of pivots. This can provide a smoother picture at the price of accuracy.”)precision = input.int(75, “Manual Precision”, minval = 3, inline = “Precision”, group = “Settings”, tooltip = “Use this to manually set the number of divisions of the range.”)auto_precision = not input.bool(true, “”, inline = “Precision”, group = “Settings”, tooltip = “Use the average range of a candle to divide the range with a minimum of 10.”)real_time_only = input.bool(false, “Calculate on Real Time Only”, group = “Settings”)length_1 = input.int(5, “Length 1”, minval = 1, inline = “Length_1”, group = “Pivots”)include_5 = input.bool(true, “”, inline = “Length_1”, group = “Pivots”)length_2 = input.int(10, “Length 2”, minval = 2, inline = “Length_2”, group = “Pivots”)include_10 = input.bool(true, “”, inline = “Length_2”, group = “Pivots”)length_3 = input.int(20, “Length 3”, minval = 3, inline = “Length_3”, group = “Pivots”)include_20 = input.bool(true, “”, inline = “Length_3”, group = “Pivots”)length_4 = input.int(50, “Length 4”, minval = 4, inline = “Length_4”, group = “Pivots”)include_50 = input.bool(true, “”, inline = “Length_4”, group = “Pivots”)include_ph = input.bool(true, “Include Pivot High”, group = “Pivots”)include_pl = input.bool(true, “Include Pivot Low”, group = “Pivots”)show_lines = input.bool(true, “Show Support/Resistance”, group = “Support/Resistance”)show_hits = input.bool(true, “Show Bounces”, inline = “Bounce”, group = “Support/Resistance”)hit_lookback = input.int(100, “”, minval = 1, inline = “Bounce”, group = “Support/Resistance”)show_zone = input.bool(false, “Show S/R Zone”, inline = “Zone”, group = “Support/Resistance”)zone_alpha = input.int(88, “”, minval = 0, maxval = 100, inline = “Zone”, group = “Support/Resistance”)support_color = input.color(#00FF00, “Support Color”, group = “Support/Resistance”)resistance_color = input.color(#FF0000, “Resistance Color”, group = “Support/Resistance”)show_dist = input.bool(true, “Show Distribution”, group = “Distribution”)show_score = input.bool(true, “Show Score in Distribution”, group = “Distribution”)scale = input.int(30, “Distribution Scale”, minval = 5, group = “Distribution”, tooltip = “This scales the distribution’s size on the screen. It also impacts the precision of the calculations.”)heat_map = input.bool(true, “Show Distribution Overlay”, inline = “MAP”, group = “Distribution”)heat_alpha = input.int(85, “”, minval = 0, maxval = 100, inline = “MAP”, group = “Distribution”)high_color=input.color(#00FFFF,”High Color”,group=”Distribution”)low_color = input.color(#FF00FF, “Low Color”, group = “Distribution”)txt_color = input.color(#111111, “Text Color”, group = “Distribution”)enable_ma = input.bool(false, “Pivot Level Average”, inline = “MA”, group = “Moving Average”, tooltip = “Show an average price weighted by the pivot points.”)ma_smoothing = input.int(12, “”, minval = 0, maxval = 200, inline = “MA”, group = “Moving Average”) + 1ma_color = input.color(#5536e4, “MA Color”, group = “Moving Average”)var pivot_high = array.new<float>()var pivot_high_weight = array.new<float>()var pivot_low = array.new<float>()var pivot_low_weight = array.new<float>()ph_5 = ta.pivothigh(high, length_1, length_1)ph_10 = ta.pivothigh(high, length_2, length_2)ph_20 = ta.pivothigh(high, length_3, length_3)ph_50 = ta.pivothigh(high, length_4, length_4)pl_5 = ta.pivotlow(low, length_1, length_1)pl_10 = ta.pivotlow(low, length_2, length_2)pl_20 = ta.pivotlow(low, length_3, length_3)pl_50 = ta.pivotlow(low, length_4, length_4)if not na(ph_5) and include_5w = switch weight_style“Linear” => 1“Time” => bar_index – length_1“Volume” => volume[length_1]pivot_high.push(ph_5)pivot_high_weight.push(w)if not na(ph_10) and include_10w = switch weight_style“Linear” => 1“Time” => bar_index – length_2“Volume” => volume[length_2]pivot_high.push(ph_10)pivot_high_weight.push(w)if not na(ph_20) and include_20w = switch weight_style“Linear” => 1“Time” => bar_index – length_3“Volume” => volume[length_3]pivot_high.push(ph_20)pivot_high_weight.push(w)if not na(ph_50) and include_50w = switch weight_style“Linear” => 1“Time” => bar_index – length_4“Volume” => volume[length_4]pivot_high.push(ph_50)pivot_high_weight.push(w)if not na(pl_5) and include_5w = switch weight_style“Linear” => 1“Time” => bar_index – length_1“Volume” => volume[length_1]pivot_low.push(pl_5)pivot_low_weight.push(w)if not na(pl_10) and include_10w = switch weight_style“Linear” => 1“Time” => bar_index – length_2“Volume” => volume[length_2]pivot_low.push(pl_10)pivot_low_weight.push(w)if not na(pl_20) and include_20w = switch weight_style“Linear” => 1“Time” => bar_index – length_3“Volume” => volume[length_3]pivot_low.push(pl_20)pivot_low_weight.push(w)if not na(pl_50) and include_50w = switch weight_style“Linear” => 1“Time” => bar_index – length_4“Volume” => volume[length_4]pivot_low.push(pl_50)pivot_low_weight.push(w)ifpivot_high.size()>pivot_lookbackpivot_high.shift()pivot_high_weight.shift()ifpivot_low.size()>pivot_lookbackpivot_low.shift()pivot_low_weight.shift()sudo_max = ta.max(high)max_range = math.max(include_ph ? pivot_high.max() : 0, include_pl ? pivot_low.max() : 0)min_range = math.min(include_ph ? pivot_high.min() : sudo_max, include_pl ? pivot_low.min() : sudo_max)cum = ta.cum(high – low)atr = cum > 0 ? cum / (bar_index + 1) : 10auto = auto_precision ? math.min(100, math.max(10, math.ceil((max_range – min_range) / atr))) : precisionbin_size = (max_range – min_range) / autoscores = array.new<float>(auto, 0)if include_phscores.add_to_score(pivot_high, pivot_high_weight, weight_style, min_range, bin_size, auto)if include_plscores.add_to_score(pivot_low, pivot_low_weight, weight_style, min_range, bin_size, auto)var dist = array.new<box>()var peak = array.new<line>()var peak_box = array.new<box>()var heat = array.new<box>()var bounce = array.new<label>()if dist.size() > 0 and barstate.isconfirmedfor i = dist.size() – 1 to 0dist.get(i).delete()dist.remove(i)if peak.size() > 0 and barstate.isconfirmedfor i = peak.size() – 1 to 0peak.get(i).delete()peak.remove(i)if peak_box.size() > 0 and barstate.isconfirmedfor i = peak_box.size() – 1 to 0peak_box.get(i).delete()peak_box.remove(i)if heat.size() > 0 and barstate.isconfirmedfor i = heat.size() – 1 to 0heat.get(i).delete()heat.remove(i)if bounce.size() > 0 and barstate.isconfirmedfor i = bounce.size() – 1 to 0bounce.get(i).delete()bounce.remove(i)float ma = naspeed_hack = real_time_only ? barstate.isrealtime : trueif speed_hackfiltered_scores = sinc_filter(scores, filter)iffiltered_scores.max()>0float real_minimum = 0for i = 0 to filtered_scores.size() – 1s = filtered_scores.min(i)if s != 0real_minimum := sbreakpeak_idx = peak_detection(filtered_scores, scale, real_minimum, true)if barstate.isconfirmedif peak_idx.size() > 0 and show_linesfor i = 0 to peak_idx.size() – 1p_idx = peak_idx.get(i)bin_top = min_range + bin_size * (p_idx + 1)bin_bottom = min_range + bin_size * p_idxscore = (bin_top + bin_bottom) / 2score_color = close > score ? support_color : resistance_colorif show_hitsbounce.hit(score, hit_lookback, atr, resistance_color, support_color)peak.push(line.new(bar_index + 3, score, bar_index + scale + 3, score, color = score_color, width = 2, extend = extend.left))if show_zonezone_color = color.new(score_color, zone_alpha)peak_box.push(box.new(bar_index – 1, bin_top, bar_index + scale + 3, bin_bottom, zone_color, bgcolor = zone_color, extend = extend.left))if show_dist or heat_mapfor i = 0 to filtered_scores.size() – 1max_score = filtered_scores.max() – real_minimumraw_score = filtered_scores.get(i)score = int((raw_score – real_minimum) / max_score * (scale – 1) + 1)score_color = color.from_gradient(score, 0, scale, low_color, high_color)bin_top = min_range + bin_size * (i + 1)bin_bottom = min_range + bin_size * itxt = show_score ? (weight_style == “Volume” ? str.tostring(raw_score, format.volume) : str.tostring(math.ceil(raw_score))) : naif raw_score > 0if show_distdist.push(box.new(bar_index + scale – score + 3, bin_top, bar_index + scale + 3, bin_bottom, bgcolor = score_color, border_color = score_color, text = txt, text_color = txt_color))if heat_mapheat.push(box.new(bar_index + scale – score + 3, bin_top, bar_index + scale + 3, bin_bottom, bgcolor = color.new(score_color, heat_alpha), border_color = color.new(score_color, heat_alpha), extend = extend.left))ma := ta.sma(ma(filtered_scores, min_range, bin_size, enable_ma), ma_smoothing)ma_plot = plot(ma, “MA”, ma_color, 2)ma_plot_top = plot(ma + atr / 2, “”, color.new(ma_color, 100), display = display.data_window, editable = false)ma_plot_bottom = plot(ma – atr / 2, “”, color.new(ma_color, 100), display = display.data_window, editable = false)fill(ma_plot, ma_plot_top, ma + atr / 2, ma, color.new(ma_color, 100), color.new(ma_color, 80), “Glow Top”)fill(ma_plot, ma_plot_bottom, ma, ma – atr / 2, color.new(ma_color, 80), color.new(ma_color, 100), “Glow Bottom”)06/11/2025 at 11:29 AM #248176Aquí tienes:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423//---------------------------------------------------------------------////PRC_Dynamic Support Resistance//version = 0//11.06.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------------------------------------------------------------------//DEFPARAM DrawOnLastBarOnly = true// =====================================================================// === INPUTS (Configuración del Usuario) ===// =====================================================================// -- Estilo de Ponderación: 1=""Linear"", 2=""Time"", 3=""Volume"" --weightStyle = 1// -- Longitudes para la detección de Pivotes --length1 = 5length2 = 10length3 = 20length4 = 50// -- Incluir Pivotes Altos y Bajos: 1 = sí, 0 = no --includePH = 1includePL = 1// -- Límite de Pivotes a Almacenar --pivotLookback = 50// -- Configuración de la Distribución y Filtro --precision = 75 // Número de ""contenedores"" para dividir el rango de preciosfilter = 3 // Fuerza del filtro de suavizado. 0 para desactivar.scale = 50 // Escala visual para el dibujo de objetos en el futuro// -- Configuración de Visualización --showLines = 1 // Mostrar líneas de S/RshowZone = 1 // Mostrar zonas de S/RzoneAlpha = 50 // Transparencia de la zona (0-100)showHits = 1 // Mostrar rebotes en los niveleshitLookback = 200 // Cuántas velas hacia atrás buscar rebotes// -- Colores de Soporte (Verde) --supportColorR = 0supportColorG = 255supportColorB = 0// -- Colores de Resistencia (Rojo) --resistanceColorR = 255resistanceColorG = 0resistanceColorB = 0// =====================================================================// === INICIALIZACIÓN DE ARRAYS Y VARIABLES ===// =====================================================================ONCE phIndex = 0ONCE plIndex = 0ONCE $phPrice[0] = -1ONCE $phWeight[0] = -1ONCE $phIdx[0] = -1ONCE $plPrice[0] = -1ONCE $plWeight[0] = -1ONCE $plIdx[0] = -1PI = 3.14159// Pre-calculamos el ATR para usarlo en el dibujo de los rebotesatr = AverageTrueRange[14](close)// =====================================================================// === PASO 1: DETECCIÓN Y ALMACENAMIENTO DE PIVOTES ===// =====================================================================// --- Pivotes de Longitud 1 ---isHigh1 = high[length1] > highest[length1](high)[length1+1] AND high[length1] >= highest[length1](high)isLow1 = low[length1] < lowest[length1](low)[length1+1] AND low[length1] <= lowest[length1](low)IF isHigh1 AND includePH THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length1ELSIF weightStyle = 3 THENw = volume[length1]ENDIF$phPrice[phIndex] = high[length1]$phWeight[phIndex] = w$phIdx[phIndex] = barindex[length1]phIndex = phIndex + 1ENDIFIF isLow1 AND includePL THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length1ELSIF weightStyle = 3 THENw = volume[length1]ENDIF$plPrice[plIndex] = low[length1]$plWeight[plIndex] = w$plIdx[plIndex] = barindex[length1]plIndex = plIndex + 1ENDIF// --- Pivotes de Longitud 2 ---isHigh2 = high[length2] > highest[length2](high)[length2+1] AND high[length2] >= highest[length2](high)isLow2 = low[length2] < lowest[length2](low)[length2+1] AND low[length2] <= lowest[length2](low)IF isHigh2 AND includePH THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length2ELSIF weightStyle = 3 THENw = volume[length2]ENDIF$phPrice[phIndex] = high[length2]$phWeight[phIndex] = w$phIdx[phIndex] = barindex[length2]phIndex = phIndex + 1ENDIFIF isLow2 AND includePL THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length2ELSIF weightStyle = 3 THENw = volume[length2]ENDIF$plPrice[plIndex] = low[length2]$plWeight[plIndex] = w$plIdx[plIndex] = barindex[length2]plIndex = plIndex + 1ENDIF// --- Pivotes de Longitud 3 ---isHigh3 = high[length3] > highest[length3](high)[length3+1] AND high[length3] >= highest[length3](high)isLow3 = low[length3] < lowest[length3](low)[length3+1] AND low[length3] <= lowest[length3](low)IF isHigh3 AND includePH THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length3ELSIF weightStyle = 3 THENw = volume[length3]ENDIF$phPrice[phIndex] = high[length3]$phWeight[phIndex] = w$phIdx[phIndex] = barindex[length3]phIndex = phIndex + 1ENDIFIF isLow3 AND includePL THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length3ELSIF weightStyle = 3 THENw = volume[length3]ENDIF$plPrice[plIndex] = low[length3]$plWeight[plIndex] = w$plIdx[plIndex] = barindex[length3]plIndex = plIndex + 1ENDIF// --- Pivotes de Longitud 4 ---isHigh4 = high[length4] > highest[length4](high)[length4+1] AND high[length4] >= highest[length4](high)isLow4 = low[length4] < lowest[length4](low)[length4+1] AND low[length4] <= lowest[length4](low)IF isHigh4 AND includePH THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length4ELSIF weightStyle = 3 THENw = volume[length4]ENDIF$phPrice[phIndex] = high[length4]$phWeight[phIndex] = w$phIdx[phIndex] = barindex[length4]phIndex = phIndex + 1ENDIFIF isLow4 AND includePL THENIF weightStyle = 1 THENw = 1ELSIF weightStyle = 2 THENw = barindex - length4ELSIF weightStyle = 3 THENw = volume[length4]ENDIF$plPrice[plIndex] = low[length4]$plWeight[plIndex] = w$plIdx[plIndex] = barindex[length4]plIndex = plIndex + 1ENDIF// --- Gestión del tamaño de los arrays ---IF phIndex >= pivotLookback THENFOR i = 0 TO phIndex - 2 DO$phPrice[i] = $phPrice[i+1]$phWeight[i] = $phWeight[i+1]$phIdx[i] = $phIdx[i+1]NEXTphIndex = phIndex - 1ENDIFIF plIndex >= pivotLookback THENFOR i = 0 TO plIndex - 2 DO$plPrice[i] = $plPrice[i+1]$plWeight[i] = $plWeight[i+1]$plIdx[i] = $plIdx[i+1]NEXTplIndex = plIndex - 1ENDIF// =====================================================================// === INICIO DEL BLOQUE DE CÁLCULO Y DIBUJO EN LA ÚLTIMA VELA ===// =====================================================================IF ISLASTBARUPDATE THEN// --- PASO 2: CONSTRUIR LA DISTRIBUCIÓN ---// 1. Calcular rango de preciosIF phIndex > 0 THENmaxRange = $phPrice[0]ELSEmaxRange = highENDIFIF plIndex > 0 THENminRange = $plPrice[0]ELSEminRange = lowENDIFFOR i = 1 TO phIndex - 1 DOIF $phPrice[i] > maxRange THENmaxRange = $phPrice[i]ENDIFNEXTFOR i = 0 TO plIndex - 1 DOIF $plPrice[i] > maxRange THENmaxRange = $plPrice[i]ENDIFNEXTFOR i = 0 TO phIndex - 1 DOIF $phPrice[i] < minRange THENminRange = $phPrice[i]ENDIFNEXTFOR i = 1 TO plIndex - 1 DOIF $plPrice[i] < minRange THENminRange = $plPrice[i]ENDIFNEXT// 2. Definir tamaño de BinsIF maxRange > minRange THENbinSize = (maxRange - minRange) / precisionELSEbinSize = 0ENDIF// 3. Construir la Puntuación ($scores)UnSet($scores)FOR i = 0 TO precision - 1 DO$scores[i] = 0NEXTIF binSize > 0 THENIF includePH THENFOR i = 0 TO phIndex - 1 DOpivotPrice = $phPrice[i]pivotWeight = $phWeight[i]idx = MIN(FLOOR((pivotPrice - minRange) / binSize), precision - 1)IF idx >= 0 THEN$scores[idx] = $scores[idx] + pivotWeightENDIFNEXTENDIFIF includePL THENFOR i = 0 TO plIndex - 1 DOpivotPrice = $plPrice[i]pivotWeight = $plWeight[i]idx = MIN(FLOOR((pivotPrice - minRange) / binSize), precision - 1)IF idx >= 0 THEN$scores[idx] = $scores[idx] + pivotWeightENDIFNEXTENDIFENDIF// --- PASO 3: FILTRO SINC Y DETECCIÓN DE PICOS ---// 4. Aplicar Filtro SincUnSet($filteredScores)IF filter > 0 AND binSize > 0 THENFOR i = 0 TO precision - 1 DOsum = 0sumw = 0FOR j = 0 TO precision - 1 DOdiff = i - jIF diff = 0 THENweight = 1ELSEangle = (PI * diff / (filter + 1)) * 180 / PIweight = SIN(angle) / (PI * diff / (filter + 1))ENDIFsum = sum + $scores[j] * weightsumw = sumw + weightNEXTIF sumw <> 0 THEN$filteredScores[i] = sum / sumwELSE$filteredScores[i] = 0ENDIFNEXTELSEFOR i = 0 TO precision - 1 DO$filteredScores[i] = $scores[i]NEXTENDIF// 5. Detección de PicosUnSet($peakIdx)peakCount = 0FOR i = 1 TO precision - 2 DOisPeak = ($filteredScores[i] > $filteredScores[i-1]) AND ($filteredScores[i] > $filteredScores[i+1])IF isPeak THEN$peakIdx[peakCount] = ipeakCount = peakCount + 1ENDIFNEXT// Encontramos la puntuación máxima para escalar el histogramamaxFilteredScore = 0FOR i = 0 TO precision - 1 DOIF $filteredScores[i] > maxFilteredScore THENmaxFilteredScore = $filteredScores[i]ENDIFNEXT// Posición inicial del histograma en el eje XstartHisto = barindex + 5// Dibujamos cada barra del histograma FILTRADOIF maxFilteredScore > 0 THENFOR i = 0 TO precision - 1 DObinTop = minRange + binSize * (i + 1)binBottom = minRange + binSize * iscore = $filteredScores[i]barLength = (score / maxFilteredScore) * scale// Color basado en la puntuaciónr = (score / maxFilteredScore) * 255g = 0b = 255 - rDRAWRECTANGLE(startHisto, binTop, startHisto + barLength, binBottom) coloured(r,g,b, 100)NEXTENDIF// --- PASO 4: VISUALIZACIÓN FINAL ---IF binSize > 0 THENFOR i = 0 TO peakCount - 1 DOidx = $peakIdx[i]binTop = minRange + binSize * (idx + 1)binBottom = minRange + binSize * idxlevel = (binTop + binBottom) / 2// Dibujamos un punto en el nivel del picoDRAWPOINT(startHisto, level,2) coloured("orange")IF close > level THENr = supportColorRg = supportColorGb = supportColorBELSEr = resistanceColorRg = resistanceColorGb = resistanceColorBENDIFIF showLines THENDRAWSEGMENT($phIdx[0], level, barindex + scale, level) coloured(r,g,b) style(line, 2)ENDIFIF showZone THENDRAWRECTANGLE($phIdx[0], binTop, barindex + scale, binBottom) coloured(r,g,b,0)fillcolor(r,g,b,zoneAlpha)ENDIFIF showHits THENFOR j = 0 TO hitLookback - 1 DOIF level <= high[j] AND level >= low[j] THENisBullBounce = (level < open[j]) AND (close[j] > level) AND (close[j] > open[j])IF isBullBounce THENdrawpoint(barindex[j], low[j] - atr/2, 2) coloured(supportColorR, supportColorG, supportColorB, 255)ENDIFisBearBounce = (level > open[j]) AND (close[j] < level) AND (close[j] < open[j])IF isBearBounce THENdrawpoint(barindex[j], high[j] + atr/2, 2) coloured(resistanceColorR, resistanceColorG, resistanceColorB, 255)ENDIFENDIFNEXTENDIFNEXTENDIFENDIFRETURN06/11/2025 at 6:15 PM #248194Merci Ivàn pour ce super job et ça fonctionne à la perfection.
Cependant il manque la courbe bleue 🙁
De plus, est-il possible d’ajouter la nuance de couleur dans l’histogramme horizontale.Ci-joint les Screenshots pour voir la différence entre les 2 affichages.
Merci d’avance pour ton aide
06/12/2025 at 8:31 AM #24820806/12/2025 at 10:17 AM #248209 -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
Find exclusive trading pro-tools on
Similar topics: