# NEED HELP!! Calling function by an array.

37

hello,good evening.

i need to call a function with an array.
the functions count buylot,selllot.and the array
is for a set of different magic number.

what i did was, Function_1(ARRAY_1[i]);but it doesnt seems to work.

```Global Declearation.

int Free_Magic[4];
int Magic[8];
int Standby_Magic;
int Hedged_Magic[4];

initialization.

Magic[0]=123000;
Magic[1]=234000;
Magic[2]=345000;
Magic[3]=456000;
Magic[4]=500000;
Magic[5]=600000;
Magic[6]=700000;
Magic[7]=800000;

start()

int counter;
int i;
for(i=0;i<=7;i++)

{
if((OrdersTotalMagic(Magic[i])==0))

{ Free_Magic[counter]=Magic[i];

counter++;
if(counter>3)break;}}

Standby_Magic=Free_Magic[0];

GlobalVariableSet(Stand_Magic,Standby_Magic);
int xxx=OrdersTotalMagicOpen(Free_Magic[0]);
Print("AAA====",xxx);
counter=0;
for(i=0;i<=7;i++)

{

{ Hedged_Magic[counter]=Magic[i];
Print("Tanim");

counter++;
if(counter>3)break;}}

Print("AAA====",Hedged_Magic[0]);

Order_Modify(Hedged_Magic[i]);

}
// end start.//--------------------------------------------------------------------------//

int OrdersTotalMagicOpen(int magic) {

int OrderCount = 0;
for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
if (!( OrderMagicNumber() >= magic&&OrderMagicNumber()<magic+100)) continue;
if (OrderMagicNumber()>=magic && OrderMagicNumber() < magic+100)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) OrderCount++;
}
return (OrderCount);
}
//-----------------------------------------------------------------------------//

for(int i=OrdersTotal()-1;i>=0;i--){
if (!( OrderMagicNumber() >= Magic&&OrderMagicNumber()<Magic+100)) continue;
if ((OrderMagicNumber()>=Magic && OrderMagicNumber() < Magic+100)&&(OrderType()==OP_BUY))

//---------------------------------------------------------------------------//
double Sell_Lot_Count(int Magic){

double Sell_Lot=0;
for(int i=OrdersTotal()-1;i>=0;i--){
if (!( OrderMagicNumber() >= Magic&&OrderMagicNumber()<Magic+100)) continue;
if ((OrderMagicNumber()>=Magic && OrderMagicNumber() < Magic+100)&&(OrderType()==OP_SELL))
{Sell_Lot+=OrderLots();}}
return (Sell_Lot);}```

Moderator
10614

I got as far as

`    if((OrdersTotalMagic(Magic[i])==0))`

and as this function is not shown, no point in continuing

16105

tanim: i need to call a function with an array.
what i did was, Function_1(ARRAY_1[i]);but it doesnt seems to work.
1. I didn't even get that far. If ARRAY_1 is a int array then ARRAY_1[i] is an int and "what i did was" Function_1(anInt)
2. ```Global Declearation.

int Free_Magic[4];
int Magic[8];
int Standby_Magic;
int Hedged_Magic[4];

initialization.

Magic[0]=123000;
Magic[1]=234000;
Magic[2]=345000;
Magic[3]=456000;
Magic[4]=500000;
Magic[5]=600000;
Magic[6]=700000;
Magic[7]=800000;

start()
```
Don't post code what won't even compile.
3. Initializing arrays with constants is easy:
```// Global Declearation.

int Free_Magic[4];
int Magic[8]={123000, 234000, 345000, 456000,
500000, 600000, 700000, 800000};

int Standby_Magic;
int Hedged_Magic[4];

start(){
```
4. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
16105

Don't double post. You should have continued here.