Cómo armo mi asesor por ensayo y error - página 34

 

de prescribir correctamente el riesgo

#define  Magic_Number 0
//+------------------------------------------------------------------+
//| Enum Lor or Risk                                                 |
//+------------------------------------------------------------------+
enum ENUM_LOT_OR_RISK
  {
   lots=0,     // Constant lot
   risk=1,     // Risk in percent
  };
//+------------------------------------------------------------------+


input double   MaximumRisk             = 0.01;          // Maximum Risk in percentage
input double   DecreaseFactor          = 3;             // Descrease factor
input ENUM_LOT_OR_RISK InpLotOrRisk    = lots;          // Money management: Lot OR Risk
   //+------------------------------------------------------------------+
   //| Calculate optimal lot size                                       |
   //+------------------------------------------------------------------+
   double            TradeSizeOptimized(void)
     {
      double price=0.0;
      double margin=0.0;
      //--- select lot size
      if(!SymbolInfoDouble(_Symbol,SYMBOL_ASK,price))
         return(0.0);
      if(!OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,1.0,price,margin))
         return(0.0);
      if(margin<=0.0)
         return(0.0);
      double lot=0;
      //---
      switch(InpLotOrRisk)
        {
         case lots:
            lot=MaximumRisk;
            break;
         case risk:
            lot=NormalizeDouble(AccountInfoDouble(ACCOUNT_MARGIN_FREE)*MaximumRisk/margin,2);
         default:
            break;
        }
      //--- calculate number of losses orders without a break
      if(DecreaseFactor>0)
        {
         //--- select history for access
         HistorySelect(0,TimeCurrent());
         //---
         int    orders=HistoryDealsTotal();  // total history deals
         int    losses=0;                    // number of losses orders without a break

         for(int i=orders-1; i>=0; i--)
           {
            ulong ticket=HistoryDealGetTicket(i);
            if(ticket==0)
              {
               Print("HistoryDealGetTicket failed, no trade history");
               break;
              }
            //--- check symbol
            if(HistoryDealGetString(ticket,DEAL_SYMBOL)!=_Symbol)
               continue;
            //--- check Expert Magic number
            if(HistoryDealGetInteger(ticket,DEAL_MAGIC)!=Magic_Number)
               continue;
            //--- check profit
            double profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
            if(profit>0.0)
               break;
            if(profit<0.0)
               losses++;
           }
         //---
         if(losses>1)
            lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
        }
      //--- normalize and check limits
      double stepvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
      lot=stepvol*NormalizeDouble(lot/stepvol,0);

      double minvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
      if(lot<minvol)
         lot=minvol;

      double maxvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
      if(lot>maxvol)
         lot=maxvol;
      //--- return trading volume
      return(lot);

     }
   //+------------------------------------------------------------------+

donde lote - insertarTradeSizeOptimized()

Tengo que corregirlo en Expert Advisor - de lo contrario no es correcto allí

 

renombrado - experto completado. todos los errores corregidos. Título <Movimiento del caballo ><Movimiento del caballo

Movimiento de caballos

Archivos adjuntos:
Horse_move.mq5  190 kb
 


Aleksandr Klapatyuk:

Añadido al anterior Experto, dos métodos para la línea Horizontal.

1 posibilidad : la línea 1 abrirá la línea 4 a una distancia determinada, la línea 2 abrirá la línea 3 a una distancia determinada.

2ª posibilidad: la línea 7 abrirá una línea 10 a una distancia determinada , que se mueve detrás del precio y cuando éste la toca, se dispara una orden. la línea 8 abrirá una línea 9 a una distancia determinada, - la misma acción que para 7 y 10.

#versión de la propiedad "1.01"

Hay otra opción - lalínea 1abrirá 4 y 9.la línea 2 abrirá 3 y 10.

lalínea 7abrirá 10 y 3 .la línea 8 abrirá 9 y4

input string   t3="------ Obj:Name 1-2-3-4 ------";     // Имя Объекта
input string   InpObjUpNameZ           = "TOP 1";       // Obj: TOP (Name Obj) ВВЕРХУ 1
input string   InpObjDownNameZ         = "LOWER 2";     // Obj: LOWER (Name Obj) ВНИЗУ 2
input int      Step                    = 5;             // Obj: Шаг сетки, пунктов(0 = false)
input string   InpObjDownName0         = "TOP 3";       // Obj: TOP (Name Obj) ВВЕРХУ 3
input ENUM_TRADE_COMMAND InpTradeCommand=open_sell;     // Obj:  command:
input string   InpObjUpName0           = "LOWER 4";     // Obj: LOWER (Name Obj) ВНИЗУ 4
input ENUM_TRADE_COMMAND InpTradeCommand0=open_buy;     // Obj:  command:
input string   t5="- 2_Obj:Trailing Line 7-8-9-10 --- ";// Trailing Obj:Line
input string   InpObjUpNameZx          = "TOP 7";       // Obj: TOP (Name Obj) ВВЕРХУ 7
input string   InpObjDownNameZx        = "LOWER 8";     // Obj: LOWER (Name Obj) ВНИЗУ 8
input int      StepZx                  = 5;             // Obj: Шаг сетки, пунктов(0 = false)
input string   InpObjUpNameX           = "TOP 9";       // Obj: TOP (Horizontal Line) ВВЕРХУ 9
input ENUM_TRADE_COMMAND InpTradeCommandX=open_buy;     // Obj:  command:
input string   InpObjDownNameX         = "LOWER 10";    // Obj: LOWER (Horizontal Line) ВНИЗУ 10
input ENUM_TRADE_COMMAND InpTradeCommand0X=open_sell;   // Obj:  command:
input ushort   InpObjTrailingStopX     = 5;             // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepX     = 5;             // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)

para abrir las posiciones en el reverso y no toque elcomando de configuraciónObj::

hay una inversión -

input string   t6="------ Obj: Revers Buy and Sell --"; // Obj: Revers Buy and Sell
input bool     ObjRevers               = false;         // Obj: Revers
Archivos adjuntos:
Horse_move.mq5  190 kb
2.mq5  17 kb
 
Aleksandr Klapatyuk:

#versión de la propiedad "1.01"

Resultó ser otra posibilidad - lalínea 1abrirá 4 y 9. la línea 2 abrirá 3 y 10.

la línea 7 abrirá 10 y 3 . la línea 8 abrirá 9 y 4

para abrir las posiciones en sentido inverso y no tocar elcomando de configuraciónObj::

hay una inversión -

ahora he comenzado la prueba - no haré nada hasta el final del mes, me pregunto qué pasará. - lote, lo he puesto en riesgo - de alguna manera calculará

prueba

 

¡No está mal! Lentamente - pero está mejorando

prueba1

 

¡Sí! Va directamente a la cima.

Alpari MT5

 
Aleksandr Klapatyuk:

renombrado - experto completado. todos los errores corregidos. Título <Movimiento del caballo ><Movimiento del caballo

Interesante asesor experto.

 

setinput double TargetProfit = 30000.00;// Beneficio objetivo

probablemente no es suficiente - debería haber sido más. ahora tenemos que esperar de nuevo, puntos de entrada y establecer el TargetProfit = 35000.00;// Target Profit

//+------------------------------------------------------------------+
input string   t0="------ Parameters --------";         // Настройка Эксперта
input string   Template                = "ADX";         // Имя шаблона(without '.tpl')
input datetime HoursFrom               = D'1970.01.01'; // Время старта Эксперта
input datetime HoursTo                 = D'2030.12.31'; // Время закрытия всех позиций
input double   TargetProfit            = 900000.00;     // Целевая прибыль
input uint     maxLimits               = 1;             // Кол-во Позиции Открыть в одну сторону
input double   MaximumRisk             = 0.01;          // Maximum Risk in percentage
input double   DecreaseFactor          = 3;             // Descrease factor
input ENUM_LOT_OR_RISK InpLotOrRisk    = lots;          // Money management: Lot OR Risk

abre posiciones desde el indicador de líneas pivote timezone.mq5 desde la línea R2 - abajo S2 - arriba

Instantánea1

el indicador no se puede borrar - sus líneas se actualizan al día siguiente

Alpari MT5

el indicador está abajo - buscaré el enlace al indicador en el sitio webhttps://www.mql5.com/ru/code/1114

Archivos adjuntos:
 
Aleksandr Klapatyuk:

setinput double TargetProfit = 30000.00; // Beneficio objetivo

probablemente no es suficiente - debería haber sido más. ahora tenemos que esperar de nuevo, puntos de entrada y establecer el TargetProfit = 35000.00; // Target Profit

abre posiciones desde el indicador de líneas pivote timezone.mq5 desde la línea R2 - abajo S2 - arriba

el indicador no se puede borrar - sus líneas se actualizan al día siguiente

el indicador de abajo - ahora buscando en el sitio web el enlace al indicadorhttps://www.mql5.com/ru/code/1114

esta es una de las opciones. pero hay un millón de opciones

Se me olvidó decir lo del lote - ajustado a la entrada de riesgo ENUM_LOT_OR_RISK InpLotOrRisk = lotes;// Gestión del dinero: Lote O Riesgo

(información experta en .log) qué avisos se emiten https://www.mql5.com/ru/docs/event_handlers/ondeinit
Документация по MQL5: Обработка событий / OnDeinit
Документация по MQL5: Обработка событий / OnDeinit
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Возвращает текстовое описания причины деинициализации            |
Archivos adjuntos:
20191107.log  272 kb
 

#versión de la propiedad "1.02"

encontró otra forma para los botones

//+------------------------------------------------------------------+
//| Enum ENUM_BUTTON                                                 |
//+------------------------------------------------------------------+
enum ENUM_BUTTON
  {
   Button0=0,  // ВЫКЛ
   Button1=1,  // ВКЛ
   Button2=2,  // ВКЛ: AVGiS
  };
//+------------------------------------------------------------------+

aquí seleccionamos

input string   t9="------ Button: AVGiS -----";         // AVGiS (Или обычный режим Buy/Sell)
input ENUM_BUTTON Buttons              = Button0;       // Вкл: Копки Buy/Sell
input bool     ObjectLineX             = false;         // Button: Horizontal Line(true) || Buy/Sell(false)
input bool     TickRevers              = false;         // Button: Revers
input int      TrailingStop_STOP_LEVEL = 350;           // Trailing Stop LEVEL
input ENUM_TIMEFRAMES _period          = PERIOD_CURRENT;// period
input int      limit_total_symbol      = 190;           // limit_total_symbol
input int      limit_total             = 190;           // limit_total
//---

en la apertura de la posición - el stop loss se fija inmediatamente ( línea horizontal amarilla)

ajustado aquí -input double InpStopLoss = 55;// Obj: Stop Loss, en pips (1.00045-1.00055=1 pips)

desactivar set 0

input string   t2="------ Obj:Trailing Line     --- ";  // Trailing Obj:Line
input double   InpStopLoss             = 55;            // Obj: Stop Loss, in pips (1.00045-1.00055=1 pips)
input ushort   InpObjTrailingStop      = 27;            // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStep      = 9;             // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
Archivos adjuntos:
Horse_move.mq5  198 kb
2.mq5  17 kb