Discussão do artigo "Como colocar um produto no mercado" - página 3

 
Adriano De Mello Moura #:

Meu EA ao cadastrar novo produto retorna erro :

test on EURUSD,H1 (netting) 2020.04.15 15:47:05 failed modify #44 sell 0.2 EURUSD sl: 1.08929, tp: 1.08599 -> sl: 1.08919, tp: 1.08599 [Modification failed due to order or position being close to market]

Porém meu EA é para rodar no WIN$ não em forex. Porque o testador não deixa informar qual ativo deve ser executado ?

Agora como corrigir algo que não tem erro, pois o EA está rodando perfeitamente, só não consigo cadastrar o produto para venda.

O robô deve estar preparado para funcionar em qualquer ativo . . .


Para corrigir o erro apontado acima, você deve fazer a verificação abaixo antes de modificar a posição:

//+--------------------------------------------------------------------------------------------------------------------+
//| Verifica se distância entre o TakeProfit/StopLoss e o preço de fechamento é maior do que SYMBOL_TRADE_STOPS_LEVEL  |
//+--------------------------------------------------------------------------------------------------------------------+
bool Check_SL_TP(ENUM_ORDER_TYPE type, double SL, double TP)
  {
//--- Local variables
   bool SL_check = false, TP_check = false;

//--- Determines last price for current symbol
   double BID = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   double ASK = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

//--- get the SYMBOL_TRADE_STOPS_LEVEL level
   int stops_level = (int)SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL);
   if(stops_level != 0)
     {
      PrintFormat("SYMBOL_TRADE_STOPS_LEVEL=%d: StopLoss and TakeProfit must not be nearer than %d points from the closing price", stops_level, stops_level);
     }

//--- check only two order types
   switch(type)
     {
      //--- Buy operation
      case  ORDER_TYPE_BUY:
        {
         //--- check the StopLoss
         SL_check = (BID - SL > stops_level * _Point);
         if(!SL_check)
           {
            ERRMSG = StringFormat("For order %s StopLoss=%.5f must be less than %.5f (Bid=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), SL, BID - stops_level * _Point, BID, stops_level);
           }
         //--- check the TakeProfit
         TP_check = (TP - BID > stops_level * _Point);
         if(!TP_check)
           {
            ERRMSG = StringFormat("For order %s TakeProfit=%.5f must be greater than %.5f (Bid=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), TP, BID + stops_level * _Point, BID, stops_level);
           }
         //--- return the result of checking
         return(SL_check && TP_check);
        }
      //--- Sell operation
      case  ORDER_TYPE_SELL:
        {
         //--- check the StopLoss
         SL_check = (SL - ASK > stops_level * _Point);
         if(!SL_check)
           {
            ERRMSG = StringFormat("For order %s StopLoss=%.5f must be greater than %.5f (Ask=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), SL, ASK + stops_level * _Point, ASK, stops_level);
           }
         //--- check the TakeProfit
         TP_check = (ASK - TP > stops_level * _Point);
         if(!TP_check)
           {
            ERRMSG = StringFormat("For order %s TakeProfit=%.5f must be less than %.5f (Ask=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), TP, ASK - stops_level * _Point, ASK, stops_level);
           }
         //--- return the result of checking
         return(TP_check && SL_check);
        }
      break;
     }

//--- Verification succeeded
   return(false);
  }



Veja outras verificações que devem ser feitas pelo robô no artigo abaixo:

Que testes deve passar o robô de negociação antes da publicação no Mercado - Artigos MQL5

 
Alguém poderia me explicar como eu posso publicar meu EA que contém indicadores personalizados?
Como eu só posso publicar o arquivo ea.ex5, eu não compreendi como eu posso adicionar meus indicadores para serem instalados juntos do meu EA.
Razão: