MARKET PROFILE, POC VAH VAL dynamiques
Forums › ProRealTime forum Français › Support ProBuilder › MARKET PROFILE, POC VAH VAL dynamiques
- This topic has 3 replies, 2 voices, and was last updated 6 days ago by
larouedegann.
-
-
05/17/2025 at 4:42 PM #247239
Bonjour,
entendons-nous bien il ne s’agit pas de volumes (VOLUME PROFILE), mais de temps passés sur le prix (MARKET PROFILE).
j’ai demandé à l’IA de bien vouloir me créer un POC,VAH,VAL dynamiques (joint ci-dessous) mais il a quelques problèmes
avec le code pine. Il y a quelque erreurs dans ce code. Si un informaticien pourrait se pencher dessus et ainsi en faire bénéficier la communauté
je le remercie d’avance.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899// === Paramètres ===tickSize = 0.25 // Résolution du profil en pointsmaxLevels = 200 // Nombre max de niveaux de prixvalueAreaPercent = 70 // Pourcentage de la Value Area// === Détection d’un nouveau jour ===newDay = (date <> date[1])if newDay theni_reset = 0minPrice = lowmaxPrice = highendif// === Initialisation progressive des niveaux TPO ===if i_reset < maxLevels thenif i_reset = 0 then setglobal("freq0", 0)if i_reset = 1 then setglobal("freq1", 0)if i_reset = 2 then setglobal("freq2", 0)if i_reset = 3 then setglobal("freq3", 0)if i_reset = 4 then setglobal("freq4", 0)if i_reset = 5 then setglobal("freq5", 0)if i_reset = 6 then setglobal("freq6", 0)if i_reset = 7 then setglobal("freq7", 0)if i_reset = 8 then setglobal("freq8", 0)if i_reset = 9 then setglobal("freq9", 0)// [...] à répéter jusqu’à freq199i_reset = i_reset + 1endif// === Mise à jour min/max journalier ===if low < minPrice thenminPrice = lowendifif high > maxPrice thenmaxPrice = highendif// === Calcul du nombre de niveaux à suivre ===range = maxPrice - minPricenbBins = min(maxLevels, ceil(range / tickSize) + 1)// === Mise à jour des niveaux de fréquence (TPO) ===for i = 0 to nbBins - 1 dolevel = minPrice + i * tickSizeif level >= low and level <= high thenfreq = getglobal("freq" + i)setglobal("freq" + i, freq + 1)endifnext// === Détermination du POC ===pocIdx = 0maxFreq = getglobal("freq0")totalFreq = maxFreqfor i = 1 to nbBins - 1 dofreq = getglobal("freq" + i)totalFreq = totalFreq + freqif freq > maxFreq thenmaxFreq = freqpocIdx = iendifnext// === Calcul Value Area (70%) ===target = totalFreq * valueAreaPercent / 100sum = getglobal("freq" + pocIdx)up = pocIdx + 1down = pocIdx - 1while sum < target dofUp = 0fDown = 0if up < nbBins thenfUp = getglobal("freq" + up)endifif down >= 0 thenfDown = getglobal("freq" + down)endifif fUp >= fDown and up < nbBins thensum = sum + fUpup = up + 1elsif down >= 0 thensum = sum + fDowndown = down - 1elsebreakendifwend// === Résultats convertis en prix ===poc = minPrice + pocIdx * tickSizevah = minPrice + (up - 1) * tickSizeval = minPrice + (down + 1) * tickSize// === Tracé ===return poc coloured("red") style(line,2) as "POC",vah coloured("green") style(dottedline) as "VAH",val coloured("green") style(dottedline) as "VAL"05/19/2025 at 10:58 AM #247306Comme je te l’ai mentionné dans un post précédent, je te laisse ici le code pour le calcul du POC. Tu verras maintenant qu’il se met à jour à chaque bougie.
Le calcul de la zone de valeur, je te le laisse.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647//------------------------------------------------------////PRC_Rolling POC Volume profile//version = 0//26.04.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//------------------------------------------------------////-----Inputs-------------------------------------------//plook=40res=15scale=30hlen=25//------------------------------------------------------////-----Create arrays for High, Low and volume-----------//maxx = highest[plook](high)minn = lowest[plook](low)step = (maxx-minn)/res //height of the rectanglevolsum=summation[plook](volume)startbar = barindex+7//------------------------------------------------------////-----Calculation POC----------------------------------//for i=0 to res-1 dobinsize=0volsize=0mybot=minn+(i*step)mytop=minn+((i+1)*step)$bottomboundaries[i]=mybot$topboundaries[i]=mytopfor j=0 to plook-1 doif close[j]>=mybot and close[j]<=mytop thenvolsize=volsize+volume[j]endifnext$VolLen[i]=volsizevolbar = (volsize*res/volsum)*scalenextfor k=0 to res-1 doif $VolLen[k]=ArrayMax($VolLen) thenx = kbreakendifnextpoc = ($topboundaries[x]+$bottomboundaries[x])/2//------------------------------------------------------//return poc as "POC" coloured("orange")style(line,3)05/19/2025 at 6:32 PM #24734206/08/2025 at 5:36 PM #248073Après plusieurs essais, voilà ce que l’on peut faire avec chatgpt.
Je ne sais pas si ce code est exact mais au moins il existe
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677DEFPARAM CalculateOnLastBars = 500defparam drawonlastbaronly = true// ----- Paramètres -----increment = pointsize // tick sizeonce $tpoCounts[0] = 0once $priceLevels[0] = 0// Réinitialisation à chaque nouvelle sessionIF OpenDay <> OpenDay[1] THENUnSet($tpoCounts)UnSet($priceLevels)ENDIF// Ajout ou incrément d’un niveaufound = 0FOR i = 0 TO LastSet($priceLevels) DOIF ABS(close - $priceLevels[i]) <= increment / 2 THEN$tpoCounts[i] = $tpoCounts[i] + 1found = 1BREAKENDIFNEXTIF found = 0 THENi = LastSet($priceLevels) + 1$priceLevels[i] = close$tpoCounts[i] = 1ENDIF// ----- Calcul POC, VAH, VAL -----totalTPO = 0maxTPO = 0pocIndex = 0FOR i = 0 TO LastSet($tpoCounts) DOtotalTPO = totalTPO + $tpoCounts[i]IF $tpoCounts[i] > maxTPO THENmaxTPO = $tpoCounts[i]pocIndex = iENDIFNEXT// VAH / VAL sur 70 % autour du POCvalueAreaTPO = totalTPO * 0.7areaTPO = $tpoCounts[pocIndex]lowIndex = pocIndexhighIndex = pocIndexWHILE areaTPO < valueAreaTPO AND (lowIndex > 0 OR highIndex < LastSet($tpoCounts)) DOvalLow = 0valHigh = 0IF lowIndex > 0 THENvalLow = $tpoCounts[lowIndex - 1]ENDIFIF highIndex < LastSet($tpoCounts) THENvalHigh = $tpoCounts[highIndex + 1]ENDIFIF valHigh >= valLow THENhighIndex = highIndex + 1areaTPO = areaTPO + valHighELSElowIndex = lowIndex - 1areaTPO = areaTPO + valLowENDIFWENDPOC = $priceLevels[pocIndex]VAH = max($priceLevels[lowIndex], $priceLevels[highIndex])VAL = min($priceLevels[lowIndex], $priceLevels[highIndex])DRAWTEXT(" POC",barindex,POC,SansSerif,Bold,20)coloured(255,255,0)DRAWTEXT(" VAH",barindex,VAH,SansSerif,Bold,20)coloured(0,255,0)DRAWTEXT(" VAL",barindex,POC,SansSerif,Bold,20)coloured(255,0,0)RETURN POC COLOURED(255,255,0) AS "POC"style(line,4), VAH COLOURED(0,255,0) AS "VAH"style(line,4), VAL COLOURED(255,0,0) AS "VAL"style(line,4)1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on