How to plot Daily Volume Histogram and Peak Volume Price?

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 51 times

How to plot Daily Volume Histogram and Peak Volume Price?

Postby Tresor » 10 Sep 2008

Hello Guys,

Could a kind sould tell me what I should do to make my MC display Daily Volume Histogram separately for each session + how to plot the Peak Volume Price, as shown in the attached screenshot please?

Peak Volume Price = the price which has the most trading volume. PVP is dynamic and can change throughout the session.

Cheers
Attachments
Daily Volume Histogram and Peak Volume Price.png
Daily Volume Histogram and Peak Volume Price.png (29.07 KiB) Viewed 1086 times

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 26 Sep 2008

Hi Tresor,

There was an indicator that did the job somewhere in TS forums. I'd recommend searching there.

Regards.

User avatar
TJ
Posts: 7178
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: How to plot Daily Volume Histogram and Peak Volume Price

Postby TJ » 26 Sep 2008

Hello Guys,
Cheers
Search for Market Profile. I think they have something similar to what you are looking for.

Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 51 times

Re: How to plot Daily Volume Histogram and Peak Volume Price

Postby Tresor » 26 Sep 2008

Search for Market Profile. I think they have something similar to what you are looking for.
Thanks TJ,

Market Profile is indeed what I was looking for but didn't know the name of it. When one knows the name it is much easier to find.

Could someone experienced in coding look here: http://www.traders2traders.com/code&ove ... togram.htm

and possibly debug the code to work in MC?

Regards

User avatar
TJ
Posts: 7178
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: How to plot Daily Volume Histogram and Peak Volume Price

Postby TJ » 26 Sep 2008

Could someone experienced in coding look here: http://www.traders2traders.com/code&ove ... togram.htm
and possibly debug the code to work in MC?
Regards

Code: Select all

[LegacyColorValue = TRUE];

input: date1(0), time1(930), time2(1600), HistColor(darkgray), ValueArea(.6), ValueColor(blue);
input: EveryMins(15), MinsBack(15);
input: ShoHist(true);

{ This displays price histograms EveryMins. The lookback period is MinsBack.

It works for both minute and tick bars, even 1-tick bars. Try with S&P 1-minute bars
or S&P 1-tick bars.

Inputs:
date1 - draws histrograms for this date; all date if its 0
time1, time2 - draws histograms within this date range
HistColor - the color of the histogram
ValueColor - the color of the value area
ValueArea - portion of the prices that will be colored; range 0 to 1
EveryMins - draw a histogram every, say, 15 minutes
MinsBack - how far back to analyze prices, typically the same as EveryMins
ShoHist - if false, just the value area is plotted like a bar
}

array: array_v[5000](0);
var: base(10000);

var: ii(0), ij(0), hh(0), ll(0), cbStart(0), bb(0), maxv(0), han1(0), m1(0), m2(0);
var: mins(0), cb(0), cbPrev(0), targ(0), Sanity(false);
var: iivmax(0), totv(0), vmaxpc(0), vhh(0),vll(0), loop(0);

if currentbar = 1 then begin
hh = h;
ll = l;
end;
mins = EveryMins*intportion(timetominutes(time)/EveryMins);

if (date1 = date or date1 = 0) and ((time >= time1 and time <= time2) or time1 = 0 or time2 = 0) and
mins <> mins[1] then begin

{ plot1(c,"",red,default,5);}

{ clear v array }
for ii = ll * 10 - base to hh * 10 - base begin
array_v[ii] = 0;
end;

{ find start of interval }
cb = 0;
Sanity = true;
targ = timetominutes(time) - MinsBack;
while targ <= timetominutes(time[cb]) and Sanity begin
cb = cb+1;
if cb >= currentbar then Sanity = false;
if date[cb] <> date then Sanity = false;
if cb > 1000 then Sanity = false;
end;
cb = cb - 1;

{ add bars to list }
hh = h;
ll = l;
for ij = cb - 1 downto 0 begin
m1 = l[ij];
m2 = h[ij];
if hh < m2 then hh = m2;
if ll > m1 then ll = m1;
if m1 > c[ij+1] + .10 then m1 = c[ij+1] + .10
else if m2 < c[ij+1] - .10 then m2 = c[ij+1] - .10;
for ii = m1 * 10 - base to m2 * 10 - base begin
array_v[ii] = array_v[ii] + 1;
end;
end;

{ find value area }
maxv = 0;
totv = 0;
for ii = ll * 10 to hh * 10 begin
totv = totv + array_v[ii - base];
if maxv < array_v[ii - base] then begin
maxv = array_v[ii - base];
iivmax = ii;
end;
end;
vmaxpc = maxv;
vhh = iivmax;
vll = iivmax;
sanity = true;
loop = 0;
if maxV > 0 then
while sanity and vmaxpc / totv < ValueArea begin
loop = loop + 1;
if loop > 50 then sanity = false;
if array_v[vhh + 1 - base] > array_v[vll - 1 - base] then begin
vhh = vhh + 1;
vmaxpc = vmaxpc + array_v[vhh - base];
end else begin
vll = vll - 1;
vmaxpc = vmaxpc + array_v[vll - base];
end;
end;



{ display the list }
if ShoHist then
for ii = ll * 10 to hh * 10 begin
if maxV > 0 then begin
bb = array_v[ii - base] * (currentbar - cbPrev) / maxV;
if time[bb] <> time then begin
han1 = tl_new(date[bb],time[bb],ii*.1,date,time,ii*.1);
tl_setextleft(han1,false);
tl_setextright(han1,false);
tl_setcolor(han1,HistColor);
if ii >= vll and ii <= vhh then tl_setcolor(han1,ValueColor);
if ii = iivmax then tl_setcolor(han1,cyan);
end;
end;
end;
{ plot2(iivmax*.1,"",cyan,default,4);}
plot3(vhh*.1,"",ValueColor,default,0);
plot4(vll*.1,"",ValueColor,default,0);
cbPrev = currentbar;
end;





if false then begin
plot1(0,"");
plot2(0,"");
plot3(0,"");
plot4(0,"");
end;

Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 51 times

Postby Tresor » 27 Sep 2008

Thanks TJ,

It compiles perfectly :)

Would you have an idea why I get the error as shown in the screenshot?

Regards
Attachments
PriceDistributionError.jpg
PriceDistributionError.jpg (147.25 KiB) Viewed 1035 times

Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 51 times

Postby Tresor » 27 Sep 2008

Hi again,

I increased the array_v as suggested in this thread:

http://forum.tssupport.com/viewtopic.ph ... sc&start=0

The study now seems to work.

Thanks


Return to “User Contributed Studies and Indicator Library”