Conversion Pine Script Tradingwiew en PRT
Forums › ProRealTime forum Français › Support ProBuilder › Conversion Pine Script Tradingwiew en PRT
- This topic has 3 replies, 3 voices, and was last updated 6 months ago by Iván.
Viewing 4 posts - 1 through 4 (of 4 total)
-
-
12/16/2023 at 9:14 PM #225352
Bonjour à tous,
Ci-joint le pine script de tradeforopp de tradingwiew.
Ne connaissant rien en pine script, si un informaticien pourrait aider
merci
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198/@version=5indicator("Protected Highs & Lows [TFO]", "Protected Highs & Lows [TFO]", true, max_lines_count = 500, max_labels_count = 500)var g_STR = "Structure"ps = input.int(1, "Pivot Strength", group = g_STR)color_trend = input.bool(true, "Trend Candles", inline = "TREND", group = g_STR)show_labels = input.bool(true, "Show Structure Labels", inline = "MSS", group = g_STR)label_type = input.string("MSS", "", options = ['MSS', 'BOS', 'All'], inline = "MSS", group = g_STR)var g_PHL = "Protected Highs & Lows"show_phl = input.bool(true, "Show Protected Highs & Lows", inline = "PHL", group = g_PHL)trail_phl = input.bool(true, "Show Protected Trail", inline = "TRAIL", group = g_PHL)trail_width = input.int(2, "", inline = "TRAIL", group = g_PHL)ph_color = input.color(color.red, "", inline = "PHL", group = g_PHL)pl_color = input.color(color.blue, "", inline = "PHL", group = g_PHL)bull_color = input.color(color.teal, "", inline = "TREND", group = g_STR)bear_color = input.color(color.red, "", inline = "TREND", group = g_STR)var bool bull = navar float trail_price = navar color trail_color = navar ph = array.new_float()var pl = array.new_float()var pht = array.new_int()var plt = array.new_int()var float last_high = navar float last_low = navar int last_high_idx = navar int last_low_idx = navar float track_high = navar float track_low = navar int track_high_idx = navar int track_low_idx = natype dwglabel[] _labellabel[] _phlline[] _linebool[] _bullmethod dwg_add(dwg d, label LB, label PHL, line LN, bool BL) =>d._label.unshift(LB)d._phl.unshift(PHL)d._line.unshift(LN)d._bull.unshift(BL)clear_all() =>pl.clear()plt.clear()ph.clear()pht.clear()if ta.pivotlow(low, ps, ps) and pl.size() == 0pl.unshift(low[ps])plt.unshift(time[ps])if na(last_low)last_low := low[ps]last_low_idx := bar_index - pselseif low[ps] < last_lowlast_low := low[ps]last_low_idx := bar_index - psif ta.pivothigh(high, ps, ps) and ph.size() == 0ph.unshift(high[ps])pht.unshift(time[ps])if na(last_high)last_high := high[ps]last_high_idx := bar_index - pselseif high[ps] > last_highlast_high := high[ps]last_high_idx := bar_index - psif (high[ps] > track_high or na(track_high) or last_low_idx >= track_high_idx) and not na(ta.pivothigh(high, ps, ps))track_high := high[ps]track_high_idx := bar_index - psif (low[ps] < track_low or na(track_low) or last_high_idx >= track_low_idx) and not na(ta.pivotlow(low, ps, ps))track_low := low[ps]track_low_idx := bar_index - psbos_bear = falsebos_bull = falsemss_bear = falsemss_bull = falsechange = falsevar dwgs = dwg.new(array.new_label(), array.new_label(), array.new_line(), array.new_bool())if ph.size() > 0if close > ph.get(0)label _label = nalabel _phl = naif show_labelssave = falseif label_type == 'MSS' and not bullsave := trueelse if label_type == 'BOS' and bullsave := trueelse if label_type == 'All'save := trueif save_label := label.new(math.floor(math.avg(time, pht.get(0))), ph.get(0), bull ? "BOS" : "MSS", xloc = xloc.bar_time, style = label.style_label_down, color = #ffffff00, textcolor = na)if bullbos_bull := trueelsemss_bull := true_line = line.new(pht.get(0), ph.get(0), time, ph.get(0), color = na, xloc = xloc.bar_time, style = line.style_dashed)bull := truechange := trueclear_all()if not na(track_low)if show_phl_phl := label.new(time[bar_index - track_low_idx], track_low, "▲", xloc = xloc.bar_time, style = label.style_label_up, textcolor = na, color = #ffffff00)pl.unshift(track_low)plt.unshift(time[bar_index - track_low_idx])last_high := nadwgs.dwg_add(_label, _phl, _line, bull)if pl.size() > 0if close < pl.get(0)label _label = nalabel _phl = naif show_labelssave = falseif label_type == 'MSS' and bullsave := trueelse if label_type == 'BOS' and not bullsave := trueelse if label_type == 'All'save := trueif save_label := label.new(math.floor(math.avg(time, plt.get(0))), pl.get(0), not bull ? "BOS" : "MSS", xloc = xloc.bar_time, style = label.style_label_up, color = #ffffff00, textcolor = na)if not bullbos_bear := trueelsemss_bear := true_line = line.new(plt.get(0), pl.get(0), time, pl.get(0), color = na, xloc = xloc.bar_time, style = line.style_dashed)bull := falsechange := trueclear_all()if not na(track_high)if show_phl_phl := label.new(time[bar_index - track_high_idx], track_high, "▼", xloc = xloc.bar_time, style = label.style_label_down, textcolor = na, color = #ffffff00)ph.unshift(track_high)pht.unshift(time[bar_index - track_high_idx])last_low := nadwgs.dwg_add(_label, _phl, _line, bull)if change[1]if bos_bear[1] or mss_bear[1]trail_price := track_hightrail_color := ph_colorelse if bos_bull[1] or mss_bull[1]trail_price := track_lowtrail_color := pl_color_bull = dwgs._bull.get(0)dwgs._label.get(0).set_textcolor(_bull ? bull_color : bear_color)dwgs._phl.get(0).set_textcolor(_bull ? pl_color : ph_color)dwgs._line.get(0).set_color(_bull ? bull_color : bear_color)barcolor(color_trend ? (bull ? bull_color : bear_color) : na)plot(trail_phl ? trail_price : na, color = trail_color, linewidth = trail_width)alertcondition(bos_bear[1] or bos_bull[1], "BOS Any")alertcondition(mss_bear[1] or mss_bull[1], "MSS Any")alertcondition(bos_bear[1], "BOS Bear")alertcondition(bos_bull[1], "BOS Bull")alertcondition(mss_bear[1], "MSS Bear")alertcondition(mss_bull[1], "MSS Bull")06/18/2024 at 3:15 PM #234047Mieux vaut tard que jamais 🙂
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216//-----------------------------------------------------------////PRC_Protected Highs & Lows//version = 0//18.06.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-----------------------------------------------------------////-----Inputs------------------------------------------------//ps = 1src1 = lowsrc2 = highshowLabels=1labelType=3 //1=MSS 2=BOS 3=Allshowphl=1atr=averagetruerange[14](close)coef=0.45//-----------------------------------------------------------//once lastlow=0once lastlowidx=0once lasthigh=0once lasthighidx=0once trackhigh=0once trackhighidx=0once tracklow=0once tracklowidx=0//-----------------------------------------------------------////-----Pivots low--------------------------------------------//if src1 > src1[ps] and lowest[ps](src1) > src1[ps] and src1[ps] < lowest[ps](src1)[ps+1] and not isset($pl[0]) then$pivotl[t+1]=src1[ps]t=t+1$pl[0]=src1[ps]$plx[0] = barindex[ps]pPricelow=high[ps]pIdx=barindex[ps]pBull=0pValidlow=0if lastlow=0 thenlastlow = low[ps]lastlowidx = barindex[ps]elseif low[ps] < lastlow thenlastlow = low[ps]lastlowidx = barindex[ps]endifendif//drawpoint(barindex[ps],src1[ps],2)coloured("blue",150)endif//-----------------------------------------------------------////-----Pivots high-------------------------------------------//if src2 < src2[ps] and highest[ps](src2)<src2[ps] and src2[ps]>highest[ps](src2)[ps+1] and not isset($ph[0]) then$pivoth[z+1]=src2[ps]z=z+1$ph[0]=src2[ps]$phx[0] = barindex[ps]pPricehigh=low[ps]pIdx=barindexpBull=1pValidhigh=0if lasthigh=0 thenlasthigh = high[ps]lasthighidx = barindex[ps]elseif high[ps] > lasthigh thenlasthigh = high[ps]lasthighidx = barindex[ps]endifendif//drawpoint(barindex[ps],src2[ps],2)coloured("red",150)endif//-----------------------------------------------------------//if pBull thenif close<pPricehigh and pValidhigh=0 thenpValidhigh=1endifelseif close>pPricehigh and pValidhigh=0 thenpValidhigh=1endifendifif pBull thenif close<pPricelow and pValidlow=0 thenpValidlow=1endifelseif close>pPricelow and pValidlow=0 thenpValidlow=1endifendif//-----------------------------------------------------------//if (high[ps]>trackHigh or trackhigh=0 or lastlowidx>=trackHighidx) and isset($ph[0]) and pValidlow thentrackhigh=high[ps]trackhighidx=barindex[ps]endifif (low[ps]<tracklow or tracklow=0 or lasthighidx>=tracklowidx) and isset($pl[0]) and pValidhigh thentracklow=low[ps]tracklowidx=barindex[ps]endif//-----------------------------------------------------------//bosbear=0bosbull=0mssbear=0mssbull=0change=0if isset($ph[0]) thenif close > $ph[0] thenif showLabels thenif labelType=1 and not bull thendrawtext("MSS",(barindex+$phx[0])/2,$ph[0]+coef*atr)coloured("green")drawsegment(barindex,$ph[0],$phx[0],$ph[0])style(dottedline)elsif labelType=2 and bull thendrawtext("BOS",(barindex+$phx[0])/2,$ph[0]+coef*atr)coloured("green")drawsegment(barindex,$ph[0],$phx[0],$ph[0])style(dottedline)elsif labelType=3 and not bull thendrawtext("MSS",(barindex+$phx[0])/2,$ph[0]+coef*atr)coloured("green")drawsegment(barindex,$ph[0],$phx[0],$ph[0])style(dottedline)elsif labelType=3 and bull thendrawtext("BOS",(barindex+$phx[0])/2,$ph[0]+coef*atr)coloured("green")drawsegment(barindex,$ph[0],$phx[0],$ph[0])style(dottedline)endifendifif bull thenbosbull=1elsemssbull=1endifbull=1change=1unset($ph)unset($phx)unset($pl)unset($plx)if tracklow>0 thenif showphl thendrawtext("▲",barindex[barindex-tracklowidx],tracklow)endif$pl[0]=tracklow$plx[0]=barindex[barindex-tracklowidx]lasthigh=0endifendifendifif isset($pl[0]) thenif close < $pl[0] thenif showLabels thenif labelType=1 and bull thendrawtext("MSS",(barindex+$plx[0])/2,$pl[0]-coef*atr)coloured("green")drawsegment(barindex,$pl[0],$plx[0],$pl[0])style(dottedline)elsif labelType=2 and not bull thendrawtext("BOS",(barindex+$plx[0])/2,$pl[0]-coef*atr)coloured("green")drawsegment(barindex,$pl[0],$plx[0],$pl[0])style(dottedline)elsif labelType=3 and not bull thendrawtext("BOS",(barindex+$plx[0])/2,$pl[0]-coef*atr)coloured("green")drawsegment(barindex,$pl[0],$plx[0],$pl[0])style(dottedline)elsif labelType=3 and bull thendrawtext("MSS",(barindex+$plx[0])/2,$pl[0]-coef*atr)coloured("green")drawsegment(barindex,$pl[0],$plx[0],$pl[0])style(dottedline)endifendifif not bull thenbosbear=1elsemssbear=1endifbull=0change=1unset($ph)unset($phx)unset($pl)unset($plx)if trackhigh>0 thenif showphl thendrawtext("▼",barindex[barindex-trackhighidx],trackhigh)endif$ph[0]=trackhigh$phx[0]=barindex[barindex-trackhighidx]lastlow=0endifendifendif//-----------------------------------------------------------//if change[1] thenif bosbear[1] or mssbear[1] thentrailprice=trackhighr=255b=0elsif bosbull[1] or mssbull[1] thentrailprice=tracklowr=0b=255endifendif//-----------------------------------------------------------//return trailprice coloured(r,0,b)style(line,2)06/18/2024 at 4:06 PM #234054hello
une erreur ligne 87 : pValidhigh=1#PH&F TFO
06/18/2024 at 4:14 PM #234055problèmes de copier-coller
ligne 87 : pValidhigh=1
déjà corrigé ci-dessus
1 user thanked author for this post.
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
Find exclusive trading pro-tools on
Similar topics: