can i find a error

To add comments, please log in or register
Ankit Jain
458
Ankit Jain  
int a[3,3];
a[3,2]=54;
Print(a[3,2]);
cant find a error in this..gives output 0;
Simon Gniadkowski
17271
Simon Gniadkowski  
ankit29030:
cant find a error in this..gives output 0;


Try . . .

int a[3][3];
Ankit Jain
458
Ankit Jain  
RaptorUK:


Tboth are same things written in documentation..tried that also

Simon Gniadkowski
17271
Simon Gniadkowski  

ankit29030:

Tboth are same things written in documentation..tried that also 



OK,  I see the problem . . .   a[3,2]  is not a valid cell in the array,  the 3 cells are at  0, 1 and 2.

So  . . .

int a[3][3];
a[2,1]=54;
Print(a[2,1]);
Ankit Jain
458
Ankit Jain  

i have made a 3-d array such that it contains the market order and pending order count of a specific symbol.....


for each symbol it calculates the market order and pending order...now how should i place values in this here is my code...

int start()
  {
  for(i=OrdersTotal()-1;i>=0;j--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
string osym=OrderSymbol();
for(j=OrdersTotal()-1;j>=0;j++)
{
OrderSelect(j,SELECT_BY_POS);
if(osym==OrderSymbol()&& (OrderType()==0 ||OrderType()==1))
mo++;
 if(osym==OrderSymbol() && (OrderType()==2 ||OrderType()==3||OrderType()==4||OrderType()==5))
 po++;
 }

//////////confusion here
ordertot[0][0][0]=0;
ordertot[0][00][00]=mo;
ordertot[0][10][11]=po;

}
Simon Gniadkowski
17271
Simon Gniadkowski  
ankit29030:

i have made a 3-d array such that it contains the market order and pending order count of a specific symbol.....


for each symbol it calculates the market order and pending order...now how should i place values in this here is my code...

So why do you need a 3D array ?
Ankit Jain
458
Ankit Jain  

like

 

            market order   pending order

eurusd           2                        1

usdjpy            4                        0

gbpjpy           4                         2

eurjpy            4                         0 

Ankit Jain
458
Ankit Jain  
this prints market order and pending order 0; acnt find why
int start()
  {
  for(i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
string osym=OrderSymbol();
//Print(osym);
for(j=OrdersTotal()-1;j>=0;j--)
{
OrderSelect(j,SELECT_BY_POS);
if((osym==OrderSymbol())&& (OrderType()==0 ||OrderType()==1))
//Print("dd");
mo++;
 if((osym==OrderSymbol()) && (OrderType()==2 ||OrderType()==3||OrderType()==4||OrderType()==5))
 po++;
 }

ordertot[i][0][0]=mo;
ordertot[i][0][1]=po;
}
for(a=OrdersTotal()-1;a>=0;a--)
{
OrderSelect(a,SELECT_BY_POS);
Print(OrderSymbol(),"   ",ordertot[a][0][0],"   ",ordertot[a,0,1]);
}
return;
Simon Gniadkowski
17271
Simon Gniadkowski  
ankit29030:

like

 

            market order   pending order

eurusd           2                        1

usdjpy            4                        0

gbpjpy           4                         2

eurjpy            4                         0 

So you don't need a 3D array,  you could simply use 3 x 1D arrays.
Simon Gniadkowski
17271
Simon Gniadkowski  
ankit29030:
this prints market order and pending order 0; acnt find why
You check the symbol in the i  loop  and then use that info in the  j  loop even though you will probably be looking at a different order . . .  why ?
Alain Verleyen
40770
Alain Verleyen  
RaptorUK:
So you don't need a 3D array,  you could simply use 3 x 1D arrays.


2 x 1D arrays no ? or 1 x 2D array.
123
To add comments, please log in or register