[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 470

 
tol64:

How do you optimise the multicurrency parameters? In the MT4 tester there's no possibility to test several symbols at once... I'm thinking about the multicurrency one and so far I've come to the idea that I optimize parameters for each symbol separately, and then I transfer all these parameters to my Expert Advisor in the multicurrency mode.

Am I moving in the right direction or it's easier in fact?)

In mql5 it all can be implemented in one EA for testing and trading, but for now I've decided to study mql4.

I've just thought that if you can't test some symbols at once, why bother with one EA if you can just set your own copy of each symbol chart and it will be the same. I would like to hear the opinions of the community members)))

I don't have a multicurrency, I just hang the same EA on each instrument.
 
Roman.:

reply
Sorry, didn't understand the answer
 
demlin:
Sorry, I do not understand the answer.

Search through google for "how to optimise a site:mql4.com": The following book is also available here: "how to optimize an Expert Advisor site:mql4.com", also here.

I recommend a good book on this subject: "Development, Testing and Optimization of Trading Systems for the Stock Trader" by Ralph Vince - all in details.

 

Problem: The figure shows a curve (e.g. MA). Points A,C,E are local maxima, and points B,D are local minima. Question: how do we calculate them if the distance between the nearest maximum and minimum is more than N points? I tried to do it, but it seems to be too cumbersome. Maybe there's a ready algorithm for solving such a problem? Please advise, if someone has experience of it.

 
Elenn:

Problem: The figure shows a curve (e.g. MA). Points A,C,E are local maxima, and points B,D are local minima. Question: how do we calculate them if the distance between the nearest maximum and minimum is more than N points? I tried to do it, but it seems to be too cumbersome. Maybe there's a ready algorithm for solving such a problem? Please advise, if anyone has experience of it.


Determining the direction of sliding.

If it is up and Variables B,C,D and E are empty, then we enter the current value of moving angle into Variable A.

If Variable A is not empty, and the sliding direction is downwards, and variables C,D,E are empty, then the current value of the sliding indicator is entered in Variable B. If variable A and variable B are not empty, and the moving average is pointing upwards, and variables D and E are empty, then variable C shall be populated with the current value of the moving average.

And so on, we fill in the values of the variables with values.

Now, if variable A and C are not empty, and if the modulus of difference between A and C is greater than or equal to a predefined number of points, then the action you have in mind will be executed.

Generally speaking, the code is quite possible. We only need to determine the point in the algorithm, at which we are going to reset the variables, so that the EA will realize that it has come to a new start point. The code can be written through a loop and arrays, and it may be less complex, but it's better to write the algorithm through variables in order to avoid confusion with array indexes and candlestick numbers in the loop.

 

Guys, recently came across this issue. Who's in the loop - comment on it. I've found the error myself - thank goodness - quickly... When writing code - everything compiles without errors, but trawl doesn't work... I.e., we don't go further in the order loop. Here are the code fragments... The bug was in the following - we gave orders magic in external variables, but in search of orders in the loop - with a capital letter, the search via CTRL+F - we were changing frommagic to requestingmagic... The compiler gave no error, but the program execution did not change to trawl mode in the loop... the loop would interrupt on "magic"... Is this supposed to be like this? I always thought "magic" and "magic" were different variables... and therefore the compiler should have indicated this error that the "magic" variable is undefined... In the code, as it is now executed before selecting trawl and Printa () no longer reaches - exit the loop on this condition - because of magic - i.e. this condition - will never be executed, due to different names - "magic" and "Magic".

if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != magic))
      {
         continue;
      }

// глоб переменные
...
...
extern int  Magic = 10;     // MagicNumber

//----------------------------------------------------------------------------
int start()                            // Спец. функция start
  {
  
   
   int orderCount = 0; 
  
   //---------------------------ТРАЛ ОРДЕРОВ---------------------------------------------------------------------------------------
   int orderType;
    for (orderIndex = (OrdersTotal() - 1); orderIndex >= 0; orderIndex--)
    {
      if (!OrderSelect(orderIndex, SELECT_BY_POS))
      {
         continue;
      }

      if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != magic))
      {
         continue;
      }

      orderType = OrderType();
      if ((orderType != OP_BUY) && (orderType != OP_SELL))
      {
         continue;
      }
                ticket = OrderTicket( );                         // Номер ордера
       double   orderLots = OrderLots();                         // Lots   
       double   orderProfit = OrderProfit() + OrderSwap();       // Profit
       double   Price = OrderOpenPrice();                        // Цена открытия рыночного ордера
       double   SL =  OrderStopLoss();                           // Значение StopLoss ордера
       double   TP = OrderTakeProfit();                          // Значение TakeProfit ордера
          
             if (ticket>0)                                               // Если позиция открылась
                    {
                             while(OrderSelect(ticket,SELECT_BY_TICKET)==false)       // Если ордер выбран
                                 {
                                   Sleep(100);
                                 }
                                  double OpenPrice=OrderOpenPrice();
                    }
                 
         
      orderCount++;                     // считаем ордера (не больше 10)
     
            
       while (!IsTradeAllowed() || !IsConnected()) Sleep(5000); RefreshRates();
       
      //----------------------------Тралим последовательно все наши ордера по виду трала------------------
      if (UseTrailing && orderCount > 0 && type ==0)   // простой трал по аналогии учебнику - в зависимости от параметра trlinloss (тралить ли в зоне лоссов)
          {     
           if (orderType == OP_BUY)  SampleTrailing_texbook (0);          // если бай
           if (orderType == OP_SELL) SampleTrailing_texbook (1);          // если селл
          }      
      ...
      ...
      ...   
     Print( "Эксперт база: Всего наших ордеров = " ,orderCount);
     }   
