ProRealCode - Trading & Coding with ProRealTime™
TopImbalance = high<low[2]
if TopImbalance then
drawcandle(low[2], low[2], high[0], high[0]) coloured("yellow")
endif
BottomInbalance = high[2]<low
if BottomInbalance then
drawcandle(low[0], low[0], high[2], high[2]) coloured ("yellow")
endif
return
Pourquoi ne pas le faire en automatique ?
Grace au topic sus-cité on a un début de réponse prometteur .
ci dessous le code du topic
REM Store support
IF high[2] < low THEN
$support[i]= high[2]
$bar[i]=barindex
i=i+1
ENDIF
REM check support line
if islastbarupdate and i>1 then
for j = 0 to i-1
checklow = $support[j]
bars = max(1,barindex-$bar[j])
endbar=barindex
for z = 1 to bars
if low[z]<checklow then
endbar=barindex[z]
endif
next
if endbar<barindex then
drawrectangle($bar[j]-2,low[max(0,barindex-$bar[j])],endbar,$support[j]) coloured("yellow") bordercolor(0,0,0,0)
ELSE
drawrectangle($bar[j]-2,low[max(0,barindex-$bar[j])],barindex,$support[j]) coloured("yellow") bordercolor(0,0,0,0)
endif
next
endif
RETURN
il ne reste pas grand chose pour qu’il soit parfait.
1/il n’y a que des bottom imbalances ( high[2]<low) donc manque les top imbalances (high<low[2])
2/ et c’est là que cela devient intéressant réduire le grignotage du rectangle (ou pas) au fur et à mesure du temps.
voir exemple.
Merci de votre aide pour enfin finir ce sujet.
defparam drawonlastbaronly=true
REM Store support
IF high[2] < low THEN
$support[i]= high[2]
$bar[i]=barindex
i=i+1
ENDIF
REM Store resistance
if high<low[2] then
$res[y]= low[2]
$resbar[y]=barindex
y=y+1
endif
REM check support line
if islastbarupdate and i>1 then
for j = 0 to i-1
checklow = $support[j]
bars = max(1,barindex-$bar[j])
endbar=barindex
for z = 1 to bars
if low[z]<checklow then
endbar=barindex[z]
endif
next
if endbar<barindex then
drawrectangle($bar[j]-2,low[max(0,barindex-$bar[j])],endbar,$support[j]) coloured("yellow",50) bordercolor(0,0,0,0)
ELSE
drawrectangle($bar[j]-2,low[max(0,barindex-$bar[j])],barindex,$support[j]) coloured("yellow",50) bordercolor(0,0,0,0)
endif
next
endif
REM check resistance line
if islastbarupdate and y>1 then
for j = 0 to y-1
checkhigh = $res[j]
bars = max(1,barindex-$resbar[j])
endbar=barindex
for z = 1 to bars
if high[z]>checkhigh then
endbar=barindex[z]
endif
next
if endbar<barindex then
drawrectangle($resbar[j]-2,high[max(0,barindex-$resbar[j])],endbar,$res[j]) coloured("cyan",50) bordercolor(0,0,0,0)
ELSE
drawrectangle($resbar[j]-2,high[max(0,barindex-$resbar[j])],barindex,$res[j]) coloured("cyan",50) bordercolor(0,0,0,0)
endif
next
endif
RETURN
Voici un model qui projette la zone imbalance jusqu au prix, mais le code ne tiens pas compte de la partie déjà retracée et la projection n’est donc pas réduite a sa partie vierge. CLAUDE IA et AI de prorelacode ne trouve pas la correction…Pouvez-vous aider?
//----------------------------------------------
// IMBALANCES VIERGES v4 — projection 30 jours
// Detection originale conservee
// + prolongation des zones non retracees
//----------------------------------------------
DEFPARAM DrawOnLastBarOnly = false
DEFPARAM calculateonlastbars = 20000
// ================================================================
// PARAMETRES
// ================================================================
imbMax = 200
days30 = 8640
// ================================================================
// INITIALISATION
// ================================================================
ONCE topIdx = 0
ONCE topCount = 0
ONCE botIdx = 0
ONCE botCount = 0
// ================================================================
// DETECTION ORIGINALE — inchangee
// ================================================================
TopImb = 0
TopImbalance = low[2] <= open[1] AND high[0] >= close[1]
TopImbalancesize = low[2] - high[0]
IF TopImbalance AND TopImbalancesize > 0 THEN
LowerWick = (min(open,close) - low) <= (range * 0.05)
Body = abs(Close - Open)
TopImb = (TopImbalancesize > Body) AND LowerWick AND (low[2] <= (min(open,close) + 2*PipSize))
DrawCandle(low[2], low[2], high[0], high[0]) coloured(255,255,0)
ENDIF
BottomInbalance = high[2] >= open[1] AND low[0] <= close[1]
BottomInbalancesize = low[0] - high[2]
IF BottomInbalance AND BottomInbalancesize > 0 THEN
DrawCandle(low[0], low[0], high[2], high[2]) coloured(255,255,0)
ENDIF
// ================================================================
// STOCKAGE DES ZONES DETESTEES
// ================================================================
IF TopImbalance AND TopImbalancesize > 0 THEN
sl = topIdx MOD imbMax
$tH[sl] = low[2]
$tL[sl] = high[0]
$tB[sl] = barindex
$tF[sl] = 0
topIdx = topIdx + 1
IF topCount < imbMax THEN
topCount = topCount + 1
ENDIF
ENDIF
IF BottomInbalance AND BottomInbalancesize > 0 THEN
sl = botIdx MOD imbMax
$bH[sl] = low[0]
$bL[sl] = high[2]
$bB[sl] = barindex
$bF[sl] = 0
botIdx = botIdx + 1
IF botCount < imbMax THEN
botCount = botCount + 1
ENDIF
ENDIF
// ================================================================
// DETECTION RETRACEMENT — zone touchee = zone remplie
// ================================================================
IF topCount > 0 THEN
FOR i = 0 TO topCount - 1 DO
sl = (topIdx - topCount + i) MOD imbMax
IF $tF[sl] = 0 AND barindex > $tB[sl] THEN
IF high >= $tL[sl] AND low <= $tH[sl] THEN
$tF[sl] = 1
ENDIF
ENDIF
NEXT
ENDIF
IF botCount > 0 THEN
FOR i = 0 TO botCount - 1 DO
sl = (botIdx - botCount + i) MOD imbMax
IF $bF[sl] = 0 AND barindex > $bB[sl] THEN
IF high >= $bL[sl] AND low <= $bH[sl] THEN
$bF[sl] = 1
ENDIF
ENDIF
NEXT
ENDIF
// ================================================================
// PROJECTION — zones vierges prolongees jusqu a maintenant
// ================================================================
IF islastbarupdate THEN
barLimit = barindex - days30
// Top imbalances vierges (orange)
IF topCount > 0 THEN
FOR i = 0 TO topCount - 1 DO
sl = (topIdx - topCount + i) MOD imbMax
IF $tF[sl] = 0 AND $tB[sl] >= barLimit THEN
DrawRectangle($tB[sl], $tH[sl], barindex, $tL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
ENDIF
NEXT
ENDIF
// Bottom imbalances vierges (jaune clair)
IF botCount > 0 THEN
FOR i = 0 TO botCount - 1 DO
sl = (botIdx - botCount + i) MOD imbMax
IF $bF[sl] = 0 AND $bB[sl] >= barLimit THEN
DrawRectangle($bB[sl], $bH[sl], barindex, $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
ENDIF
NEXT
ENDIF
ENDIF
RETURN
Bonjour Bertrand
Je n’ai pas compris ta demande, peux-tu la préciser ?
Le modèle fonctionne et ne conserve que les imbalances non touchées par le prix. Que faut-il d’autre ?
Ci-joint le modèle en surimpression de l’excellent algo de Nicolas: Imbalances indicator
Cordialement.
Merci pour ton retour, l image jointe illustre ce dont j ai besoin. La hauteur de la projection doit correspondre a la zone jaune non retracé. Idéalement il me faut obtenir ces projection de l unité de temps H1 vers mon graph 5min. J ai aborder d’innombrable combinaison avec CLAUDE sans succès. Il projette toujours la hauteur totale, ce n est pas cela qu’ il nous faut.
Bonjour Bertrand
Aldous Huxley disait que pour savoir si quelque chose est possible, il faut s’aventurer un peu au-delà, dans l’impossible !
Tu n’as pas précisé si ton graph est en H1 ou 5m, et il m’est impossible de le reproduire.
Voici en pièce jointe:
En H1, j’ai appliqué le modèle et je l’ai figé par des rectangles bleus.
Je bascule en 5m et si j’applique le modèle, il est immédiat de constater qu’il n’y a aucune frontière commune entre la projection H1 et d’éventuels résidus d’imbalances.
Les bruits H1 et 5m sont totalement disjoints.
Cordialement.
Merci pour ton aide, restons simple , donc sur un graphique 1h. Pouvez-vous projeter une imbalance comme le montre ma photo d’hier? c’est a dire une projection conforme a la hauteur de l imabalnce disponible? Pas sa hauteur totale puisqu’à un moment dans le futur une bougie l’a partiellement retracée.
Théoriquement, c’est possible mais ce sera complexe à coder car en plus tu travailles en HeikinAshi et donc les valeurs OHLC des bougies seront synthétiques et non réelles.
Un spécialiste du codage pourra mieux te répondre.
Cordialement.
Bonsoir,
J’apporte ici une proposition comportant plusieurs modifications du code fourni, pour que les rectangles tiennent compte d’un éventuel retracement partiel hors toute considération d’heikin-ashi. En effet comme le mentionne Bernard ce code des imbalances est fait avec les OHLC réels, qui ne seront pas les mêmes que les OHLC heikin-ashi. Même si quelqu’un voulait faire ce genre de comparaison hybride pour des raisons qui lui appartiennent, il faudrait de toute façon passer par l’étape de le faire fonctionner avec les OHLC réels avant toute autre chose. A tester donc sur un graphe avec prix réels où on peut trouver des zones retracées partiellement.
//----------------------------------------------
// IMBALANCES VIERGES v4 — projection 30 jours
// Detection originale conservee
// + prolongation des zones non retracees
//----------------------------------------------
DEFPARAM DrawOnLastBarOnly = false
DEFPARAM calculateonlastbars = 20000
// ================================================================
// PARAMETRES
// ================================================================
imbMax = 200
days30 = 8640
// ================================================================
// INITIALISATION
// ================================================================
ONCE topIdx = 0
ONCE topCount = 0
ONCE botIdx = 0
ONCE botCount = 0
// ================================================================
// DETECTION ORIGINALE — inchangee
// ================================================================
TopImb = 0
TopImbalance = low[2] <= open[1] AND high[0] >= close[1]
TopImbalancesize = low[2] - high[0]
IF TopImbalance AND TopImbalancesize > 0 THEN
LowerWick = (min(open,close) - low) <= (range * 0.05)
Body = abs(Close - Open)
TopImb = (TopImbalancesize > Body) AND LowerWick AND (low[2] <= (min(open,close) + 2*PipSize))
DrawCandle(low[2], low[2], high[0], high[0]) coloured(255,255,0)
ENDIF
BottomInbalance = high[2] >= open[1] AND low[0] <= close[1]
BottomInbalancesize = low[0] - high[2]
IF BottomInbalance AND BottomInbalancesize > 0 THEN
DrawCandle(low[0], low[0], high[2], high[2]) coloured(255,255,0)
ENDIF
// ================================================================
// STOCKAGE DES ZONES DETESTEES
// ================================================================
IF TopImbalance AND TopImbalancesize > 0 THEN
sl = topIdx MOD imbMax
$tH[sl] = low[2]
$tL[sl] = high[0]
$tB[sl] = barindex
$tF[sl] = 0
topIdx = topIdx + 1
IF topCount < imbMax THEN
topCount = topCount + 1
ENDIF
ENDIF
IF BottomInbalance AND BottomInbalancesize > 0 THEN
sl = botIdx MOD imbMax
$bH[sl] = low[0]
$bL[sl] = high[2]
$bB[sl] = barindex
$bF[sl] = 0
botIdx = botIdx + 1
IF botCount < imbMax THEN
botCount = botCount + 1
ENDIF
ENDIF
// ================================================================
// DETECTION RETRACEMENT — zone touchee = zone remplie
// ================================================================
IF topCount > 0 THEN
FOR i = 0 TO topCount - 1 DO
sl = (topIdx - topCount + i) MOD imbMax
IF $tF[sl]<1 AND barindex > $tB[sl] THEN//IF $tF[sl] = 0 AND barindex > $tB[sl] THEN
//IF high >= $tL[sl] AND low <= $tH[sl] THEN
//$tF[sl] = 1
//ENDIF
//// remplacé par:
IF high >= $tH[sl] THEN
$tF[sl] = 1
elsif high >= $tL[sl] THEN
$tF[sl] = 0.5
$tB2[sl] = barindex
$tL2[sl] = high
ENDIF
//// fin de remplacement
ENDIF
NEXT
ENDIF
IF botCount > 0 THEN
FOR i = 0 TO botCount - 1 DO
sl = (botIdx - botCount + i) MOD imbMax
IF $bF[sl]<1 AND barindex > $bB[sl] THEN//IF $bF[sl] = 0 AND barindex > $bB[sl] THEN
//IF high >= $bL[sl] AND low <= $bH[sl] THEN
//$bF[sl] = 1
//ENDIF
//// remplacé par:
IF low <= $bL[sl] THEN
$bF[sl] = 1
elsif low <= $bH[sl] THEN
$bF[sl] = 0.5
$bB2[sl] = barindex
$bH2[sl] = low
ENDIF
//// fin de remplacement
ENDIF
NEXT
ENDIF
// ================================================================
// PROJECTION — zones vierges prolongees jusqu a maintenant
// ================================================================
IF islastbarupdate THEN
barLimit = barindex - days30
// Top imbalances vierges (orange)
IF topCount > 0 THEN
FOR i = 0 TO topCount - 1 DO
sl = (topIdx - topCount + i) MOD imbMax
//IF $tF[sl] = 0 AND $tB[sl] >= barLimit THEN
//DrawRectangle($tB[sl], $tH[sl], barindex, $tL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
//ENDIF
//// remplacé par:
IF $tF[sl]<1 AND $tB[sl] >= barLimit THEN
if $tF[sl]=0 then// zones non retracées
DrawRectangle($tB[sl], $tH[sl], barindex, $tL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
elsif $tF[sl]=0.5 then// zones partiellement retracées
DrawRectangle($tB[sl], $tH[sl], $tB2[sl], $tL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
DrawRectangle($tB2[sl], $tH[sl], barindex, $tL2[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
endif
//// fin de remplacement
ENDIF
NEXT
ENDIF
// Bottom imbalances vierges (jaune clair)
IF botCount > 0 THEN
FOR i = 0 TO botCount - 1 DO
sl = (botIdx - botCount + i) MOD imbMax
//IF $bF[sl] = 0 AND $bB[sl] >= barLimit THEN
//DrawRectangle($bB[sl], $bH[sl], barindex, $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
//ENDIF
//// remplacé par:
IF $bF[sl]<1 AND $bB[sl] >= barLimit THEN
if $bF[sl]=0 then// zones non retracées
DrawRectangle($bB[sl], $bH[sl], barindex, $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
elsif $bF[sl]=0.5 then// zones partiellement retracées
DrawRectangle($bB[sl], $bH[sl], $bB2[sl], $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
DrawRectangle($bB2[sl], $bH2[sl], barindex, $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
endif
//// fin de remplacement
ENDIF
NEXT
ENDIF
ENDIF
RETURN
PS1: PJ capture écran Brent timeframe 1h, qui présente deux cas de retracement partiel, un de de chaque côté
PS2: Si un retracement partiel se fait en plusieurs fois, il faudra adapter le code davantage au niveau des $tL2 et $bH2, si quelqu’un voit un cas d’actif et de timeframe où cela se produit, svp me le communiquer pour que je teste sur ce cas les modifications supplémentaires à apporter, merci.
Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.
IMBALANCE projections rectangulaires
This topic contains 14 replies,
has 5 voices, and was last updated by
JC_Bywan
1 day, 16 hours ago.
| Forum: | ProBuilder : Indicateurs & Outils Personnalisés |
| Language: | French |
| Started: | 10/07/2023 |
| Status: | Active |
| Attachments: | 7 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.