Comment j'ai assemblé mon conseiller par essais et erreurs - page 34

 

ont compris comment prescrire correctement le risque

#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);

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

où lot - insérerTradeSizeOptimized()

Je dois le corriger dans le conseiller expert - sinon, il n'est pas correct ici.

 

renommé - expert terminé. toutes les erreurs ont été corrigées. Titre <Mouvement de cheval ><Mouvement de cheval

Mouvement des chevaux

Dossiers :
Horse_move.mq5  190 kb
 


Aleksandr Klapatyuk:

Ajouté à l'Expert précédent, deux méthodes pour la ligne Horizontale.

1 possibilité : la ligne 1 ouvrira la ligne 4 à une distance donnée, la ligne 2 ouvrira la ligne 3 à une distance donnée.

2ème possibilité : la ligne 7 ouvrira une ligne 10 à une distance donnée, qui se déplace derrière le prix et quand le prix la touche, une commande se déclenchera. la ligne 8 ouvrira une ligne 9 à une distance donnée, - la même action que pour 7 et 10.

#property version "1.01"

Il y a une autre option -la ligne 1 ouvrira 4 et 9. Laligne 2 ouvrira 3 et 10.

La ligne 7 ouvrira 10 et 3. Laligne 8 ouvrira 9 et4.

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)

pour ouvrir les positions à l'envers et ne pas toucher les paramètresObj : commande :

il y a un renversement -

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

#property version "1.01"

Il s'est avéré que c'était une autre possibilité -la ligne 1 ouvrira 4 et 9. La ligne 2 ouvrira 3 et 10.

La ligne 7 ouvrira 10 et 3. La ligne 8 ouvrira 9 et 4.

pour ouvrir les positions en sens inverse et ne pas toucher aux paramètres de lacommande Obj: :

il y a un renversement -

J'ai maintenant commencé le test - je ne ferai rien jusqu'à la fin du mois, je me demande ce qui va se passer. - lot, je l'ai réglé sur le risque - il calculera en quelque sorte

test

 

Pas mal ! Lentement, mais ça s'améliore.

test1

 

Oui ! Ça va directement au sommet.

Alpari MT5

 
Aleksandr Klapatyuk:

renommé - expert terminé. toutes les erreurs ont été corrigées. Titre <Mouvement de cheval ><Mouvement de cheval

Conseiller expert intéressant.

 

définir l'entrée double TargetProfit = 30000.00;// Bénéfice cible

probablement pas assez - aurait dû être plus. maintenant nous devons attendre à nouveau, points d'entrée et définir le 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

ouvre des positions à partir de l'indicateur lignes pivot timezone.mq5 à partir de la ligne R2 - bas S2 - haut

Instantané1

l'indicateur ne peut pas être supprimé - ses lignes sont mises à jour le jour suivant

Alpari MT5

l'indicateur est ci-dessous - je vais chercher le lien vers l'indicateur sur le sitehttps://www.mql5.com/ru/code/1114.

Dossiers :
 
Aleksandr Klapatyuk:

définir l'entrée double TargetProfit = 30000.00; // Bénéfice cible

probablement pas assez - aurait dû être plus. maintenant nous devons attendre à nouveau, points d'entrée et fixer le TargetProfit = 35000.00; // Target Profit

ouvre des positions à partir de l'indicateur lignes pivot timezone.mq5 à partir de la ligne R2 - bas S2 - haut

l'indicateur ne peut pas être supprimé - ses lignes sont mises à jour le jour suivant

l'indicateur ci-dessous - maintenant recherche sur le site web le lien vers l'indicateurhttps://www.mql5.com/ru/code/1114

c'est l'une des options. mais il y en a un million.

J'ai oublié de dire à propos du lot - défini en entrée de risque ENUM_LOT_OR_RISK InpLotOrRisk = lots ;// Gestion de l'argent : Lot OR Risque

(informations d'expert dans .log) quels avertissements sont émis https://www.mql5.com/ru/docs/event_handlers/ondeinit
Документация по MQL5: Обработка событий / OnDeinit
Документация по MQL5: Обработка событий / OnDeinit
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Возвращает текстовое описания причины деинициализации            |
Dossiers :
20191107.log  272 kb
 

#property version "1.02"

trouvé un autre moyen pour les boutons

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

ici nous choisissons

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
//---

à l'ouverture de la position - le stop loss est fixé immédiatement ( ligne horizontale jaune)

ajusté ici -input double InpStopLoss = 55;// Obj : Stop Loss, en pips (1.00045-1.00055=1 pips)

désactiver l'ensemble 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)
Dossiers :
Horse_move.mq5  198 kb
2.mq5  17 kb
Raison: