Price Distribution Indicator Errors

Questions about MultiCharts and user contributed studies.
thehaul
Posts: 14
Joined: 15 Oct 2008

Price Distribution Indicator Errors

Postby thehaul » 28 Dec 2008

Having issues plotting this. It compiles fine in PLE but it gives an array bounds. wrong index value error. Any ideas??

thehaul
Posts: 14
Joined: 15 Oct 2008

Postby thehaul » 28 Dec 2008

Why can't I attach a pla file?

thehaul
Posts: 14
Joined: 15 Oct 2008

Postby thehaul » 28 Dec 2008

Here's the code.

[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: vol[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
vol[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
vol[ii] = v[ii] + 1;
end;
end;

{ find value area }
maxv = 0;
totv = 0;
for ii = ll * 10 to hh * 10 begin
totv = totv + v[ii - base];
if maxv < v[ii - base] then begin
maxv = 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 v[vhh + 1 - base] > v[vll - 1 - base] then begin
vhh = vhh + 1;
vmaxpc = vmaxpc + v[vhh - base];
end else begin
vll = vll - 1;
vmaxpc = vmaxpc + 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 = 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;

thehaul
Posts: 14
Joined: 15 Oct 2008

Postby thehaul » 28 Dec 2008

Here's the original TS code. I made some changes because it uses v in an array and v is already defined. So, i changed v to vol. That's probably where my issues are.
Attachments
PRICEDIST.ELA
(6.19 KiB) Downloaded 451 times

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

Postby Tresor » 29 Dec 2008

Try the link in the last post of this thread. I used to have the same problem

http://forum.tssupport.com/viewtopic.ph ... highlight=

thehaul
Posts: 14
Joined: 15 Oct 2008

Postby thehaul » 29 Dec 2008

Thanks for forwarding those posts! What did you increase the array_v to? I've tried a few and still getting an error.

thehaul
Posts: 14
Joined: 15 Oct 2008

Postby thehaul » 29 Dec 2008

My quote manager settings are 1/100th, min. movement 25 and big point value 50 for es.

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

Postby Tresor » 29 Dec 2008

Thanks for forwarding those posts! What did you increase the array_v to? I've tried a few and still getting an error.
Hi thehaul,

Kill me, I don't remember. But it was something like rather a million than a few thousand. I quit playing with Market Profile (I was not satisfied with the indicator) and put it on hold after reading this thread http://forum.tssupport.com/viewtopic.ph ... hlight=dom in which Marina suggested that MC might soon have a Market Profile built-in. So I am waiting :)

BTW, does your AGN data feed have daily Open Interest?

Regards

thehaul
Posts: 14
Joined: 15 Oct 2008

Postby thehaul » 29 Dec 2008

Thanks....It appears to have Open interest. MCs open interest indicator plots. Here's a pic.
Attachments
Screen capture 13.png
(199.01 KiB) Downloaded 532 times


Return to “MultiCharts”