Differenza tra vari tipi di blok order
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Differenza tra vari tipi di blok order
- This topic has 1 reply, 2 voices, and was last updated 1 month ago by
Iván.
Viewing 2 posts - 1 through 2 (of 2 total)
-
-
10/02/2025 at 11:00 AM #252096
Ivan buongiorno , su trading view ho trovato un codice che sembra il più interessante tra i vari e similari “Blok order”.
Puoi per cortesia tradurlo?
Grazie
10/07/2025 at 11:25 AM #252237Ecco!!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406//----------------------------------------------//PRC_FVG Fair value MS//version = 0//01.04.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//----------------------------------------------// User Inputs//----------------------------------------------ONCE fvgTog = 1 // 1="Structural", 2="All", 3="None"// --- Colores FVG ---ONCE upColR = 58ONCE upColG = 170ONCE upColB = 69ONCE downColR = 255ONCE downColG = 3ONCE downColB = 62ONCE upFillColR = 0ONCE upFillColG = 0ONCE upFillColB = 0ONCE upFillColA = 100ONCE downFillColR = 0ONCE downFillColG = 0ONCE downFillColB = 0ONCE downFillColA = 100// --- Áreas de Interés (AOI) ---ONCE aoiNum = 3 // Número de AOIs a extenderONCE bullColorR = 58ONCE bullColorG = 170ONCE bullColorB = 69ONCE bullColorA = 20ONCE bearColorR = 255ONCE bearColorG = 3ONCE bearColorB = 62ONCE bearColorA = 20ONCE bullFillColorR = 58ONCE bullFillColorG = 170ONCE bullFillColorB = 69ONCE bullFillColorA = 20ONCE bearFillColorR = 255ONCE bearFillColorG = 3ONCE bearFillColorB = 62ONCE bearFillColorA = 20ONCE textTog = 0 // 0=false, 1=trueONCE textColorR = 255ONCE textColorG = 255ONCE textColorB = 255ONCE textColorA = 60ONCE textSize = 10// --- Líneas de Reflexión ---ONCE refTog = 1 // 0=false, 1=trueONCE refDownColR = 255ONCE refDownColG = 60ONCE refDownColB = 0ONCE refUpColR = 0ONCE refUpColG = 77ONCE refUpColB = 146ONCE refCount = 3// --- Estructura de Mercado (MS) ---ONCE msTog = 1 // 0=false, 1=trueONCE msStyle = 1 // 1=Solid, 2=Dashed, 3=DottedONCE mssBullTog = 1 // 0=false, 1=trueONCE mssBullStyle = 2 // 1=Solid, 2=Dashed, 3=DottedONCE mssBullColR = 58ONCE mssBullColG = 170ONCE mssBullColB = 69ONCE mssBearTog = 1 // 0=false, 1=trueONCE mssBearStyle = 2 // 1=Solid, 2=Dashed, 3=DottedONCE mssBearColR = 255ONCE mssBearColG = 3ONCE mssBearColB = 62// --- Sesión ---ONCE seshinStart = 093000ONCE seshinEnd = 160000ONCE stog = 1 // 0=false, 1=trueONCE sstyle = 2 // 1=Solid, 2=Dashed, 3=DottedONCE scR = 128ONCE scG = 128ONCE scB = 128ONCE scA = 50ONCE etog = 1 // 0=false, 1=trueONCE estyle = 2 // 1=Solid, 2=Dashed, 3=DottedONCE ecR = 255ONCE ecG = 3ONCE ecB = 62ONCE ecA = 50//----------------------------------------------// Variables y Arrays//----------------------------------------------ONCE dir = 0ONCE mssdir = 0ONCE bullaoicheck = 0ONCE bearaoicheck = 0ONCE hstPrice = 0ONCE hstBar = 0ONCE lstPrice = 0ONCE lstBar = 0ONCE pivhiPrice = 0ONCE pivhiBar = 0ONCE pivloPrice = 0ONCE pivloBar = 0ONCE phaoiTopPrice = highONCE phaoiTopBar = 0ONCE phaoiBotPrice = highONCE phaoiBotBar = 0ONCE plaoiTopPrice = lowONCE plaoiTopBar = 0ONCE plaoiBotPrice = lowONCE plaoiBotBar = 0ONCE pivloclaimed = 0ONCE pivhiclaimed = 0// Arrays para AOIs BullishONCE bullAoisCount = 0// Arrays para AOIs BearishONCE bearAoisCount = 0// Arrays para Líneas de ReflexiónONCE rValsCount = 0fvgup = (low > high[2]) AND (close[1] > high[2])fvgdown = (high < low[2]) AND (close[1] < low[2])ctop = MAX(open, close)cbot = MIN(open, close)//----------------------------------------------// Lógica FVG y Estructura//----------------------------------------------IF fvgTog = 2 THEN // "All"IF fvgdown THENDRAWRECTANGLE(barindex[2], low[2], barindex, high) COLOURED(downColR, downColG, downColB)$fvgTop[fvgCount+1] = high$fvgBottom[fvgCount+1] = low[2]$fvgLeft[fvgCount+1] = barindex[2]$fvgType[fvgCount+1] = -1fvgCount = fvgCount + 1ENDIFIF fvgup THENDRAWRECTANGLE(barindex[2], high[2], barindex, low) COLOURED(upColR, upColG, upColB)$fvgTop[fvgCount+1] = low$fvgBottom[fvgCount+1] = high[2]$fvgLeft[fvgCount+1] = barindex[2]$fvgType[fvgCount+1] = 1fvgCount = fvgCount + 1ENDIFENDIFIF dir = 0 THENIF fvgup THENdir = 1hstPrice = highhstBar = barindexlstPrice = lowlstBar = barindexENDIFIF fvgdown THENdir = -1hstPrice = highhstBar = barindexlstPrice = lowlstBar = barindexENDIFENDIFIF dir = 1 THENIF high >= hstPrice THENhstPrice = highhstBar = barindexlstPrice = lowlstBar = barindexelsif low <= lstPrice THENlstPrice = lowlstBar = barindexENDIFIF fvgdown THENdir = -1pivhiPrice = hstPricepivhiBar = hstBarpivhiclaimed = 0IF hstPrice > pivhiPrice[1] THENIF (pivhiPrice >= phaoiTopPrice AND bearaoicheck) OR NOT bearaoicheck THENphaoiTopPrice = pivhiPricephaoiTopBar = pivhiBarphaoiBotPrice = low[2]phaoiBotBar = barindexbearaoicheck = 1ENDIFENDIFhstPrice = highhstBar = barindex// lst se mantieneIF msTog THENDRAWSEGMENT(pivhiBar, pivhiPrice, pivloBar, pivloPrice) COLOURED(128,128,128,60) STYLE(line, 2)ENDIFIF fvgTog = 1 THEN // "Structural"DRAWRECTANGLE(barindex[2], low[2], barindex, high) COLOURED(downColR, downColG, downColB, downFillColA)$fvgTop[fvgCount+1] = high$fvgBottom[fvgCount+1] = low[2]$fvgLeft[fvgCount+1] = barindex[2]$fvgType[fvgCount+1] = -1fvgCount = fvgCount + 1ENDIFENDIFENDIFIF dir = -1 THENIF low <= lstPrice THENhstPrice = highhstBar = barindexlstPrice = lowlstBar = barindexENDIFIF high >= hstPrice THENhstPrice = highhstBar = barindexENDIFIF fvgup THENdir = 1pivloPrice = lstPricepivloBar = lstBarpivloclaimed = 0IF lstPrice < pivloPrice[1] THENIF (pivloPrice <= plaoiBotPrice AND bullaoicheck) OR NOT bullaoicheck THENplaoiTopPrice = high[2]plaoiTopBar = barindexplaoiBotPrice = pivloPriceplaoiBotBar = pivloBarbullaoicheck = 1ENDIFENDIF// hst se mantienelstPrice = lowlstBar = barindexIF msTog THENDRAWSEGMENT(pivhiBar, pivhiPrice, pivloBar, pivloPrice) COLOURED(128,128,128,60) STYLE(line, 2)ENDIFIF fvgTog = 1 THEN // "Structural"DRAWRECTANGLE(barindex[2], high[2], barindex, low) COLOURED(upColR, upColG, upColB, upFillColA)$fvgTop[fvgCount+1] = low$fvgBottom[fvgCount+1] = high[2]$fvgLeft[fvgCount+1] = barindex[2]$fvgType[fvgCount+1] = 1fvgCount = fvgCount + 1ENDIFENDIFENDIF//----------------------------------------------// --- Detección de Ruptura de Estructura (MSS) y Activación de AOIs ---//----------------------------------------------// --- Ruptura Alcista ---IF close CROSSES OVER pivhiPrice AND pivhiPrice > 0 THENDRAWSEGMENT(pivhiBar, pivhiPrice, barindex, pivhiPrice) STYLE(dottedline) COLOURED(mssBullColR, mssBullColG, mssBullColB)// ACTIVAMOS Y GUARDAMOS EL AOI ALCISTAIF bullaoicheck THENcumvol = 0FOR i = plaoiTopBar DOWNTO plaoiBotBar DOcumvol = cumvol + volume[barindex-i]NEXT// Guardamos los datos del AOI en los arrays para dibujarlos al final$bullAoisTop[bullAoisCount] = plaoiTopPrice$bullAoisBottom[bullAoisCount] = plaoiBotPrice$bullAoisLeftBar[bullAoisCount] = plaoiBotBar$bullAoisRightBar[bullAoisCount] = barindex$bullAoisVolume[bullAoisCount] = cumvol$bullAoisBreak[bullAoisCount] = 0bullAoisCount = bullAoisCount + 1// Reseteamos el check para que este AOI no se guarde dos vecesbullaoicheck = 0// Guardamos el nivel del pivote bajo para la Línea de Reflexión$rValsPrice[rValsCount] = plaoiBotPrice // Precio del pivote bajo$rValsBar[rValsCount] = plaoiBotBar // Barindex del pivote bajorValsCount = rValsCount + 1ENDIF// --- Ruptura Bajista ---ELSIF close CROSSES UNDER pivloPrice AND pivloPrice > 0 THEN// Dibujamos la línea de rupturaDRAWSEGMENT(pivloBar, pivloPrice, barindex, pivloPrice) STYLE(dottedline,3) COLOURED(mssBearColR, mssBearColG, mssBearColB)// ACTIVAMOS Y GUARDAMOS EL AOI BAJISTAIF bearaoicheck THEN// Calculamos el volumencumvol = 0FOR i = phaoiBotBar DOWNTO phaoiTopBar DOcumvol = cumvol + volume[barindex-i]NEXT// Guardamos los datos del AOI en los arrays$bearAoisTop[bearAoisCount] = phaoiTopPrice$bearAoisBottom[bearAoisCount] = phaoiBotPrice$bearAoisLeftBar[bearAoisCount] = phaoiTopBar$bearAoisRightBar[bearAoisCount] = barindex$bearAoisVolume[bearAoisCount] = cumvol$bearAoisBreak[bearAoisCount] = 0bearAoisCount = bearAoisCount + 1// Reseteamos el checkbearaoicheck = 0// Guardamos el nivel del pivote alto para la Línea de Reflexión$rValsPrice[rValsCount] = phaoiTopPrice // Precio del pivote alto$rValsBar[rValsCount] = phaoiTopBar // Barindex del pivote altorValsCount = rValsCount + 1ENDIFENDIF//----------------------------------------------// Draw AOIs//----------------------------------------------if islastbarupdate thenfor i=bearAoisCount downto 1 dodist = barindex-$bearAoisLeftBar[i]if $bearAoisBreak[i] = 0 thenfor j=dist downto 0 doif high[j] > $bearAoisTop[i] and $bearAoisBreak[i] = 0 then$bearAoisBreak[i] = 1$bearAoisRightBar[i] = barindex[j]breakendifnextendifif $bearAoisBreak[i] = 1 thendrawrectangle($bearAoisLeftBar[i],$bearAoisBottom[i],$bearAoisRightBar[i],$bearAoisTop[i])coloured(downColR,downColG,downColB)fillcolor(downColR,downColG,downColB,50)elsedrawrectangle($bearAoisLeftBar[i],$bearAoisBottom[i],barindex,$bearAoisTop[i])coloured(downColR,downColG,downColB)fillcolor(downColR,downColG,downColB,50)endifnextfor i=bullAoisCount downto 1 dodist = barindex-$bullAoisLeftBar[i]if $bullAoisBreak[i] = 0 thenfor j=dist downto 0 doif low[j] < $bullAoisBottom[i] and $bullAoisBreak[i] = 0 then$bullAoisBreak[i] = 1$bullAoisRightBar[i] = barindex[j]breakendifnextendifif $bullAoisBreak[i] = 1 thendrawrectangle($bullAoisLeftBar[i],$bullAoisBottom[i],$bullAoisRightBar[i],$bullAoisTop[i])coloured(upColR,upColG,upColB)fillcolor(upColR,upColG,upColB,50)elsedrawrectangle($bullAoisLeftBar[i],$bullAoisBottom[i],barindex,$bullAoisTop[i])coloured(upColR,upColG,upColB)fillcolor(upColR,upColG,upColB,50)endifnext// --- DIBUJO DE LÍNEAS DE REFLEXIÓN ---IF refTog THEN// Calculamos el precio medio suavizadothreshold = averagetruerange[14]ONCE rope = closemove = close - roperope = rope + MAX(ABS(move) - threshold, 0) * SGN(move)mean = rope// Controlamos que el array no supere refCountWHILE rValsCount > refCount DO// Simular un desplazamiento (shift) para eliminar el elemento más antiguoFOR i = 0 TO rValsCount - 2 DO$rValsPrice[i] = $rValsPrice[i+1]$rValsBar[i] = $rValsBar[i+1]NEXTrValsCount = rValsCount - 1WEND// Dibujamos las líneasFOR i = 0 TO rValsCount - 1 DOvalPrice = $rValsPrice[i]valBar = $rValsBar[i]// Lógica de colorIF mean < valPrice THEN// ResistenciaDRAWSEGMENT(valBar, valPrice, barindex + 1, valPrice) COLOURED(refDownColR, refDownColG, refDownColB) STYLE(line, 2)ELSE// SoporteDRAWSEGMENT(valBar, valPrice, barindex + 1, valPrice) COLOURED(refUpColR, refUpColG, refUpColB) STYLE(line, 2)ENDIFNEXTENDIFendifreturn -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
Find exclusive trading pro-tools on 
Similar topics: