[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 429

 
Dimka-novitsek:

Good day!!! I must have misunderstood something about arrays or something. The function does not put a profit in the array!!! It's zero in all circumstances. Zero and that's it!

int Orderasthitaem[6][3];
void Orderasthitaem()
{
 int BUY = 0, SELL = 0, BUYLIMIT = 0, BUYSTOP = 0, SELLLIMIT = 0, SELLSTOP = 0;
 double BUY_Profit = 0, SELL_Profit = 0;
 for (int i = 0; i < OrdersTotal(); i++)
  {
   OrderSelect(i, SELECT_BY_POS);  
   if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magicnumber)
    {            
     int type = OrderType();
     if (type == 0) {BUY++; BUY_Profit = BUY_Profit + OrderProfit();}
     if (type == 1) {SELL ++; SELL_Profit = SELL_Profit + OrderProfit();}
     if (type == 2) {BUYLIMIT++;}
     if (type == 3) {SELLLIMIT++;}
     if (type == 4) {BUYSTOP++;}
     if (type == 5) {SELLSTOP++;}}}
       
     Orderasthitaem[0][1] = BUY;
     Orderasthitaem[0][2] = BUY_Profit;
     Orderasthitaem[1][1] = SELL;
     Orderasthitaem[1][2] = SELL_Profit;
     Orderasthitaem[2][1] = BUYLIMIT;
     Orderasthitaem[3][1] = SELLLIMIT;
     Orderasthitaem[4][1] = BUYSTOP;
     Orderasthitaem[5][1] = SELLSTOP;        
    }
  }
}
Function.

The obiagraph is outside all functions.

 
Thank you!!!
 

Why an array like int? What if the profits are fractional, but I don't think that's significant... Yes, apparently there's no need for a dowble!

I'll re-define it now and give it a try. But will it make a difference? Why didn't it work? I'll give it a try...

 
ruslanchik:
If the order ticket is stored on the broker's server, where are the majik and comment orders stored?

On the broker's server.
 
Ah, I see what you're assigning to array elements. Yeah, thanks!!!!!!!!
 
Hello, I am studying MQL4 tutorial by Sergey Kovalev and I have not found yet how to access time series arrays of other currency pairs. I.e., I need to load arrays of time series of several currency pairs into one EA. I know that some data can be accessed using the MarketInfo() function, but the problem is that the request IDs do not contain close or other parameters for price series. Please, advise where I can read how to organize work (if any) with arrays-timeseries and several instruments, or maybe how to circumvent this limitation.
 
I haven't actually compiled or tried anything yet, just looking at it. Takm, the point is that on exit from loops, BUY_Profit and prue variables values are not saved, right? The program is executed sequentially, or is it not saved?
 
Dimka-novitsek:
I haven't actually compiled or tried anything yet, just looking at it. Tuck, the point is that on exit of the loops, BUY_Profit and BUT values are not saved, right? The program is executed sequentially, or is it not saved?
Dimka-novitsek:
Ah, I see what you are assigning to array elements. Yep, thanks!!!!!!!!

Any type is possible. I just didn't notice that one of the variables is double. If you need double, put double.

Does it work?

 

I'm just looking. И... OOOOOOO!!!!!! I did it this way in mine, declared so Orderasthitaem[6][2]; in the element two arrays, that is you understood, and addressed already the third Orderasthitaem[0,2] !!!!!!!

Sure enough, here's the dog in the hole!!!!!!!!!!! OOO!!!

 
Dimka-novitsek:
I haven't actually compiled or tried anything yet, just looking at it. Takm, the point is that on exit of loops, BUY_Profit and prue variables values are not saved, right? The program is executed sequentially, or is it not saved?

...you could also do this:

double Orderasthitaem[6][2];
void Orderasthitaem()
{
    double ld_Profit = 0.;
    int li_Total = OrdersTotal();
    ArrayInitialize (Orderasthitaem, 0.);
    if (li_Total == 0) return;
    for (int i = 0; i < OrdersTotal(); i++)
    {
        OrderSelect (i, SELECT_BY_POS);  
        if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magicnumber)
        {            
            int type = OrderType();
            ld_Profit = OrderProfit();
            Orderasthitaem[type][0]++;
            if (type > 1) continue;
            Orderasthitaem[type][1] += ld_Profit;
        }
    }
}
- It depends on who you like.