Aggregated Bid Ask on Chart

Questions about MultiCharts and user contributed studies.
aczk
Posts: 67
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Aggregated Bid Ask on Chart

Postby aczk » 05 Mar 2014

Hi

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);


appreciate any help & I think it would be a cool indicator to include in MC anyway

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1527 times
Been thanked: 1502 times
Contact:

Re: Aggregated Bid Ask on Chart

Postby JoshM » 08 Mar 2014

aczk wrote: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.


Code: Select all

///////////////// add up DOM asks
   value3 =    ((dom_asksize(0) )+(dom_asksize(1) )+(dom_asksize(2) )+
         (dom_asksize(3) )+(dom_asksize(4) ));


Try filtering with the dom_askscount reserved word. You already use this word in your loops, but when you're using the `dom_asksize` directly, you don't check beforehand if there are really five levels available.

SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

Re: Aggregated Bid Ask on Chart

Postby SP » 08 Mar 2014

I posted a solution here some months ago for the whole DOM, you need to delete the parts you dont need.

Image
Attachments
DOM.pla
(16.12 KiB) Downloaded 181 times
These users thanked the author SP for the post:
MAtricks

SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

Re: Aggregated Bid Ask on Chart

Postby SP » 08 Mar 2014

Cleanup Version
Attachments
DomSum.pla
(16.17 KiB) Downloaded 234 times
These users thanked the author SP for the post:
MAtricks

aczk
Posts: 67
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Aggregated Bid Ask on Chart

Postby aczk » 09 Mar 2014

this is perfect thanks!!!!!!!!!!!!!

aczk
Posts: 67
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Aggregated Bid Ask on Chart

Postby aczk » 11 Mar 2014

There is a little bug in the code, the lines sometimes remain on the chart after more frantic order book action. Have you got the same issue on your chart,

thx


Return to “MultiCharts”