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

 

L'indicateur comporte 4 lignes horizontales, dont 2 proviennent de l'indicateur Heiken_Ashi.

2 niveaux à partir desquels vous pouvez acheter ou vendre. Lorsqu'ils traversent le rouge, vous recevez un signal -lorsqu'ils traversent le bleu, vous recevez un autre signal.

EURJPYM1

-------------

quand il est au milieu (entre les lignes (rouge et bleu) les signaux ne fonctionnent pas - fonctionneront, comme sortiront de chaque côté

Dossiers :
LN_2.mq5  22 kb
 
Alexsandr San:

L'indicateur comporte 4 lignes horizontales - 2 d'entre elles proviennent de l'indicateur Heiken_Ashi.

2 niveaux à partir desquels vous pouvez acheter ou vendre. Lorsqu'ils traversent le rouge, vous recevez un signal -lorsqu'ils traversent le bleu, vous recevez un autre signal.

-------------

lorsqu'ils sont situés au milieu (entre les lignes (rouge et bleue), les signaux ne fonctionnent pas - ils fonctionneront, comme s'ils allaient dans l'une ou l'autre direction.

J'ai joint le conseiller expert à cet indicateur.

Vous devez installer l'indicateur sur le graphique, puis installer le conseiller expert sur le même graphique.

---------------------

Après l'ouverture d'une position, l'indicateur a été supprimé. Après un certain temps, j'ai remis l'indicateur en place (comment vérifier le travail de l'expert).

---------------

lorsqu'un signal se déclenche, ouvre une position et supprime l'indicateur ainsi que les lignes


Dossiers :
Exp_LN_2.mq5  20 kb
 

Combinaison de deux experts pour le trading manuel

celui-cihttps://www.mql5.com/ru/code/24803

et celui-cihttps://www.mql5.com/ru/code/26353

AutoClose Line
AutoClose Line
  • www.mql5.com
Помощник закрытия позиции, если цена пересекла линию: Правило закрытия: цена Open и цена Close текущего бара должны оказаться по разные стороны от линии. Имя линии задаётся в параметре "Line name" - эту линию пользователь проводит сам. Тип линии может быть...
Dossiers :
 
Alexsandr San:

Combinaison de deux experts pour le trading manuel

celui-cihttps://www.mql5.com/ru/code/24803

et celui-cihttps://www.mql5.com/ru/code/26353

Ajouté une autre ligne

//+------------------------------------------------------------------+
//| Enum Lor or Risk                                                 |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {
   close_buys=0,     // Close All Buy's
   close_sells=1,    // Close All Sell's
   close_all=2,      // Close All Buy's and Sell's
   open_buy=3,       // Open Buy
   open_sell=4,      // Open Sell
   open_buy_sell=5,  // Open Buy and Sell
  };
//--- input parameters
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input ushort   InpSignalsFrequency          = 10;                // Search signals, in seconds (min value "10")
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = close_all;         // Trade command:
input bool     ObjRevers                    = false;             // Obj: Revers
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = close_all;         // Trade command:
input ulong    InpMagic                     = 78712995;          // Magic number
//---
Dossiers :
 
Alexsandr San:

J'ai ajouté une autre ligne.

Pour un expert à part entière, il manque -

1 - Stop Loss , Take Profit en pips (non visible)

2 - Trailing Stop à partir de la ligne horizontale

3 - Signal de l'indicateur

Je vais encore modifier l'Expert Advisor2_LineOpenClose.mq5

//--- input parameters
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input ushort   InpSignalsFrequency          = 10;                // Search signals, in seconds (min value "10")
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = close_all;         // Trade command:
input bool     ObjRevers                    = false;             // Obj: Revers
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = close_all;         // Trade command:
input ulong    InpMagic                     = 78712995;          // Magic number
//---
 
Alexsandr San:

Pour un expert à part entière, il manque -

1 - Stop Loss , Take Profit en pips (non visible)

2 - Trailing Stop à partir de lignes horizontales

3 - Le signal de l'indicateur

Je vais encore modifier l'Expert Advisor2_LineOpenClose.mq5

Ajouté - Signal de l'indicateur

de cette façon

//+------------------------------------------------------------------+
//| Get value of buffers                                             |
//+------------------------------------------------------------------+
double iGetArray(const int handle,const int buffer,const int start_pos,const int count,double &arr_buffer[])
  {
   bool result=true;
   if(!ArrayIsDynamic(arr_buffer))
     {
      Print("This a no dynamic array!");
      return(false);
     }
   ArrayFree(arr_buffer);
//--- reset error code
   ResetLastError();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer);
   if(copied!=count)
     {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
   return(result);
  }
