Traduction Code pine tradingwiew (Order Block)
Forums › ProRealTime forum Français › Support ProBuilder › Traduction Code pine tradingwiew (Order Block)
- This topic has 8 replies, 4 voices, and was last updated 2 days ago by larouedegann.
-
-
01/03/2024 at 3:22 PM #225935
Bonjour,
Veuillez trouver ci-dessous le code pine “ORDER BLOCK DETECTOR” de luxalgo
Est-ce qu’on peut le traduire en PRT ?merci
/@version=5
indicator(“Order Block Detector [LuxAlgo]”
, overlay = true
, max_boxes_count = 500
, max_labels_count = 500
, max_lines_count = 500)
//——————————————————————————
//Settings
//—————————————————————————–{
length = input.int(5, ‘Volume Pivot Length’
, minval = 1)bull_ext_last = input.int(3, ‘Bullish OB ’
, minval = 1
, inline = ‘bull’)bg_bull_css = input.color(color.new(#169400, 80), ”
, inline = ‘bull’)bull_css = input.color(#169400, ”
, inline = ‘bull’)bull_avg_css = input.color(color.new(#9598a1, 37), ”
, inline = ‘bull’)bear_ext_last = input.int(3, ‘Bearish OB’
, minval = 1
, inline = ‘bear’)bg_bear_css = input.color(color.new(#ff1100, 80), ”
, inline = ‘bear’)bear_css = input.color(#ff1100, ”
, inline = ‘bear’)bear_avg_css = input.color(color.new(#9598a1, 37), ”
, inline = ‘bear’)line_style = input.string(‘⎯⎯⎯’, ‘Average Line Style’
, options = [‘⎯⎯⎯’, ‘—-‘, ‘····’])line_width = input.int(1, ‘Average Line Width’
, minval = 1)mitigation = input.string(‘Wick’, ‘Mitigation Methods’
, options = [‘Wick’, ‘Close’])//—————————————————————————–}
//Functions
//—————————————————————————–{
//Line Style function
get_line_style(style) =>
out = switch style
‘⎯⎯⎯’ => line.style_solid
‘—-‘ => line.style_dashed
‘····’ => line.style_dotted//Function to get order block coordinates
get_coordinates(condition, top, btm, ob_val)=>
var ob_top = array.new_float(0)
var ob_btm = array.new_float(0)
var ob_avg = array.new_float(0)
var ob_left = array.new_int(0)float ob = na
//Append coordinates to arrays
if condition
avg = math.avg(top, btm)array.unshift(ob_top, top)
array.unshift(ob_btm, btm)
array.unshift(ob_avg, avg)
array.unshift(ob_left, time[length])ob := ob_val
[ob_top, ob_btm, ob_avg, ob_left, ob]
//Function to remove mitigated order blocks from coordinate arrays
remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=>
mitigated = false
target_array = bull ? ob_btm : ob_topfor element in target_array
idx = array.indexof(target_array, element)if (bull ? target < element : target > element)
mitigated := truearray.remove(ob_top, idx)
array.remove(ob_btm, idx)
array.remove(ob_avg, idx)
array.remove(ob_left, idx)mitigated
//Function to set order blocks
set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=>
var ob_box = array.new_box(0)
var ob_lvl = array.new_line(0)//Fill arrays with boxes/lines
if barstate.isfirst
for i = 0 to ext_last-1
array.unshift(ob_box, box.new(na,na,na,na
, xloc = xloc.bar_time
, extend= extend.right
, bgcolor = bg_css
, border_color = color.new(border_css, 70)))array.unshift(ob_lvl, line.new(na,na,na,na
, xloc = xloc.bar_time
, extend = extend.right
, color = lvl_css
, style = get_line_style(line_style)
, width = line_width))//Set order blocks
if barstate.islast
if array.size(ob_top) > 0
for i = 0 to math.min(ext_last-1, array.size(ob_top)-1)
get_box = array.get(ob_box, i)
get_lvl = array.get(ob_lvl, i)box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i))
box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i))line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i))
line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i))//—————————————————————————–}
//Global elements
//—————————————————————————–{
var os = 0
var target_bull = 0.
var target_bear = 0.n = bar_index
upper = ta.highest(length)
lower = ta.lowest(length)if mitigation == ‘Close’
target_bull := ta.lowest(close, length)
target_bear := ta.highest(close, length)
else
target_bull := lower
target_bear := upperos := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1] phv = ta.pivothigh(volume, length, length) //-----------------------------------------------------------------------------} //Get bullish/bearish order blocks coordinates //-----------------------------------------------------------------------------{ [bull_top , bull_btm , bull_avg , bull_left , bull_ob] = get_coordinates(phv and os == 1, hl2[length], low[length], low[length]) [bear_top , bear_btm , bear_avg , bear_left , bear_ob] = get_coordinates(phv and os == 0, high[length], hl2[length], high[length]) //-----------------------------------------------------------------------------} //Remove mitigated order blocks //-----------------------------------------------------------------------------{ mitigated_bull = remove_mitigated(bull_top , bull_btm , bull_left , bull_avg , target_bull , true) mitigated_bear = remove_mitigated(bear_top , bear_btm , bear_left , bear_avg , target_bear , false) //-----------------------------------------------------------------------------} //Display order blocks //-----------------------------------------------------------------------------{ //Set bullish order blocks set_order_blocks(bull_top , bull_btm , bull_left , bull_avg , bull_ext_last , bg_bull_css , bull_css , bull_avg_css) //Set bearish order blocks set_order_blocks(bear_top , bear_btm , bear_left , bear_avg , bear_ext_last , bg_bear_css , bear_css , bear_avg_css) //Show detected order blocks plot(bull_ob, 'Bull OB', bull_css, 2, plot.style_linebr , offset = -length , display = display.none) plot(bear_ob, 'Bear OB', bear_css, 2, plot.style_linebr , offset = -length , display = display.none) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ alertcondition(bull_ob, 'Bullish OB Formed', 'Bullish order block detected') alertcondition(bear_ob, 'Bearish OB Formed', 'bearish order block detected') alertcondition(mitigated_bull, 'Bullish OB Mitigated', 'Bullish order block mitigated') alertcondition(mitigated_bear, 'Bearish OB Mitigated', 'bearish order block mitigated') //-----------------------------------------------------------------------------}
01/03/2024 at 3:25 PM #225936123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230/@version=5indicator("Order Block Detector [LuxAlgo]", overlay = true, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500)//------------------------------------------------------------------------------//Settings//-----------------------------------------------------------------------------{length = input.int(5, 'Volume Pivot Length', minval = 1)bull_ext_last = input.int(3, 'Bullish OB ', minval = 1, inline = 'bull')bg_bull_css = input.color(color.new(#169400, 80), '', inline = 'bull')bull_css = input.color(#169400, '', inline = 'bull')bull_avg_css = input.color(color.new(#9598a1, 37), '', inline = 'bull')bear_ext_last = input.int(3, 'Bearish OB', minval = 1, inline = 'bear')bg_bear_css = input.color(color.new(#ff1100, 80), '', inline = 'bear')bear_css = input.color(#ff1100, '', inline = 'bear')bear_avg_css = input.color(color.new(#9598a1, 37), '', inline = 'bear')line_style = input.string('⎯⎯⎯', 'Average Line Style', options = ['⎯⎯⎯', '----', '····'])line_width = input.int(1, 'Average Line Width', minval = 1)mitigation = input.string('Wick', 'Mitigation Methods', options = ['Wick', 'Close'])//-----------------------------------------------------------------------------}//Functions//-----------------------------------------------------------------------------{//Line Style functionget_line_style(style) =>out = switch style'⎯⎯⎯' => line.style_solid'----' => line.style_dashed'····' => line.style_dotted//Function to get order block coordinatesget_coordinates(condition, top, btm, ob_val)=>var ob_top = array.new_float(0)var ob_btm = array.new_float(0)var ob_avg = array.new_float(0)var ob_left = array.new_int(0)float ob = na//Append coordinates to arraysif conditionavg = math.avg(top, btm)array.unshift(ob_top, top)array.unshift(ob_btm, btm)array.unshift(ob_avg, avg)array.unshift(ob_left, time[length])ob := ob_val[ob_top, ob_btm, ob_avg, ob_left, ob]//Function to remove mitigated order blocks from coordinate arraysremove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=>mitigated = falsetarget_array = bull ? ob_btm : ob_topfor element in target_arrayidx = array.indexof(target_array, element)if (bull ? target < element : target > element)mitigated := truearray.remove(ob_top, idx)array.remove(ob_btm, idx)array.remove(ob_avg, idx)array.remove(ob_left, idx)mitigated//Function to set order blocksset_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=>var ob_box = array.new_box(0)var ob_lvl = array.new_line(0)//Fill arrays with boxes/linesif barstate.isfirstfor i = 0 to ext_last-1array.unshift(ob_box, box.new(na,na,na,na, xloc = xloc.bar_time, extend= extend.right, bgcolor = bg_css, border_color = color.new(border_css, 70)))array.unshift(ob_lvl, line.new(na,na,na,na, xloc = xloc.bar_time, extend = extend.right, color = lvl_css, style = get_line_style(line_style), width = line_width))//Set order blocksif barstate.islastif array.size(ob_top) > 0for i = 0 to math.min(ext_last-1, array.size(ob_top)-1)get_box = array.get(ob_box, i)get_lvl = array.get(ob_lvl, i)box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i))box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i))line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i))line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i))//-----------------------------------------------------------------------------}//Global elements//-----------------------------------------------------------------------------{var os = 0var target_bull = 0.var target_bear = 0.n = bar_indexupper = ta.highest(length)lower = ta.lowest(length)if mitigation == 'Close'target_bull := ta.lowest(close, length)target_bear := ta.highest(close, length)elsetarget_bull := lowertarget_bear := upperos := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1]phv = ta.pivothigh(volume, length, length)//-----------------------------------------------------------------------------}//Get bullish/bearish order blocks coordinates//-----------------------------------------------------------------------------{[bull_top, bull_btm, bull_avg, bull_left, bull_ob] = get_coordinates(phv and os == 1, hl2[length], low[length], low[length])[bear_top, bear_btm, bear_avg, bear_left, bear_ob] = get_coordinates(phv and os == 0, high[length], hl2[length], high[length])//-----------------------------------------------------------------------------}//Remove mitigated order blocks//-----------------------------------------------------------------------------{mitigated_bull = remove_mitigated(bull_top, bull_btm, bull_left, bull_avg, target_bull, true)mitigated_bear = remove_mitigated(bear_top, bear_btm, bear_left, bear_avg, target_bear, false)//-----------------------------------------------------------------------------}//Display order blocks//-----------------------------------------------------------------------------{//Set bullish order blocksset_order_blocks(bull_top, bull_btm, bull_left, bull_avg, bull_ext_last, bg_bull_css, bull_css, bull_avg_css)//Set bearish order blocksset_order_blocks(bear_top, bear_btm, bear_left, bear_avg, bear_ext_last, bg_bear_css, bear_css, bear_avg_css)//Show detected order blocksplot(bull_ob, 'Bull OB', bull_css, 2, plot.style_linebr, offset = -length, display = display.none)plot(bear_ob, 'Bear OB', bear_css, 2, plot.style_linebr, offset = -length, display = display.none)//-----------------------------------------------------------------------------}//Alerts//-----------------------------------------------------------------------------{alertcondition(bull_ob, 'Bullish OB Formed', 'Bullish order block detected')alertcondition(bear_ob, 'Bearish OB Formed', 'bearish order block detected')alertcondition(mitigated_bull, 'Bullish OB Mitigated', 'Bullish order block mitigated')alertcondition(mitigated_bear, 'Bearish OB Mitigated', 'bearish order block mitigated')//-----------------------------------------------------------------------------}01/06/2024 at 8:03 PM #226064Personne pour une traduction code pine ?
01/12/2024 at 10:23 AM #22627203/16/2024 at 6:36 PM #229903Toujours personne ?
03/19/2024 at 5:31 PM #23005603/19/2024 at 6:06 PM #230064i used the Chat gpt to convert but its got error on line 1 if someone can tell please here is the code for the above
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116//Settingslength = 5bull_ext_last = 3bg_bull_css = RGB(22, 148, 0, 80)bull_css = RGB(22, 148, 0)bull_avg_css = RGB(149, 152, 161, 37)bear_ext_last = 3bg_bear_css = RGB(255, 17, 0, 80)bear_css = RGB(255, 17, 0)bear_avg_css = RGB(149, 152, 161, 37)line_style = 0 // 0 for solid line, 1 for dashed line, 2 for dotted lineline_width = 1mitigation = 0 // 0 for Wick, 1 for Close//Functionsget_line_style(style) =>out = IIF(style = 0, linestyle.solid, IIF(style = 1, linestyle.dashed, linestyle.dotted))get_coordinates(condition, top, btm, ob_val)=>var ob_top[500]var ob_btm[500]var ob_avg[500]var ob_left[500]var ob = 0.0if condition thenavg = (top + btm) / 2ob_top[0] := topob_btm[0] := btmob_avg[0] := avgob_left[0] := time[length]ob := ob_val[ob_top, ob_btm, ob_avg, ob_left, ob]remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=>mitigated = FALSEtarget_array = bull ? ob_btm : ob_topfor i = 0 to ArraySize(target_array) - 1if (bull ? target < target_array[i] : target > target_array[i]) thenmitigated := TRUEArrayDelete(ob_top, i)ArrayDelete(ob_btm, i)ArrayDelete(ob_avg, i)ArrayDelete(ob_left, i)mitigatedset_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=>var ob_box[500]var ob_lvl[500]if barindex = 1 thenfor i = 0 to ext_last - 1ob_box[i] := CreateBox(na, na, na, na, xloc = xloc.bar_time, extend = extend.right, bgcolor = bg_css, border_color = color.new(border_css, 70))ob_lvl[i] := CreateLine(na, na, na, na, xloc = xloc.bar_time, extend = extend.right, color = lvl_css, style = get_line_style(line_style), width = line_width)if lastbaronchart thenfor i = 0 to Min(ext_last - 1, ArraySize(ob_top) - 1)box.SetLeftTop(ob_box[i], ob_left[i], ob_top[i])box.SetRightBottom(ob_box[i], ob_left[i], ob_btm[i])line.SetXY1(ob_lvl[i], ob_left[i], ob_avg[i])line.SetXY2(ob_lvl[i], ob_left[i] + 1, ob_avg[i])//Global elementsvar os = 0var target_bull = 0.0var target_bear = 0.0n = barindexupper = Highest[length]lower = Lowest[length]if mitigation = 1 thentarget_bull := Lowest[1](close[length])target_bear := Highest[1](close[length])elsetarget_bull := lowertarget_bear := upperos := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1]phv = PivotHigh(volume, length, length)//Get bullish/bearish order blocks coordinates[bull_top, bull_btm, bull_avg, bull_left, bull_ob] = get_coordinates(phv and os = 1, hl2[length], low[length], low[length])[bear_top, bear_btm, bear_avg, bear_left, bear_ob] = get_coordinates(phv and os = 0, high[length], hl2[length], high[length])//Remove mitigated order blocksmitigated_bull = remove_mitigated(bull_top, bull_btm, bull_left, bull_avg, target_bull, TRUE)mitigated_bear = remove_mitigated(bear_top, bear_btm, bear_left, bear_avg, target_bear, FALSE)//Display order blocksset_order_blocks(bull_top, bull_btm, bull_left, bull_avg, bull_ext_last, bg_bull_css, bull_css, bull_avg_css)set_order_blocks(bear_top, bear_btm, bear_left, bear_avg, bear_ext_last, bg_bear_css, bear_css, bear_avg_css)//AlertsAlertIf(bull_ob, "Bullish OB Formed", "Bullish order block detected")AlertIf(bear_ob, "Bearish OB Formed", "Bearish order block detected")AlertIf(mitigated_bull, "Bullish OB Mitigated", "Bullish order block mitigated")AlertIf(mitigated_bear, "Bearish OB Mitigated", "Bearish order block mitigated")04/29/2024 at 6:30 PM #232052Hola Aquí a une approximation.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788//-----Settings---------------------------------------------------------//length = 5 //Volume Pivot Lengthbullextlast = 3 //Bullish OBbearextlast = 3 //Bearish OBmitigation = 0 //0=Wick 1=Close//----------------------------------------------------------------------////-----Global elements--------------------------------------------------//n=barindexupper = highest[length](high)lower = lowest[length](low)if mitigation thentargetbull = lowest[length](close)targetbear = highest[length](close)elsetargetbull = lowertargetbear = upperendifif high[length] > upper thenos = 0elsif low[length] < lower thenos = 1elseos = os[1]endifif volume < volume[length] and highest[length](volume)<volume[length] and volume[length]>highest[length](volume)[length+1] then$phvol[t+1]=volume[length]$phvolx[t+1]=barindex[length]t=t+1endifphv = $phvol[t]//----------------------------------------------------------------------////-----Get bullish/bearish order blocks coordinates---------------------//if isset($phvol[t]) and phv<>phv[1] and os=1 then$bulltop[m+1] = (high[length]+low[length])/2$bullbtm[m+1] = low[length]$bullavg[m+1] = ((high[length]+low[length])/2+low[length])/2$bullleft[m+1] = barindex-length$bullob[m+1] = low[length]m=m+1endifif isset($phvol[t]) and phv<>phv[1] and os=0 then$beartop[r+1] = high[length]$bearbtm[r+1] = (high[length]+low[length])/2$bearavg[r+1] = ((high[length]+low[length])/2+high[length])/2$bearleft[r+1] = barindex-length$bearob[r+1] = high[length]r=r+1endif//----------------------------------------------------------------------////remove_mitigatedif islastbarupdate thent=0for i=m downto 0 doif targetbull > $bullbtm[i] then$bullishTOP[T+1] = $bulltop[i]$bullishBOT[T+1] = $bullbtm[i]$bullishAVG[T+1] = $bullavg[i]$bullishLEFT[T+1] = $bullleft[i]t=t+1drawrectangle($bullishLEFT[t],$bullishTOP[t],barindex,$bullishBOT[t])coloured("green")fillcolor("green",70)if t >= bullextlast thenbreakendifendifnext//----------------------------------------------------------------------//k=0for j=r downto 0 doif targetbear < $beartop[j] then$bearishtop[k+1]=$beartop[j]$bearishbot[k+1]=$bearbtm[j]$bearishavg[k+1]=$bearavg[j]$bearishleft[k+1]=$bearleft[j]k=k+1drawrectangle($bearishleft[k],$bearishtop[k],barindex,$bearishbot[k])coloured("red")fillcolor("red",70)if k >= bearextlast thenbreakendifendifnextendif//----------------------------------------------------------------------//return05/03/2024 at 10:49 AM #232251Merci à toi ivan
-
AuthorPosts