Market Profile – Initial Balance

Market Profile – Initial Balance

Hello everyone,

Thank you for accompanying me in my trading for the past 4 years. Today, it’s my turn to share my code with you!
For a few weeks now, I’ve been getting back into the market profile to improve my strategy decision-making.
As I’m on IG cfd, I don’t have access to the tool. So when I asked around, I understood that the Initial Balance IB was relatively important for the key zones of the day.

By looking around various sources I understand that the market profile is used in M30 but then the choice of the half-hour taken for the IB differs; some take the M30 candle of the preopening, others that of the openening.
For my part, I chose openning, but it’s modifiable in the code.

Nothing crazy, but I plot my IB M30 at 9 a.m. for the dax (to be modified for the US) in blue with the upper and lower bounds extended to the far right.
I put a variable n = number of rectangles (equal to the IB) above and below the IB with half-rights to visualize my key levels.

If you wish to adapt it, everything is modifiable:

To be changed according to which market you’re trading:
start = 093000 //dax if we’re in M30 and want to have the Initial Balance (IB) on the 9 a.m. candle, we set it to 9:30 a.m. because we “draw on last bar only”.
end = 100000 //dax
//start = 160000 //US if trading in the US, activate these times and deactivate those of the dax
//end = 163000 //US

Number of rectangles corresponding to IB :
n = 5 //number of rectangles above and below IB

If you want to see the current day, other days or all days, but it quickly becomes unreadable :
for y = i-1 to i-1 do //put i-1 for the previous day’s IB, i-1 to i for the previous day’s IB and the day, 1 to i for all days etc…

Don’t hesitate to give me feedback, and if anyone has a code to add the TPO, I’d love to hear from you 😉

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Razz • 36 days ago #

    Good morning
    What do I have to change in the code in line 30 to only see the current day? Please post the finished line and do the same if I want to see all days. Thank you for your work. What else might be useful is a line at 50% of the key zone?

    Thank you in advance and have a nice Christmas time

  2. Razz • 32 days ago #

    OK, I’ve solved it for myself, maybe it will help others too. Unfortunately I don’t know how to insert the ITF file here?
    defparam drawonlastbaronly=true

    If Dax then
    start = 093000 //dax si on est en M30 et qu’on veut avoir l’Initial Balance (IB) sur la bougie de 9h on met 9h30 car on “draw on last bar only”
    end = 100000 //dax
    endif
    If US then
    start = 160000 //US si trading US, activer ces horaires là et désactiver ceux du dax
    end = 163000 //US
    endif
    tc = time>=start and time<end
    n = Boxen //nombre de rectangles au dessus et en dessous de l’IB

    if tc and not tc[1] then
    i=i+1
    $x1[i]=barindex
    $y1[i]=low
    $y2[i]=high
    hh=high
    ll=low
    endif

    if tc then
    $x2[i]=barindex
    ll=min(ll,low)
    hh=max(hh,high)
    $y1[i]=ll
    $y2[i]=hh
    endif

    if islastbarupdate and isset($x1[2]) and T then
    //for y = i-1 to i-1 do //mettre i-1 pour L’IB de la veille, i-1 to i pour l’IB de la veille et la journeé, 1 to i pour tous les jours etc…
    //for y = 1 to I // alle Marken
    //for y = i-1 to I // heute und gestern
    for y = i-0 to I // heute
    for a=1 to n-1 do
    for b=1 to n do

    drawrectangle($x1[y]-1,$y1[y],$x2[y]+1,$y2[y])coloured(0,255,255,150)bordercolor(0,0,255)

    If ExtBox then //Initial balance
    drawrectangle($x1[y]-1,$y2[y],$x2[y]+1,$y2[y]+$y2[y]-$y1[y])coloured(255,0,255,150)bordercolor(0,0,255) //IB+1
    drawrectangle($x1[y]-1,$y1[y],$x2[y]+1,$y1[y]-($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255) //IB-1
    drawrectangle($x1[y]-1,$y2[y]+ a*($y2[y]-$y1[y]),$x2[y]+1,$y2[y]+(a+1)*($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255)
    drawrectangle($x1[y]-1,$y1[y]-a*($y2[y]-$y1[y]),$x2[y]+1,$y1[y]-(a+1)*($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255)
    endif
    If IBLines then
    DRAWRAY ($x1[i-x],$y1[i-x],$x1[i-x]+10,$y1[i-x])COLOURED (0,255,255,150) style(line,3) //borne haute IB
    DRAWRAY ($x2[i-x],$y2[i-x],$x2[i-x]+10,$y2[i-x])COLOURED (0,255,255,150) style(line,3) //borne basse IB
    endif
    //If IBLines then
    //DRAWRAY ($x1[i-1],$y1[i-1],$x1[i-1]+10,$y1[i-1])COLOURED (0,255,255,150) style(line,3) //borne haute IB
    //DRAWRAY ($x2[i-1],$y2[i-1],$x2[i-1]+10,$y2[i-1])COLOURED (0,255,255,150) style(line,3) //borne basse IB
    //endif
    If ExtLines then
    DRAWRAY($x1[i-x],$y2[i-x]+b*($y2[i-x]-$y1[i-x]),$x1[i-x]+10,$y2[i-x]+b*($y2[i-x]-$y1[i-x]))COLOURED (255,50,0,150) style(line,3)
    DRAWRAY($x1[i-x],$y1[i-x]-b*($y2[i-x]-$y1[i-x]),$x1[i-x]+10,$y1[i-x]-b*($y2[i-x]-$y1[i-x]))COLOURED (255,50,0,150) style(line,3)
    endif
    next
    next
    next
    endif

    if islastbarupdate and isset($x1[2]) and TY then
    //for y = i-1 to i-1 do //mettre i-1 pour L’IB de la veille, i-1 to i pour l’IB de la veille et la journeé, 1 to i pour tous les jours etc…
    //for y = 1 to I // alle Marken
    for y = i-1 to I // heute und gestern
    //for y = i-0 to I // heute
    for a=1 to n-1 do
    for b=1 to n do

    drawrectangle($x1[y]-1,$y1[y],$x2[y]+1,$y2[y])coloured(0,255,255,150)bordercolor(0,0,255)

    If ExtBox then //Initial balance
    drawrectangle($x1[y]-1,$y2[y],$x2[y]+1,$y2[y]+$y2[y]-$y1[y])coloured(255,0,255,150)bordercolor(0,0,255) //IB+1
    drawrectangle($x1[y]-1,$y1[y],$x2[y]+1,$y1[y]-($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255) //IB-1
    drawrectangle($x1[y]-1,$y2[y]+ a*($y2[y]-$y1[y]),$x2[y]+1,$y2[y]+(a+1)*($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255)
    drawrectangle($x1[y]-1,$y1[y]-a*($y2[y]-$y1[y]),$x2[y]+1,$y1[y]-(a+1)*($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255)
    endif
    If IBLines then
    DRAWRAY ($x1[i-x],$y1[i-x],$x1[i-x]+10,$y1[i-x])COLOURED (0,255,255,150) style(line,3) //borne haute IB
    DRAWRAY ($x2[i-x],$y2[i-x],$x2[i-x]+10,$y2[i-x])COLOURED (0,255,255,150) style(line,3) //borne basse IB
    endif
    //If IBLines then
    //DRAWRAY ($x1[i-1],$y1[i-1],$x1[i-1]+10,$y1[i-1])COLOURED (0,255,255,150) style(line,3) //borne haute IB
    //DRAWRAY ($x2[i-1],$y2[i-1],$x2[i-1]+10,$y2[i-1])COLOURED (0,255,255,150) style(line,3) //borne basse IB
    //endif
    If ExtLines then
    DRAWRAY($x1[i-x],$y2[i-x]+b*($y2[i-x]-$y1[i-x]),$x1[i-x]+10,$y2[i-x]+b*($y2[i-x]-$y1[i-x]))COLOURED (255,50,0,150) style(line,3)
    DRAWRAY($x1[i-x],$y1[i-x]-b*($y2[i-x]-$y1[i-x]),$x1[i-x]+10,$y1[i-x]-b*($y2[i-x]-$y1[i-x]))COLOURED (255,50,0,150) style(line,3)
    endif
    next
    next
    next
    endif

    if islastbarupdate and isset($x1[2]) and all then
    //for y = i-1 to i-1 do //mettre i-1 pour L’IB de la veille, i-1 to i pour l’IB de la veille et la journeé, 1 to i pour tous les jours etc…
    for y = 1 to I // alle Marken
    //for y = i-1 to I // heute und gestern
    //for y = i-0 to I // heute
    for a=1 to n-1 do
    for b=1 to n do

    drawrectangle($x1[y]-1,$y1[y],$x2[y]+1,$y2[y])coloured(0,255,255,150)bordercolor(0,0,255)

    If ExtBox then //Initial balance
    drawrectangle($x1[y]-1,$y2[y],$x2[y]+1,$y2[y]+$y2[y]-$y1[y])coloured(255,0,255,150)bordercolor(0,0,255) //IB+1
    drawrectangle($x1[y]-1,$y1[y],$x2[y]+1,$y1[y]-($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255) //IB-1
    drawrectangle($x1[y]-1,$y2[y]+ a*($y2[y]-$y1[y]),$x2[y]+1,$y2[y]+(a+1)*($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255)
    drawrectangle($x1[y]-1,$y1[y]-a*($y2[y]-$y1[y]),$x2[y]+1,$y1[y]-(a+1)*($y2[y]-$y1[y]))coloured(255,0,255,150)bordercolor(0,0,255)
    endif
    If IBLines then
    DRAWRAY ($x1[i-x],$y1[i-x],$x1[i-x]+10,$y1[i-x])COLOURED (0,255,255,150) style(line,3) //borne haute IB
    DRAWRAY ($x2[i-x],$y2[i-x],$x2[i-x]+10,$y2[i-x])COLOURED (0,255,255,150) style(line,3) //borne basse IB
    endif
    //If IBLines then
    //DRAWRAY ($x1[i-1],$y1[i-1],$x1[i-1]+10,$y1[i-1])COLOURED (0,255,255,150) style(line,3) //borne haute IB
    //DRAWRAY ($x2[i-1],$y2[i-1],$x2[i-1]+10,$y2[i-1])COLOURED (0,255,255,150) style(line,3) //borne basse IB
    //endif
    If ExtLines then
    DRAWRAY($x1[i-x],$y2[i-x]+b*($y2[i-x]-$y1[i-x]),$x1[i-x]+10,$y2[i-x]+b*($y2[i-x]-$y1[i-x]))COLOURED (255,50,0,150) style(line,3)
    DRAWRAY($x1[i-x],$y1[i-x]-b*($y2[i-x]-$y1[i-x]),$x1[i-x]+10,$y1[i-x]-b*($y2[i-x]-$y1[i-x]))COLOURED (255,50,0,150) style(line,3)
    endif
    next
    next
    next
    endif

    return //

    • Row trading • 31 days ago #

      Hi,
      to see the current day put : for y = i-1 to i-1 do
      to see all days put : for y = 1 to i do

  3. Razz • 31 days ago #

    Hi, thanks for your answer.
    I’ll keep an eye on the whole thing, I’ve now expanded it to include the 50% mark of the IB range

  4. Razz • 31 days ago #

    Adding an image did not work :

    https://www.directupload.eu/file/d/8765/3ez6bzlq_png.htm

avatar
Register or

Likes

avatar avatar avatar avatar avatar
Related users ' posts
Armand2020 Bonjour , super taf!! serait il possible de faire un poc dynamique en timeframe 5 min en mod...
philippe59139 voici ce qu'il faudrait faire ou ajouter: //poc dynamique defparam calculateonlastbars=1...
pouille Merci beaucoup vraiment beau boulot, j'adore je m'en sert régulièrement
Razz Bonjour Je pense que votre indicateur est très bon. Serait-il possible d'afficher la heatma...
philippe59139 if marketEtHeamap=1 then drawtext("#touch#",barindex+10,checkprice,SansSerif,Standard,10) c...
philippe59139 voici pour toi RAZZ il te faut simplement ajouter les drawtext https://www.prorealcode.com...
Bateson
1 year ago
larouedegann Amélioration du code ............................... Je trouvais assez frustrant d'attendre...
larouedegann if TIME=081500 then valeurhaute= highest[1](high) valeurbasse= lowest[1](low) milieu = v...
Nicolas 1. yes 2. maybe yes?! 3. why not?
patapouf Bonjour Nicolas. Je viens de découvrir cet indicateur, que je trouve bien intéressant Mais...
Nicolas Tu peux modifier le paramètre "scalefactor" pour adapter la hauteur des barres à ton graphiq...
otty82  all right. thanks
mmichael Hello, I noticed that the indicator shows the initial balance of today but also for all the ...
leyoy Bonjour, comment l'adapter sur 15 minutes au lieu de 1 heures ... j'ai changé 090000 par 081...

Top