NEED HELP!! Calling function by an array.

Back to topics list To post a new topic, please log in or register
avatar
10
tanim 2015.04.27 13:11
 
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.

please advice.

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++)
 
  {
    if((Buy_Lot_Count(Magic[i])>0)&&((Buy_Lot_Count(Magic[i]))==(Sell_Lot_Count(Magic[i])))) //here is the function call.
     
    { 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--) {
 OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
 if (!( OrderMagicNumber() >= magic&&OrderMagicNumber()<magic+100)) continue;
 if (OrderMagicNumber()>=magic && OrderMagicNumber() < magic+100)
 if (OrderType() == OP_SELL || OrderType() == OP_BUY) OrderCount++;
 }
 return (OrderCount);
 }
//-----------------------------------------------------------------------------//
 double Buy_Lot_Count(int Magic){
 
 double Buy_Lot=0;
 for(int i=OrdersTotal()-1;i>=0;i--){
 OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
 if (!( OrderMagicNumber() >= Magic&&OrderMagicNumber()<Magic+100)) continue;
 if ((OrderMagicNumber()>=Magic && OrderMagicNumber() < Magic+100)&&(OrderType()==OP_BUY))
 {Buy_Lot+=OrderLots();}}
 return (Buy_Lot);}
 
//---------------------------------------------------------------------------// 
 double Sell_Lot_Count(int Magic){
  
 double Sell_Lot=0;
 for(int i=OrdersTotal()-1;i>=0;i--){
 OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
 if (!( OrderMagicNumber() >= Magic&&OrderMagicNumber()<Magic+100)) continue;
 if ((OrderMagicNumber()>=Magic && OrderMagicNumber() < Magic+100)&&(OrderType()==OP_SELL))
 {Sell_Lot+=OrderLots();}}
 return (Sell_Lot);}

 

avatar
Moderator
3427
GumRai 2015.04.27 13:35 #
 

I got as far as

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

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

 

avatar
13009
WHRoeder 2015.04.27 14:10 #
 
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.
avatar
13009
WHRoeder 2015.04.27 23:02 #
 
Don't double post. You should have continued here.
Back to topics list  

To add comments, please log in or register