//+------------------------------------------------------------------+
//| Search trading signals                                           |
//+------------------------------------------------------------------+
bool SearchTradingSignals(void)
  {
//--- we work only at the time of the birth of new bar
   datetime time_0=iTime(m_symbol.Name(),Period(),0);
   if(time_0==ExtPrevBarsY)
      return(true);
   ExtPrevBarsY=time_0;
   if(!m_symbol.RefreshRates())
     {
      ExtPrevBarsY=0;
      return(false);
     }
//---
   double BuyBuffer[];
   double SellBuffer[];
   ArraySetAsSeries(BuyBuffer,true);
   ArraySetAsSeries(SellBuffer,true);
   if(!iGetArray(handle_iCustom,1,0,2,BuyBuffer) || !iGetArray(handle_iCustom,0,0,2,SellBuffer))
     {
      ExtPrevBarsY=0;
      return(false);
     }
//---
   if(BuyBuffer[1]!=0.0)
     {
      switch(InpTradeCommandY)
        {
         case  close_buys:
            ExtNeedCloseBuy=true;
            if(LongObjClosed())
               break;
         case  close_sells:
            ExtNeedCloseSell=true;
            if(ShortObjClosed())
               break;
         case close_all:
            ExtNeedCloseAll=true;
            if(LongShortObjClosed())
               break;
         case open_buy:
            ExtNeedOpenBuy=true;
            if(LongObjOpened())
               break;
         case open_sell:
            ExtNeedOpenSell=true;
            if(ShortObjOpened())
               break;
         default:
            ExtNeedOpenBuySell=true;
            if(LongShortObjOpened())
               break;
        }
     }
   if(SellBuffer[1]!=0.0)
     {
      switch(InpTradeCommandU)
        {
         case  close_buys:
            ExtNeedCloseBuy=true;
            if(LongObjClosed())
               break;
         case  close_sells:
            ExtNeedCloseSell=true;
            if(ShortObjClosed())
               break;
         case close_all:
            ExtNeedCloseAll=true;
            if(LongShortObjClosed())
               break;
         case open_buy:
            ExtNeedOpenBuy=true;
            if(LongObjOpened())
               break;
         case open_sell:
            ExtNeedOpenSell=true;
            if(ShortObjOpened())
               break;
         default:
            ExtNeedOpenBuySell=true;
            if(LongShortObjOpened())
               break;
        }
     }
//---
   return(true);
  }
//+------------------------------------------------------------------+

Maintenant, dans les paramètres

//--- input parameters
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input ushort   InpSignalsFrequency          = 10;                // Search signals, in seconds (min value "10")
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = open_buy;          // Trade command:
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = open_sell;         // Trade command:
input string   short_name             = "Examples\\ZigzagColor"; // Name Indicators
input ENUM_TRADE_COMMAND InpTradeCommandY   = open_buy;          // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU   = open_sell;         // Trade command: (SellBuffer Indicators)
input bool     ObjRevers                    = false;             // Obj: Revers
//---

Contrôle d'un signal indicateur

par

graf

Dossiers :
XXX_Ind.mq5  52 kb
 
Alexsandr San:

Pour un expert à part entière, il manque -

1 - Stop Loss , Take Profit en pips (non visible)

2 - Trailing Stop à partir de lignes horizontales

3 - Le signal de l'indicateur

Je vais affiner le Conseiller Expert2_LineOpenClose.mq5

J'ai également ajouté unTrailing Stop à partir de la ligne horizontale. J'ai en quelque sorte tout ajouté et je vérifie maintenant sa maniabilité.

Voici les paramètres

//+------------------------------------------------------------------+
input string   t="-----  Parameters         -----";              //
input string   Template                     = "ADX";             // Имя шаблона(without '.tpl')
input double   TargetProfit                 = 999999.99;         // Цель Баланса(Ваш Баланс + сумма)
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input int      InpTakeProfit                = 50;                // Take Profit ("0"-No. 5<100)
input string   t0="----- Trailing Line      -----";              //
input string   InpObjUpName                 = "TOP";             // Obj: TOP (Horizontal Line)
input ENUM_TRADE_COMMAND InpTradeCommand    = close_sells;       // Obj:  command:
input string   InpObjDownName               = "LOWER";           // Obj: LOWER (Horizontal Line)
input ENUM_TRADE_COMMAND InTradeCommand     = close_buys;        // Obj:  command:
input ushort   InpObjTrailingStop           = 30;                // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStep           = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   t1="----- Line name: 1       -----";              //
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = open_buy;          // Trade command:
input string   t2="----- Line name: 2       -----";              //
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = open_sell;         // Trade command:
input string   t3="----- Indicators:        -----";              //
input string   short_name                   = "Examples\\ZigzagColor"; // Name Indicators
input bool     InpIndicators                = false;             // Indicators: Start (true)
input ENUM_TRADE_COMMAND InpTradeCommandY   = open_buy;          // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU   = open_sell;         // Trade command: (SellBuffer Indicators)
input string   t4="----- Revers Buy><Sell   -----";              //
input bool     ObjRevers                    = false;             //  Revers
//---


Dossiers :
 
Alexsandr San:

Ajout d'unstop suiveur à partir de lignes horizontales. Je pense que j'ai tout ajouté, maintenant je dois juste vérifier si ça fonctionne.

Voici les paramètres

Le principe du travail, ici ces paramètres.

Lorsque les fonds atteignent un objectif donné, toutes les positions seront fermées sur toutes les paires ouvertes, et tous les graphiques passeront au motif "ADX".

( Il est important - il est obligatoire que les chiffres au-dessus de votre solde soient écrits dans les paramètres) et le conseiller expert fermera toutes les positions ouvertes et changera les graphiques du modèle.

//+------------------------------------------------------------------+
input string   t="-----  Parameters         -----";              //
input string   Template                     = "ADX";             // Имя шаблона(without '.tpl')
input double   TargetProfit                 = 999999.99;         // Цель Баланса(Ваш Баланс + сумма)

-------------------------------------------------------------

paramètre du lot.

pouvez-vous définir une position comme 0.06 ou un nombre de positions comme 6 à 0.01

input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots

---------------------------------------------------------------

paramètre avec Take ProfitT.

Il est déclenché par le nombre de pips (s'il est "0" il fermera la position) il est nécessaire de spécifier la distance.

input int      InpTakeProfit                = 50;                // Take Profit ("0"-No. 5<100)

XXX_Trailing Line.mq5

 
Alexsandr San:

Ajouté - Signal de l'indicateur

comme ça.

Dans les paramètres, la situation est maintenant la suivante

Vérification du signal de l'indicateur

L'indicateur n'ouvre que des positions à fermer, je l'ai pris dans l'Expert Advisor du terminal (Moving Average).

J'ai fait un petit retour en arrière

//+------------------------------------------------------------------+
//| Check for close position conditions                              |
//+------------------------------------------------------------------+
void CheckForClose(void)
  {
//---
   double BuyBuffer[];
   double SellBuffer[];
   ArraySetAsSeries(BuyBuffer,true);
   ArraySetAsSeries(SellBuffer,true);
   if(!iGetArray(handle_iCustom,1,0,2,BuyBuffer) || !iGetArray(handle_iCustom,0,0,2,SellBuffer))
     {
      return;
     }
//--- positions already selected before
   bool signal=false;
   long type=PositionGetInteger(POSITION_TYPE);
   if(ObjRevers)
     {
      if(type==(long)POSITION_TYPE_BUY && BuyBuffer[1]!=0.0)
         signal=true;
      if(type==(long)POSITION_TYPE_SELL && SellBuffer[1]!=0.0)
         signal=true;
     }
   if(!ObjRevers)
     {
      if(type==(long)POSITION_TYPE_BUY && SellBuffer[1]!=0.0)
         signal=true;
      if(type==(long)POSITION_TYPE_SELL && BuyBuffer[1]!=0.0)
         signal=true;
     }
//--- additional checking
   if(signal)
     {
      if(TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) && Bars(_Symbol,_Period)>100)
         m_trade.PositionClose(_Symbol,3);
     }
//---
  }
//+------------------------------------------------------------------+

Photo par

Le système de trading le plus simple utilisant des indicateurs sémaphores

13 janvier 2012, 13:27



Exemples de sémaphores et d'indicateurs de signaux typiques

Il y a beaucoup d'indicateurs similaires dans la base de code en ce moment. Pour les besoins de cet article, je ne donnerai que quelques liens vers les ressources sources :


Dossiers :
 
Alexsandr San:

De l'indicateur, seulement ouvre des positions, pour fermer, j'ai pris le chemin de l'Expert Advisor dans le terminal (Moving Average)

J'ai un peu affiné la marche arrière

Je n'aime pas ça quand je ferme une position. Je cherche un moyen de corriger la fonction de fermeture d'une position à partir d'un indicateur.

-------------------------------------------------------------------

Je l'ai corrigé. Je l'ai ajouté à partir de l'indicateur de moyenne mobile.

//+------------------------------------------------------------------+
//| Position select depending on netting or hedging                  |
//+------------------------------------------------------------------+
bool SelectPosition()
  {
   bool res=false;
//--- check position in Hedging mode
   if(ExtHedging)
     {
      uint total=PositionsTotal();
      for(uint i=0; i<total; i++)
        {
         string position_symbol=PositionGetSymbol(i);
         if(_Symbol==position_symbol && InpMagic==PositionGetInteger(POSITION_MAGIC))
           {
            res=true;
            break;
           }
        }
     }
//--- check position in Netting mode
   else
     {
      if(!PositionSelect(_Symbol))
         return(false);
      else
         return(PositionGetInteger(POSITION_MAGIC)==InpMagic); //---check Magic number
     }
//--- result for Hedging mode
   return(res);
  }
//+------------------------------------------------------------------+

et dans OnTick()

      if(InpCloseOpposite && InpIndicators)
        {
         //---
         if(SelectPosition())
            CheckForClose();
         else
            SearchTradingSignals();
        }
      if(!InpCloseOpposite && InpIndicators)
        {
         SearchTradingSignals();
        }

il s'avère queSelectPosition() devrait le traverser.

Dossiers :
Raison: