HELP NEEDED !! problem with array.

Back to topics list To post a new topic, please log in or register
avatar
10
tanim 2015.04.27 17:42
 
hello,good evening.

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

what i did was,Use" Function_1(ARRAY_1[i]); "formate/syntax;but it seems OrdersTotal function call is working.
as i am getting the result for Free_Magic[0],345000.which is true as 123000,234000 are allready hedged. 


but buylot,selllot count function is not,as i didnt get result of Hedged_Magic[0] while printing.pls see image.

please advice.

 

//+------------------------------------------------------------------+
//|      Close order break even                     Md. Tanim Hoque  |
//+------------------------------------------------------------------+
#property copyright "TANIM Hoque"
#property link      "tofazzle1972jbp@gmail.com"

#include <stderror.mqh> 

//+------------------------------------------------------------------+
//| Expert User Inputs                                               |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Global Variables / Includes                                      |
//+------------------------------------------------------------------+

string mySymbol;

int    SymDigits    = 5;
double SymPoints    = 0.0001;

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

int Standby_Magic;
int Hedged_Magic[4];

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
   //---
        if( SymPoints == 0.001   ) { SymPoints = 0.01;   SymDigits = 3; }
   else if( SymPoints == 0.00001 ) { SymPoints = 0.0001; SymDigits = 5; }

   //----
   return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() { return(0); }

//+------------------------------------------------------------------+
//| Expert start function                                            |
//+------------------------------------------------------------------+
int start()
{  
//----------------------------------------------------------------------------------//
int counter;
int i;
for(i=0;i<=7;i++)                       // this Part Working ;
                                        // print result =345000;
  {                                     // 123000,234000 allready Hedged.
    if((OrdersTotalMagic(Magic[i])==0)) //
                                        //pls see screenshot.
    { Free_Magic[counter]=Magic[i];
      
      
      counter++;
      if(counter>3)break;}}
   
 Standby_Magic=Free_Magic[0]; 
 Print("aa==",Free_Magic[0]);  // print result=345000; 
counter=0;
//-----------------------------------------------------------------------------------//
for(i=0;i<=7;i++)                                         //
                                                          //this part doesnt work.
{                                                         //print result =0;
if((Buy_Lot_Count(Magic[i])>0)&&((Buy_Lot_Count(Magic[i]))==(Sell_Lot_Count(Magic[i])))) //to avoid 0==0.
                                                          //
    { Hedged_Magic[counter]=Magic[i];                     //
                                                          //pls see image/screenshot.
      counter++;
      if(counter>3)break;}}  

 Print("HHH===",Hedged_Magic[0]);//  print result 0, 
 
 Order_Modify(Hedged_Magic[i]);
 
 }
//--------------------------------------------------------------------//          
 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);
 }     
//-----------------------------------------------------------------------------//      
 int OrdersTotalMagic(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))
 { 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);}
//-----------------------------------------------------------------------------------//
void Order_Modify(int magic)
{
 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)) 
   {
    bool res= OrderModify(OrderTicket(),OrderOpenPrice(),0,0,0,clrYellow);
         if(!res)
           Print("Error in OrderModify. Error code=",GetLastError());
         else
           Print("Order modified successfully.");}}}

//+-----------------------------------END-------------------------------+//




  

 

avatar
13012
WHRoeder 2015.04.27 23:07 #
 
  1. Don't double post. You should have continued your original post.
  2. Perhaps you are using a mechanical translation. Whatever, your text was unintelligible.
Back to topics list  

To add comments, please log in or register