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 😉
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
defparam drawonlastbaronly=true 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 //start = 160000 //US si trading US, activer ces horaires là et désactiver ceux du dax //end = 163000 //US tc = time>=start and time<end n = 5 //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]) 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 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) //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) 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 DRAWRAY($x1[i-1],$y2[i-1]+b*($y2[i-1]-$y1[i-1]),$x1[i-1]+10,$y2[i-1]+b*($y2[i-1]-$y1[i-1]))COLOURED (255,50,0,150) style(line,3) DRAWRAY($x1[i-1],$y1[i-1]-b*($y2[i-1]-$y1[i-1]),$x1[i-1]+10,$y1[i-1]-b*($y2[i-1]-$y1[i-1]))COLOURED (255,50,0,150) style(line,3) next next next endif return // |
Share this
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 :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
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
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 //
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
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
Adding an image did not work :
https://www.directupload.eu/file/d/8765/3ez6bzlq_png.htm