//--------------------------------------------------------------------------------------------------------------------------------------     
   
   
  
//----------------------------------------------------------------  
   return;                             // Выход из start()
  }

P.S. Who doesn't know about it - be aware of it, otherwise it's not clear how much you can do with the code...

 
Roman.:

Guys, recently came across this issue. Who's in the loop - comment on it. I've found the error myself - thank goodness - quickly... When writing code - everything compiles without errors, but trawl doesn't work... I.e., we don't go further in the order loop. Here are the code fragments... The bug was in the following - we gave orders magic in external variables, but in search of orders in the loop - with a capital letter, the search via CTRL+F - we were changing frommagic to requestingmagic... The compiler gave no error, but the program execution did not change to trawl mode in the loop... the loop would interrupt on "magic"... Is this supposed to be like this? I always thought "magic" and "magic" were different variables... and therefore the compiler should have indicated this error that the "magic" variable is undefined... In the code, as it is now executing before selecting trawl and Printa () no longer comes up - the exit from the loop on this condition - because ofmagic - i.e. this condition - will never be executed, due to different names - "magic" and "Magic".

P.S. Who doesn't know about it - be aware of it, otherwise you won't know how much you'll have to do with the code...


If magic is declared and magic is used, the compiler says that magic variable is not declared.

MetaEditor 4 401.

 
Roman.:

Guys, recently came across this issue. Who's in the loop - comment on it. I've found the error myself - thank goodness - quickly... When writing code - everything compiles without errors, but trawl doesn't work... I.e., we don't go further in the order loop. Here are the code fragments... The bug was in the following - we gave orders magic in external variables, but in search of orders in the loop - with a small letter, the search via CTRL + F - requesting "magic" was followed by "magic"... The compiler gave no error, but the program was not changed to trawl mode in the loop... the loop would interrupt on "magic"... Is this supposed to be like this? I always thought "magic" and "magic" were different variables... and therefore the compiler should have indicated this error that the "magic" variable is undefined... In the code, as it is now executing before selecting trawl and Printa () no longer comes up - the exit from the loop by this condition - because ofmagic - i.e. this condition - will never be executed, due to different names - "magic" and "Magic".

P.S. Who doesn't know about it - be aware of it, otherwise you won't understand how much you'll have to deal with code...

Compare with my simple trawl. In particular, it is a loop of search orders:

   // В глоб. переменных
   string sy=Symbol();
   // ...................................................................
   color  cl;
   double sl, StopLevel;
   for (int i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS)) {
         if (OrderSymbol()!=sy)           continue;
         if (OrderMagicNumber()!=Magic)   continue;
         if (OrderType()>1)               continue;
         sl=OrderStopLoss();
         if (OrderType()==OP_BUY) {
            cl=clModifyBuy;
            StopLevel=NormalizeDouble(strG-DeltaStop*PointX, dg);
            if (sl<StopLevel) ModifyOrder(-1, StopLevel, -1, -1, cl);
            }
         if (OrderType()==OP_SELL) {
            cl=clModifySell;
            StopLevel=NormalizeDouble(strR+DeltaStop*PointX, dg);
            if (sl>StopLevel) ModifyOrder(-1, StopLevel, -1, -1, cl);
            }
         }
      }

I think the principle will be clear to you.

And magic and magic variables are really different. When searching for them with Ctrl+F, check "case sensitive".

Somewhere in the code you did declare them both

 
artmedia70:

And magic and magic variables are really different. When searching for them with Ctrl+F, check the "case-sensitive" checkbox.

Somewhere in the code you declared them both after all

Exactly. Just found it thanks to you... :-))) At the bottom of Variables in addition to the variable extern int Magic = 10; I declared a variable -
int magic = 12345;

:-)))

It turned out I was taking into account Magic in the order opening fie and Magic in the loop, so the order loop for their trawl didn't work...:-)))

Thank you from the bottom of my heart - I have solved the issue. Checked "Use Register" - put it there and all is working properly.

P.S. How it happens!!! (When luck goes on the code - ready and not only a few majiks to declare...:-))))

 
artmedia70:

Compare this with my simplest trawl. Particularly the order search cycle:

I think the principle will be clear.

Thank you for the trawl option. The principle is clear.