Really like the Market Depth on chart indicator.
I also want to plot the aggregated Bid & Ask in the same fashion. I saw it is available on the DOM now.
Gave it a try, but I always get the "STD exception: invalid argument" error when using "dom_asksize" directly without having it in a loop. So I tried an array with the "SummationArray", but that yields a wrong value.
here is my code so far:
Code: Select all
[RecoverDrawings = false];
if not LastBarOnChart_s then #return;
Inputs: UpdateSpeed_seconds(0.1),TLsizer(1),
textcol(white),offset(3),textsize(10);
RecalcLastBarAfter(UpdateSpeed_seconds);
repeat
if not dom_isconnected then
break;
//////////////////////
array: bidarray[5](-1);
//////////////////////
value11 = 0;
value12 = 0;
for value1 = 0 to dom_askscount - 1 begin
value12 = dom_asksize(value1);
if value12 > value11 then value11 = value12;
end;
for value1 = 0 to dom_bidscount - 1 begin
value12 = dom_bidsize(value1);
if value12 > value11 then value11 = value12;
end;
if 0 >= value11 then
break;
///////////////// add up DOM asks
value3 = ((dom_asksize(0) )+(dom_asksize(1) )+(dom_asksize(2) )+
(dom_asksize(3) )+(dom_asksize(4) ));
/////////////////
for value1 = 0 to dom_askscount - 1 begin
draw_DOM_cum( dom_askprice(3)+offset, value3, value1, value11,
white, dom_askscount - 1 = value1,textsize);
end;
////////////////////////////////////////////////////////////////////////////////////////////
///////////////// add up DOM bids
for value1 = 0 to dom_bidscount - 1 begin
bidarray[value1]= dom_bidsize(value1);
end;
value2 = SummationArray(bidarray,5);
//value2 = ((dom_bidsize(0) )+(dom_bidsize(1) )+(dom_bidsize(2) )+
// (dom_bidsize(3) )+(dom_bidsize(4) ));
////////////////
for value1 = 0 to dom_bidscount - 1 begin
draw_DOM_cum( dom_bidprice(3)-offset,value2, value1, value11,
white, dom_bidscount - 1 = value1,textsize);
end;
plot1("OK", "Status", white);
#return;
until(False);
plot1("Level2 data is not avaliable", "Status", red);