forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

Create and Test Forex Strategies

You are not logged in. Please login or register.


Forex Software → Expert Advisor Studio → What did the EAs do when using ECN Broker?

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 5

Topic: What did the EAs do when using ECN Broker?

Hi,

is it possible to use the eas on ecn broker. Isn't it that on ecn broker the tp and Sl will be send later? First open trade than modifiy tp sl?

As i can see on code here

void OpenPosition(int command)
  {
   for(int attempt=0; attempt<TRADE_RETRY_COUNT; attempt++)
     {
      int    ticket     = 0;
      int    lastError  = 0;
      bool   modified   = false;
      double stopLoss   = GetStopLoss(command);
      double takeProfit = GetTakeProfit(command);
      string comment    = IntegerToString(Magic_Number);
      color  arrowColor = command==OP_BUY ? clrGreen : clrRed;

      if(IsTradeContextFree())
        {
         double price=MarketInfo(_Symbol,command==OP_BUY ? MODE_ASK : MODE_BID);
         if(setProtectionSeparately)
           {
            ticket=OrderSend(_Symbol,command,Entry_Amount,price,10,0,0,comment,Magic_Number,0,arrowColor);
            if(ticket>0 && (Stop_Loss>0 || Take_Profit>0))
              {
               modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
              }
           }
         else
           {
            ticket=OrderSend(_Symbol,command,Entry_Amount,price,10,stopLoss,takeProfit,comment,Magic_Number,0,arrowColor);
            lastError=GetLastError();
            if(ticket<=0 && lastError==130)
              {
               ticket=OrderSend(_Symbol,command,Entry_Amount,price,10,0,0,comment,Magic_Number,0,arrowColor);
               if(ticket>0 && (Stop_Loss>0 || Take_Profit>0))
                 {
                  modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
                 }
               if(ticket>0 && modified)
                 {
                  setProtectionSeparately=true;
                  Print("Detected ECN type position protection.");
                 }
              }
           }
        }

      if(ticket>0)
         break;

      lastError=GetLastError();
      if(lastError!=135 && lastError!=136 && lastError!=137 && lastError!=138)
         break;

      Sleep(TRADE_RETRY_WAIT);
      Print("Open Position retry no: "+IntegerToString(attempt+2));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

Can someone explain me how it works here?

I have tried some different Brokers and an exported ea works on broker a but not on broker b. Cause some brokers have different specifications.

Some brokers use minimum Lot size or maximum Lozsize that can be used. Also some brokers have volume step of 0.10 some can 0.01. So how about it to make it in code. For these i am using this code and works well.

   double NormalizeEntrySize(double size) {
   double minlot  = MarketInfo(_Symbol, MODE_MINLOT);
   double maxlot  = MarketInfo(_Symbol, MODE_MAXLOT);
   double lotstep = MarketInfo(_Symbol, MODE_LOTSTEP);

   if (size <= minlot)
       return (minlot);

   int steps = (int) MathRound((size - minlot) / lotstep);
   size = minlot + steps * lotstep;

   if (size >= maxlot)
       size = maxlot;
   if (size >=Maximum_Lots)
       size = Maximum_Lots;
       
   size = NormalizeDouble(size, digits);   

   return (size);
}    

So here the entry size will be checked if its compatible with your broker.
The same should be a check of TP and stop loss . Cause some brokers uses a minimum u have to use of pips for tp or sl.
But here i dont find out a code yet. to check if the sl and tp is working for the ea.

What exactly the differences between ecn brokers and normal brokers on working eas?

Re: What did the EAs do when using ECN Broker?

EA Studio always tries to set the SL and TP with the order send. If it fails the first time, the expert send the order and after that sets the SL / TP.  If it works, it marks the case and does that at every next order.

We have no reports for an execution failure, so we can expect that the current code works fine.
About the difference betwenn ECN and rest, mhhh... the name? Jokes aside. The brokers have so big margins for settings he trading behavior, that it makes it pointless to generalize. They use MT backend plugins to change the conditions dynamically for every market or group of traders. They have also people to monitor the trading and stats (Risk Managers smile  they call them) It must be no risk for the broker at any time.

Re: What did the EAs do when using ECN Broker?

EA Studio checks the minimum allowed SL and TP by using the MODE_STOPLEVEL

   double delta    = MathMax(pip*Stop_Loss, _Point*stopLevel);

Re: What did the EAs do when using ECN Broker?

did the portfolio expert works on ecn accounts?

Re: What did the EAs do when using ECN Broker?

did the portfolio expert works on ecn accounts?

When I read you question I asked myself did I miss something.

The Portfolio Expert is a regular expert and the ECN accounts are regular accounts, so your question is virtually equal to:  Did the expert works on accounts?

I may say: Yes, it works.

ECN is not mentioned in the MQL documentation and MQL is not mentioned in the ECN papers, which means that most probably the question doesn't make sense.

Do you have any specific concern about the expert created with EA Studio? If you have, we can try to find an answer.

Posts: 5

Pages 1

You must login or register to post a reply

Forex Software → Expert Advisor Studio → What did the EAs do when using ECN Broker?

Similar topics in this forum