Multicurrency advisor question - page 4

 

OK, VassaV, got it !

Here is another question. In the usual code, when a position is opened, it is shown:

//---------проверяем условие на покупку----------------------------
  if   ( бла-бла-бла  )
   {
  Lots=GetSizeLot(); 
  ticket=OrderSend("GBPUSD",0,Lots,Ask,Slippage,Bid-SL_long*Point,Ask+TP_long*Point,
                                                         "мульти",MagicNum,0,CLR_NONE);
  if    (ticket<0) { Print("Ошибка открытия ордера BUY #", GetLastError()); return (0); }  
 ... ... ...

Here we have "ticket" value. In my EA, the scheme is somewhat different, like this:

if (GBP) {     //если  "выключатель" включен
if (!ExpertOrder(MagicGBP)) { //если ордеров по паре GBPUSD нет
 
//-------Проверяем условие на покупку-------------
if  (    бла-бла-бла     )
    {  
  //---- Цикл открытия ордера  -------------------------------------------                      
int Cnt=1;
  while (Cnt <= 5) 
  { //-----покупаем--------------
    Lots=GetSizeLot();
   if (OrderSend("GBPUSD",OP_BUY,Lots,ask_GBP,3,bid_GBP - sl_GBPUSD_long*point_GBP,
           ask_GBP+tp_GBPUSD_long*point_GBP,"M_1", MagicGBP, 0, Blue) > 0)  break;    
    else 
{ Print ("Ошибка открытия Buy #", ErrorDescription( GetLastError() ),
                                                  " попытка ", Cnt);
                               
        if (Cnt==5) return(0);  //если за 5 попыток не закрыли - выходим
        Cnt++;
        Sleep(15000); // ждём 15 секунд
      }   
    }
  }

But I also need the "ticket" value! For this pair. I can't do it all morning! Who knows, - Please, tell me how?

 

To all those who wanted advice but didn't have time to respond, thank you!

I think I've worked it out myself (this afternoon). It goes like this:

 //---- Цикл открытия ордера  -------------------------------------------                      
int Cnt=1;
  while (Cnt <= 5) 
  { //-----покупаем--------------
    Lots=GetSizeLot();
   ticketGBP = OrderSend("GBPUSD",OP_BUY,Lots,ask_GBP,3,bid_GBP - sl_GBPUSD_long*point_GBP,
           ask_GBP+tp_GBPUSD_long*point_GBP,"M_1", MagicGBP, 0, Blue);
         if (ticketGBP > 0)  break;    
    else 
{ Print ("Ошибка открытия Buy #", ErrorDescription( GetLastError() ),
                                                  " попытка ", Cnt);
                               
        if (Cnt==5) return(0);  //если за 5 попыток не закрыли - выходим
        Cnt++;
        Sleep(15000); // ждём 15 секунд
      }
 

The condition of testing the Expert Advisor for 5 minutes at the Championship, and only 3 weeks before the end of the term, was almost a BEGINNING for everyone !

Individually, my Expert Advisor is tested on the history of 12 months on one pair, - no more than 3-4 minutes. It works on all ticks.

But when I unite several EAs into one - multicurrency EA, testing time increases up to 7-10 minutes !

And I disable all pairs except one which I run.

I want to ask professionals (and not only) to share their experience and ways to decrease testing time.

Expert Advisor structure is as follows:

 
//---- input parameters---------
 
ЗАДАЕМ ВНЕШНИЕ ПАРАМЕТРЫ ПО КАЖДОЙ ПАРЕ
 
int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }
 
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  { 
 
//*********************************************************************
 
double ЗАДАЕМ ПЕРЕМЕННЫЕ ПО ПЕРВОЙ ПАРЕ 
double ЗАДАЕМ ПЕРЕМЕННЫЕ ПО ВТОРОЙ ПАРЕ
... ... ... ...
double ЗАДАЕМ ПЕРЕМЕННЫЕ ПО ПОСЛЕДНЕЙ ПАРЕ
 
 =========================================================
 
int Orders=OrdersTotal ();     //получаем кол-во открытых ордеров
if (Orders<3)                 //если  открытых ордеров <3
  { 
if (выключатель 1 вкл) {ОТКРЫВАЕМ ПЕРВУЮ ПАРУ } 
if (выключатель 2 вкл) {ОТКРЫВАЕМ ВТОРУЮ ПАРУ } 
... ... ... 
if (выключатель N вкл) {ОТКРЫВАЕМ ПОСЛЕДНЮЮ ПАРУ }  
  }
//========================================================================
for (int x=0; x<OrdersTotal(); x++)                                             {
    if (OrderSelect(x, SELECT_BY_POS, MODE_TRADES)) 
{       
if (UseTrailing 1) - ТРЕЙЛИНГ ПЕРВОЙ ПАРЫ
... ... ...
if (UseTrailing N) - Трейлинг последней пары
}
//======================================================================
   return(0);
  }
 
rid:

The condition of testing the Expert Advisor for 5 minutes in the Championship in just 3 weeks before the end of the period has almost been a BEGINNING for everyone!

Individually my Expert Advisor is tested on the history of 12 months on one pair - no more than 3-4 minutes. It works on all ticks.

But when I unite several EAs into one - multicurrency EA, testing time increases up to 7-10 minutes!

And I disable all pairs except one - which I am testing.

I want to ask specialists (and not only) to share their approaches and ways to decrease testing time.

Expert Advisor structure is like this:

 
//---- input parameters---------
 
ЗАДАЕМ ВНЕШНИЕ ПАРАМЕТРЫ ПО КАЖДОЙ ПАРЕ
 
int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }
 
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  { 
 
//*********************************************************************
 
double ЗАДАЕМ ПЕРЕМЕННЫЕ ПО ПЕРВОЙ ПАРЕ 
double ЗАДАЕМ ПЕРЕМЕННЫЕ ПО ВТОРОЙ ПАРЕ
... ... ... ...
double ЗАДАЕМ ПЕРЕМЕННЫЕ ПО ПОСЛЕДНЕЙ ПАРЕ
 
 =========================================================
 
int Orders=OrdersTotal ();     //получаем кол-во открытых ордеров
if (Orders<3)                 //если  открытых ордеров <3
  { 
if (выключатель 1 вкл) {ОТКРЫВАЕМ ПЕРВУЮ ПАРУ } 
if (выключатель 2 вкл) {ОТКРЫВАЕМ ВТОРУЮ ПАРУ } 
... ... ... 
if (выключатель N вкл) {ОТКРЫВАЕМ ПОСЛЕДНЮЮ ПАРУ }  
  }
//========================================================================
for (int x=0; x<OrdersTotal(); x++)                                             {
    if (OrderSelect(x, SELECT_BY_POS, MODE_TRADES)) 
{       
if (UseTrailing 1) - ТРЕЙЛИНГ ПЕРВОЙ ПАРЫ
... ... ...
if (UseTrailing N) - Трейлинг последней пары
}
//======================================================================
   return(0);
  }

it is tested slowly, mainly due to the indicators

they are not visible in this structure, but you most likely have them, otherwise they would take a minute maximum for testing.

The indicators have to be changed or moved to the code in the EA.

 

Loky,

Did I understand you correctly?

My indicators are where I set the variables. And apparently they

double ЗАДАЕМ ПЕРЕМЕННЫЕ (индикаторов) ПО ПЕРВОЙ ПАРЕ

should probably be moved inside in

if (выключатель 1 вкл) {ОТКРЫВАЕМ ПЕРВУЮ ПАРУ }

for each pair accordingly?

 
Take a look at Prototype-IX as an example. An example of a multi-currency Expert Advisor.

It allows you to test on any of 12 currency pairs, and on several timeframes.
15:18:05 ProtoType-IX inputs: EMN=10000; Slippage=3; RiskDelta=5; PeriodWPR=8; CriteriaWPR=25; ATRPeriod=40; kATR=0.5; ZeroBar=8; MinTargetinSpread=5; TP_SL_Criteria=2; MaxOpenedOrders=3; MaxOrderSize=5; <br / translate="no"> 15:18:05 2006.10.17 09:38 ProtoType-IX EURUSD,M15: indexPeriod=2 PeriodTesting=15 Symbol index=3 SymbolTesting=EURUSD
15:18:05 2006.10.17 09:38 NRTR_GATOR EURUSD,M15: loaded successfully
15:18:09 2006.10.17 09:38 NRTR_GATOR EURUSD,M30: loaded successfully
15:18:09 2006.10.17 09:38 NRTR_GATOR EURUSD,H1: loaded successfully
15:18:09 2006.10.17 09:38 NRTR_GATOR EURUSD,H4: loaded successfully
15:18:09 2006.10.17 09:38 NRTR_GATOR EURUSD,Daily: loaded successfully
15:18:09 2007.01.02 00:00 NRTR_GATOR EURUSD,M30: Attention, trend is not defined. Bar from the end of 4
15:18:09 2007.01.02 00 00:00 NRTR_GATOR EURUSD,M30: Warning! Trend is not defined, it cannot be
15:18:09 2007.01.02 00:00 NRTR_GATOR EURUSD,H1: Warning! Trend is not defined, it cannot be. Bar from the end of 1
15:18:09 2007.01.02 00:00 NRTR_GATOR EURUSD,H1: Warning! Trend is not defined, it cannot be
......................................

15:18:23 2007.08.17 22:17 Tester: stop loss #242 at 1.3483 (1.3483 / 1.3485)
15:18:23 2007.08.17 22:59 NRTR_GATOR EURUSD,Daily: removed
15:18:23 2007.08.17 22:59 NRTR_GATOR EURUSD,H4: removed
15:18:23 2007.08.17 22:59 NRTR_GATOR EURUSD,H1: removed
15:18:23 2007.08.17 22:59 NRTR_GATOR EURUSD,M30: removed
15:18:23 2007.08.17 22:59 ProtoType-IX EURUSD,M15: Testing completed


It took 18 seconds to test on 15 minutes in the "Every ticks" model.
 

Thank you to those who responded to the question. Things are clearing up gradually. Tucked the turkeys inside. And now the limit is met.

Rosh, - tried a dozen times already to approach the expert named by you. But... every time I've backed off... With my modest knowledge I still cannot grasp the code and its structure. I am confused and am not quite sure where to start and how to structure its research. There are many uncertainties, and I cannot get to everything at once. I begin to understand everything and soon I stop to think - where I started and what for ...

And taking this opportunity, I have a question about the article "Example of creating an Expert Advisor" ^

 
klerk:
the principle of multicurrency Expert Advisor is approximately as follows:
1. in the calculation of indicators to specify specific currencies and time intervals, for example: iRSI("GBPUSD",60,GBPUSD_period,3,3,MODE_SMA,0,MODE_MAIN,i); //but here is an error
2. obtain prices, points, etc. using MarketInfo.
3. use iLow(...) instead of Low[0] for example
and apply to all currency pairs.
Good luck.
The only inconvenience is that all symbols traded must have open charts with their timeframes.

If charts are not open, or they are opened with different timeframes than used, you have to constantly perform

Checks on every sneeze - even iRSI may not work ... until the terminal swap ...

Respectfully - S.D.
 

In online, I set in the Expert Advisor (in the indices) timef=1 min (to check the performance) on all pairs.

And I put it on the chart of the first pair on the timef=1 min. But on other pairs of the EA the timeframe is often different. And nevertheless the EA operates on all pairs exactly in terms of timef-minutes, as it is implemented in the code!

Or maybe I didn't understand you correctly?

 
klerk:
The principle of the multi-currency Expert Advisor is as follows:
1. specify specific currencies and time intervals in the calculation of indicators, for example: iRSI("GBPUSD",60,GBPUSD_period,3,3,MODE_SMA,0,MODE_MAIN,i); //but here is an error
2. obtain prices, points, etc. using MarketInfo.
3. use iLow(...) instead of Low[0] for example
and
write it on all currency pairs.
Good luck.


Could you please tell me if the substitution of the construction will be correct:

H=High[iHighest("USDJPY", PERIOD_H4, MODE_HIGH, 50, 1)];

in multicurrency Expert Advisor code when working on someone else's instrument on such one:

double H_current, H_previous;
H_current=0; H_previous=0;
 
for (int n=1; n<51; n++)
  {
    H_previous=H_current;
    H_current=iHigh("USDJPY", PERIOD_H4, n);
    H=MathMax(H_previous, H_current);
  }

If not, please advise what is the error and how to do it correctly?

Thank you in advance.

Reason: