Expert Advisors: Multik

 

Multik:

The Multicurrency Expert Advisor is based on the idea, presented in the article Creating an Expert Advisor, which Trades on a Number of Instruments.

It trades on the EURUSD and GBPUSD daily bars. It buys when MA is upwards, and sells when MA downwards. It uses a special function for money management.

Author: AM2

Multicurrency Expert Advisor

 

Are we going to normalise all pairs by the current instrument ?

dsma2 = NormalizeDouble(SMA[2] - SMA[3], _Digits);      // MA at site 2-3
dsma1 = NormalizeDouble(SMA[1] - SMA[2], _Digits);      // MA at site 1-2
 
Valmars:

Are we going to normalise all pairs by the current instrument ?


Yes, there is an error here. Besides, the function of defining a new bar can be implemented without using the function of time copying.
 
Valmars:

Are we going to normalise all pairs by the current instrument ?


And how to implement it correctly so that there would be no warnings?

In the original version it's like this:

     int Digits_ = SymbolInfoInteger(Symbol_, SYMBOL_DIGITS) + 4;
     dsma2 = NormalizeDouble(SMA[2] - SMA[3], Digits_);      // MA at site 2-3
     dsma1 = NormalizeDouble(SMA[1] - SMA[2], Digits_);      // MA at site 1-2
[Deleted]  
AM2:

What is the correct way to implement it without warnings?

In the original version it's like this:

What does +4 have to do with it? That's how it should be logically

int Digits_ = SymbolInfoInteger(Symbol_, SYMBOL_DIGITS);
dsma2 = NormalizeDouble(SMA[2] - SMA[3], Digits_); // MA at site 2-3
dsma1 = NormalizeDouble(SMA[1] - SMA[2], Digits_); // MA at site 1-2
 
Interesting:

What does that have to do with +4? It's supposed to be logical.

This is also how the warning goes:

possible loss of data due to type conversion Multik.mq5 218 18

 
AM2:

That's how the warning goes, too:

possible loss of data due to type conversion Multik.mq5 218 18

to avoid warnings, you need to make the conversion like this

int Digits_ = (int)SymbolInfoInteger(Symbol_, SYMBOL_DIGITS);
 

Nice work, but doesn't multi-instrument lose it's meaning when you trade coorelated pairs with the same setups? I would expect their drawdowns to occur around the same time and that may be an issue. Unfortunately though, all currency pairs are so corellated this may be unavoidable. I actually trade the EUR/USD GBP/USD pairs together as well but with one I use a trend follower with the other I use a reversal, tops and bottoms type of EA.

 
sergey1294:

If you don't want to get warnings, you have to make the conversion like this.

Thanks, it works!
 

request.volume = Money_M();

 

This EA is a great example of organized code and has great comments.  I did have one question however pertaining to your lot size function called Money_M().  What and where is the decision tree behind this?

I tried to search the support site but could find no reference and it did not appear to be linked to an associated class. 

[Deleted]  
bdwezensky:

request.volume = Money_M();

 

This EA is a great example of organized code and has great comments.  I did have one question however pertaining to your lot size function called Money_M().  What and where is the decision tree behind this?

I tried to search the support site but could find no reference and it did not appear to be linked to an associated class. 

double Money_M()
  {
   double Lots=AccountInfoDouble(ACCOUNT_FREEMARGIN)/100000*10;
   Lots=MathMin(5,MathMax(0.1,Lots));
   if(Lots<0.1)
      Lots=NormalizeDouble(Lots,2);
   else
     {
      if(Lots<1) Lots=NormalizeDouble(Lots,1);
      else       Lots=NormalizeDouble(Lots,0);
     }
   return(Lots);
  }

This function is used to calculate the size of trading lots.

double Lots=AccountInfoDouble(ACCOUNT_FREEMARGIN)/100000*10;

In  this string the calculated size of trade lots. The calculation is carried out on free money (ACCOUNT_FREEMARGIN). Risk = 10% of available free funds.

Lots=MathMin(5,MathMax(0.1,Lots));
In this line is executed the normalization of the trade lots. 0.1 <= Lot <= 5.0