Multicurrency advisor question

 

Good evening!

I am thinking of combining two pairs into one EA. I have done it.

But suddenly I had doubts. I did it like this:

extern bool    GBP=true;
extern bool    EUR=true;
- - - - - - - - - - - - - - - - - - - -
int start()
  {
double A = iRSI("GBPUSD", 0, .....);
double B = iRSI("GBPUSD", 0, .....);
 
double C = iRSI("EURUSD", 0, .....);
double D = iRSI("EURUSD", 0, .....);
//------------------------------------------------------
if (GBP) {//если есть разрешение true
if (A<B)
{
double   BID = MarketInfo("GBPUSD", MODE_BID);
 double   ASK = MarketInfo("GBPUSD", MODE_ASK);
 double POINT =MarketInfo("GBPUSD",MODE_POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)     }}}
//----------------------------------------------------------  
if (EUR) { //если есть разрешение true
if (C>D)
{
double   BID = MarketInfo("EURUSD", MODE____BID);
 double   ASK = MarketInfo("EURUSD", MODE____ASK);
 double POINT =MarketInfo("EURUSD",MODE____POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)      }}}
//------------------------------------------------------------
return(0);  
  }

In online and in the Strategy Tester everything works! Maybe this is not quite the right way to do it:

extern bool    GBP=true;
extern bool    EUR=true;
- - - - - - - - - - - - - - - - - - - -
int start()
  {
//------------------------------------------------------
if (GBP) //если есть разрешение true{
 
double C = iRSI("GBPUSD", 0, .....);
double D = iRSI("GBPUSD", 0, .....); 
 if (A<B)
{
double   BID = MarketInfo("GBPUSD", MODE_BID);
 double   ASK = MarketInfo("GBPUSD", MODE_ASK);
 double POINT =MarketInfo("GBPUSD",MODE_POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)     }}}
//----------------------------------------------------------  
if (EUR) { //если есть разрешение true
 
double C = iRSI("EURUSD", 0, .....);
double D = iRSI("EURUSD", 0, .....);
 if (C>D)
{
double   BID = MarketInfo("EURUSD", MODE____BID);
 double   ASK = MarketInfo("EURUSD", MODE____ASK);
 double POINT =MarketInfo("EURUSD",MODE____POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)      }}}
//------------------------------------------------------------
return(0);  
  }
The second option also seems to work in the tester.

But what's the best way to do it?

 
rid:

Good evening!


I am thinking of combining two pairs into one EA. I have done it.


But suddenly I had doubts. I did it like this:

extern bool    GBP=true;
extern bool    EUR=true;
- - - - - - - - - - - - - - - - - - - -
int start()
  {
double A = iRSI("GBPUSD", 0, .....);
double B = iRSI("GBPUSD", 0, .....);
 
double C = iRSI("EURUSD", 0, .....);
double D = iRSI("EURUSD", 0, .....);
//------------------------------------------------------
if (GBP) {//если есть разрешение true
if (A<B)
{
double   BID = MarketInfo("GBPUSD", MODE_BID);
 double   ASK = MarketInfo("GBPUSD", MODE_ASK);
 double POINT =MarketInfo("GBPUSD",MODE_POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)     }}}
//----------------------------------------------------------  
if (EUR) { //если есть разрешение true
if (C>D)
{
double   BID = MarketInfo("EURUSD", MODE____BID);
 double   ASK = MarketInfo("EURUSD", MODE____ASK);
 double POINT =MarketInfo("EURUSD",MODE____POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)      }}}
//------------------------------------------------------------
return(0);  
  }

In online and in the Strategy Tester everything works! Maybe this is not quite the right way to do it:

extern bool    GBP=true;
extern bool    EUR=true;
- - - - - - - - - - - - - - - - - - - -
int start()
  {
//------------------------------------------------------
if (GBP) //если есть разрешение true{
 
double C = iRSI("GBPUSD", 0, .....);
double D = iRSI("GBPUSD", 0, .....); 
 if (A<B)
{
double   BID = MarketInfo("GBPUSD", MODE_BID);
 double   ASK = MarketInfo("GBPUSD", MODE_ASK);
 double POINT =MarketInfo("GBPUSD",MODE_POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)     }}}
//----------------------------------------------------------  
if (EUR) { //если есть разрешение true
 
double C = iRSI("EURUSD", 0, .....);
double D = iRSI("EURUSD", 0, .....);
 if (C>D)
{
double   BID = MarketInfo("EURUSD", MODE____BID);
 double   ASK = MarketInfo("EURUSD", MODE____ASK);
 double POINT =MarketInfo("EURUSD",MODE____POINT);
(ticket=OrderSend .... //ПОКУПАЕМ/ПРОДАЕМ...)      }}}
//------------------------------------------------------------
return(0);  
  }
The second option also seems to work in the tester.

But what's the best way to do it?




I usually calculate all indicator values at the beginning, i.e. variant 1, it's easier, you don't get confused and the code is more structured.
 

Thank you! For the answer. One more question. Trailing stops do not want to work. They work individually in the tester!

But online, it works for one pair. But for another one it generates error - right after attaching the Expert Advisor.

But deals go - only without trawl on the second pair.

Error 130 modifying SL

int start()
  {
РАСЧЁТ  ИНДИКАТОРОВ 
{
ПОКУПКА/ПРОДАЖА
  }
 
for (int j=0; j<OrdersTotal(); j++)                                    {
    if (OrderSelect(j, SELECT_BY_POS, MODE_TRADES))                     {
     if (OrderSymbol()=="GBPUSD" && OrderMagicNumber()==Magic1)          {
ИДЕТ КОД 1 ТРЕЙЛИНГА.
   }
 
for (int r=0; r<OrdersTotal(); r++)                                    {
    if (OrderSelect(r, SELECT_BY_POS, MODE_TRADES))                     {
     if (OrderSymbol()=="EURUSD" && OrderMagicNumber()==Magic2)          {
ИДЕТ КОД 2 ТРЕЙЛИНГА
}
 
return(0);  
  }
The trailing codes are the same, but the external and internal variables have different characters.

I cannot understand what is wrong. Maybe someone will tell me?

 
try it like this
int start()
{
//РАСЧЁТ  ИНДИКАТОРОВ 
 
//ПОКУПКА/ПРОДАЖА
  
 
for (int j=0; j<OrdersTotal(); j++)
  {
    if (OrderSelect(j, SELECT_BY_POS, MODE_TRADES))
       {
          if (OrderSymbol()=="GBPUSD" && OrderMagicNumber()==Magic1)         
              {
                  ИДЕТ КОД 1 ТРЕЙЛИНГА.
              }
          if (OrderSymbol()=="EURUSD" && OrderMagicNumber()==Magic2)   
              {
                  ИДЕТ КОД 2 ТРЕЙЛИНГА
              }
        }
   }
 
 
  return(0);  
}
 
structure the code, it will be easier for both people and you to understand.
 

I'll give it a try, thank you.

 

It seems to be working!

No error yet. Waiting for profits to check the trawl.

More questions. If you don't mind.

Nowhere near the simplest examples of multicurrency experiments. And where they are available, they are not for the feeble mind. It's too complicated to understand everything.

There is one in my code:

 double   BID = MarketInfo("GBPUSD", MODE_BID);
 double   ASK = MarketInfo("GBPUSD", MODE_ASK);
 double POINT =MarketInfo("GBPUSD",MODE_POINT);
//-------Проверяем условие на покупку-------------
if  (

However, in the rare examples on this site when a similar block is present, there is a line:

RefreshRates();
 double BID = MarketInfo("GBPUSD", MODE_BID);
 double ASK = MarketInfo("GBPUSD", MODE_ASK);
 double POINT =MarketInfo("GBPUSD",MODE_POINT);

I have also inserted this line. It compiled. But I don't notice any change in performance.

How much is it needed here? Perhaps it should be left in my EA. It works on all ticks. And it uses an array of values -

//------заполняем массив значениями RSI GBPUSD -----------
 double RSI_array[30];
int    i=0;
while (i<31)
 {
RSI_array[i]=iRSI("GBPUSD",0,GBPUSD_period,3,3,MODE_SMA,0,MODE_MAIN,i);
i++;

 
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.
 

Got the error! Instead of "0" - I put in indicator variables for currencies - the timeframe on which the Expert Advisor works.

My Expert Advisor seems to work smoothly. And the trawls work too.

And one last question, I hope. I have inserted one more. But it is not the built-in indicator but a custom one. In the tester, this pair works. But online, it won't! It displays something strange: almost every second this indicator is placed and deleted. ..... - any advice?

//***************************************************************

kLerk ! Of all the experts here this week you're the only one who has responded to my question. And I got the answers I was mostly happy with. ( Except for question about RefreshRates() )

Please put your email address here.

I will, as a token of my gratitude, send you a simple trading "Grail" - EA! which was invented by my good friend.(Agreed) I work with it with manual confirmation. I work with it as a manual confirmation. I use only two built in Induced Indicators.

Without irony, - that it really is almost a "Grail" (at some skill of working with it), - you'll see after a few minutes after receiving it! However - let everyone have a look at it:

The symbol ---------

Period 30 Minutes (M30) 2007.01.02 11:00 - 2007.08.15 00:00

Model All ticks (based on all smallest available periods with fractal interpolation of each tick)

Modeling quality 67.35%

Initial deposit 10000.00

Net profit 4009.24

Total profit 6335.06 Total loss -2325.82

Profitability 2.72 Expected payoff 21.44

Maximum drawdown 245.63 (2.18%) Relative drawdown 2.18% (245. 63)

Total trades 187

Short positions (% win) 71 (80.28%)

Long positions (% win) 116 (68.10%)

Profitable trades (% of all) 136 (72.73%)

Loss trades (% of all) 51 (27.27%)

Largest profitable trade 145.02, losing trade -47. 77

Average profitable trade 46.58, losing trade -45.60

Maximum number of continuous wins (profit) 9 (586. 96)

continuous losses (loss) 4 (-189.99

And here is the out-of-sample test chart for November/December of the previous year 2006:

 
rid:

As a token of my gratitude, I will send you a simple trading "grail" - an advisor!

Congratulations, klerk, you got the grail for free!
 
<< Prints something incomprehensible: almost every second this indicator is put and removed...... - >>

Most likely, the actual parameters with which the custom indicator is called don't correspond to the formal ones listed with the extern key in the listing (number, order, type, ...). Quite common mistake.
Reason: