Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 464

 
VOLDEMAR:

I can't solve the problem, I'm getting dull, and beer doesn't help.

I have:

1 - there are 30 EAs working on a chart or symbol and all have different Medgic number

2- Each EA has 3-5 open orders ...

The task is to print all numbers in a bar on a chart and total profit/loss on them ...

I am digging but not getting anywhere:

Good people help who can!!! )))))))


We create a two-dimensional array. In the first dimension we store the profit accumulated, in the second dimension we store the majik.

When processing orders, we look for a magic number in the array. If we don't find it, we increase the array, if we find it, we increase the profit.

After processing is completed, we display the result on the screen

 
Vinin:


Create a two-dimensional array. In the first dimension, we store the accumulated profit, and in the second dimension, we store the mejic.

When processing orders, we look for the orders in the array, if we don't find them, we increase the array, if we find them, we increase the profit.

After processing is completed, display the result on the screen


Isn't that what I have written?
 
VOLDEMAR:

Isn't that what it says?

Not exactly. Where you define the size of the array and search for an index on Magik. I didn't see that.
 
for(int f=OrdersTotal()-1; f>=0; f--) // order search
if(OrderSelect(f,SELECT_BY_POS))
{
for(int z=0; z<ArraySize(mags); z++)// second loop on the number of elements in the array
{
if(mags[z][MagicN]==OrderMagicNumber()) // if a MagicNumber already exists, let's add the profit
{
mags[z][MagProf]+=OrderProfit()+OrderCommission()+OrderSwap();
}
else /if there is no mag
{
ArrayResize(mags,z,1000); // expand array
mags[z][MagicN]=OrderMagicNumber(); // store the mag
}
}

}

But with this construct, the terminal won't test, it says critical error

 
VOLDEMAR:
for(int f=OrdersTotal()-1; f>=0; f--) // order search
if(OrderSelect(f,SELECT_BY_POS))
{
for(int z=0; z<ArraySize(mags); z++)// second loop on the number of elements in the array
{
if(mags[z][MagicN]==OrderMagicNumber()) // if a MagicNumber already exists, let's add the profit
{
mags[z][MagProf]+=OrderProfit()+OrderCommission()+OrderSwap();
}
else /if there is no mag
{
ArrayResize(mags,z,1000); // expand array
mags[z][MagicN]=OrderMagicNumber(); // store the mag
}
}

}

But with this construct, the terminal won't test, it says critical error


What is MagicN variable and where does it change?
 
in the definition has the parameter 0 and MagProf in the definition has the value 1
 
VOLDEMAR:
in the definition has a parameter 0 and MagProf in the definition has a value of 1


Try this

#define MagicN 0
#define MagProf 1
double mags[10][2];
int CountMagic=0;

void CalcMagic()
  {
   for(int f=OrdersTotal()-1; f>=0; f--) // перебор ордеров
      if(OrderSelect(f,SELECT_BY_POS))
        {
         mags[FindMaic(OrderMagicNumber())][MagProf]+=OrderProfit()+OrderCommission()+OrderSwap();
        }

  }
//+------------------------------------------------------------------+

int FindMaic(int Magic)
  {
   int Res=-1;
   for(int i=0;i<CountMagic;i++)
     {
      if(mags[i][MagicN]==Magic)
         Res=i;
      break;
     }
   if(Res==-1)
     {
      Res=CountMagic;
      CountMagic++;
      if(CountMagic>=ArrayRange(mags,0))
        {
         ArrayResize(mags,CountMagic+10);
        }

     }

   return(Res);
  }
//+------------------------------------------------------------------+

In multidimensional arrays, the dimensionality can be defined using ArrayRange()

 
There is a StopLetter and Freeswell which I can get through marketinfo, but there is the same restriction, but which concerns the minimum date of expiration, usually it is 15 minutes. That is, if I put a pending order, the minimum time after which it will self-delete, if not triggered, is 15 minutes. That's the question - how do I know this limit programmatically?
 
Desead:
There is a stopplay and freezevel that I can get through marketinfo, and there is the same restriction, but which concerns the minimum expiry date, usually it is 15 minutes. that is, if I put a pending order, the minimum time after which it will self-delete, if not triggered, is 15 minutes. That's the question - how do I know this limit programmatically?

Ask your broker! Some do not execute an expiry.

I do not put it in an order but I remove it according to the terms.

 

Hello. I have recently started studying MQL4 and came across the following misunderstanding.

As you can see in the example below, when the highest candle in the bar reaches 1.3058, the order should close. The order is closed according to the conditions but the close price is not 1.3058(it might be 1-3 pips higher). So, how do we close correctly? Does it closeat 1.3058?

if(High[0] >= 1.3058)

OrderClose( OrderTicket(), OrderLots(),  NormalizeDouble(Ask,Digits), 0, Red) ;
Reason: