Examples: The Basic of Coding A Hedge Expert Advisor

 

New article The Basic of Coding A Hedge Expert Advisor has been published:

An example of hedge Expert Advisor is just presented in this article. The author will choose its very own favorite hedge pair that is EURJPY & GBPJPY. It always moves the same way, easier to set the hedging order type.

Author: chayutra sriboonruang

 
else // in case ping failed or requote 
          { 
            if(ExistPositions(BaseSymbol, MagicNo) == 1&&
               TotalCurProfit(MagicNo)>AcceptableLoss$) -------------------> ЗДЕСЬ
              { 
                CloseScrap(BaseSymbol, ExistOP(BaseSymbol, 
                           MagicNo), MagicNo); 
              } 
            else 
                if(ExistPositions(H_Symbol, MagicNo) == 1&&
                   TotalCurProfit(MagicNo) > AcceptableLoss$) ----------------------> И ЗДЕСЬ
                  { 
                    CloseScrap(H_Symbol, ExistOP(H_Symbol, 
                               MagicNo), MagicNo); 
                  } 
          } 
 
Эти условия всегда будут справедливы, а позиции будут сразу закрываться после открытия...
This conditions are always true, so orders would be closed just after opening.
With Regartds - S,D.
 
{ return(true);                    -- ? Return before next commands. PlaySound don't work never.
  if(PlayAudio) {PlaySound ... ;}   
}
 
I get "No Swap Condition To Gain From : pls modify one or more input parameter(s)". What is causing that? How to make it work?
 
I am having a problem with sending the hedge using this method. The base symbol is opening OK but the Hedge is giving an Invalid Price error. Any ideas????
 
What is the point in having a code that is not backtestable?
 
Hi, I am studying this, but in this core function :  

double Cor(string base, string hedge) 
  { 
    double u1=0,l1=0,s1=0; 
    for(int i = CorPeriod - 1; i >= 0; i--) 
      { 
        u1 += u(symboldif(base, i), symboldif(hedge, i)); 
        l1 += powdif(symboldif(base, i)); 
        s1 += powdif(symboldif(hedge, i)); 
      } 
    if(l1*s1 > 0) 
        return(u1 / MathSqrt(l1*s1)); 
  } 


u1 / MathSqrt(l1*s1) , basically return , always return i mean , "1" ,

because MathSqrt(l1 * s1) = symoboldif(base, i) * symboldif(hedge, i) ...  

 
I wonder why the admin created an blog with MQL5 in the url that contains almost more mql4 code than mql5 code ...
Reason: