Como eu monto meu conselheiro por tentativa e erro - página 46

 

O indicador tem 4 linhas horizontais - 2 delas trabalhando a partir do indicador Heiken_Ashi

2 níveis dos quais você pode comprar ou vender. Quando eles cruzam o vermelho, você recebe um sinal -quando eles cruzam o azul, você recebe outro sinal

EURJPYM1

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

quando está no meio (entre as linhas (vermelho e azul) os sinais não funcionam - funcionarão, assim como saem para ambos os lados

Arquivos anexados:
LN_2.mq5  22 kb
 
Alexsandr San:

O indicador tem 4 linhas horizontais - 2 delas trabalhando a partir do indicador Heiken_Ashi

2 níveis dos quais você pode comprar ou vender. Quando eles cruzam o vermelho, você recebe um sinal -quando eles cruzam o azul, você recebe outro sinal

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

quando localizados no meio (entre as linhas (vermelho e azul) os sinais não funcionam - funcionarão, como indo em qualquer direção

Anexei o Conselheiro Especialista a este Indicador

Você precisa instalar o Indicador no gráfico e depois instalar o Expert Advisor no mesmo gráfico.

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

depois que uma posição foi aberta, o indicador foi apagado. depois de um tempo, eu defino o indicador novamente (como verificar o trabalho do Perito)

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

quando um sinal dispara, abre uma posição e apaga o indicador juntamente com as linhas


Arquivos anexados:
Exp_LN_2.mq5  20 kb
 

Combinados dois especialistas em comércio manual

este aquihttps://www.mql5.com/ru/code/24803

e este aquihttps://www.mql5.com/ru/code/26353

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

Combinados dois especialistas em comércio manual

este aquihttps://www.mql5.com/ru/code/24803

e este aquihttps://www.mql5.com/ru/code/26353

Acrescentou outra linha

//+------------------------------------------------------------------+
//| 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
//---
Arquivos anexados:
 
Alexsandr San:

Acrescentei outra linha.

Para um especialista de pleno direito, desaparecido -

1 - Stop Loss , Take Profit in pips (não visível)

2 - Trailing Stop a partir da linha horizontal

3 - Sinal do Indicador

Vou modificar ainda mais o 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:

Para um especialista de pleno direito, desaparecido -

1 - Stop Loss , Take Profit in pips (não visível)

2 - Trailing Stop a partir de Linhas Horizontais

3 - O sinal do indicador

Vou modificar ainda mais o Expert Advisor2_LineOpenClose.mq5

Adicionado - Sinal do Indicador

desta maneira

//+------------------------------------------------------------------+
//| 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);
  }
//+------------------------------------------------------------------+

Agora nas configurações

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

Verificação de um sinal indicador

par

graf

Arquivos anexados:
XXX_Ind.mq5  52 kb
 
Alexsandr San:

Para um especialista de pleno direito, desaparecido -

1 - Stop Loss , Take Profit in pips (não visível)

2 - Trailing Stop a partir de Linhas Horizontais

3 - O sinal do indicador

Vou afinar o Expert Advisor2_LineOpenClose.mq5

Eu também acrescenteiTrailing Stop da Linha Horizontal . Eu meio que acrescentei tudo e agora verifico sua praticidade.

Aqui estão os ajustes

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


Arquivos anexados:
 
Alexsandr San:

Acrescentou também oTrailing Stop das Linhas Horizontais. Acho que acrescentei tudo, agora só preciso verificar se funciona.

Aqui estão os ajustes

O princípio do trabalho, aqui estes parâmetros.

Quando os fundos atingem um determinado alvo, todas as posições serão fechadas em todos os pares abertos e todos os gráficos mudarão para o padrão "ADX

( É importante - é obrigatório que os valores acima de seu saldo sejam escritos nas configurações) e o Expert Advisor fechará todas as posições abertas e mudará os gráficos do modelo

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

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

parâmetro com lote.

você pode definir uma posição como 0,06 ou número de posições como 6 a 0,01

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

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

parâmetro com Take ProfitT.

Ela é acionada pelo número de pips (se for "0" fechará a posição) é necessário especificar a distância.

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

XXX_Linha de trilhos.mq5

 
Alexsandr San:

Adicionado - Sinal do Indicador

assim.

Nos ambientes agora é assim

Verificação do sinal a partir do indicador

O indicador só abre posições para fechar, tirei-o do Expert Advisor no terminal (Moving Average)

Eu multei um pouco de reversão

//+------------------------------------------------------------------+
//| 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);
     }
//---
  }
//+------------------------------------------------------------------+

Foto por

O sistema comercial mais simples usando semáforos indicadores

13 de janeiro de 2012, 13:27



Amostras de semáforos típicos, indicadores de sinal

Há muitos indicadores similares na Base de Código no momento. Para o propósito deste artigo, vou dar apenas alguns links para os recursos da fonte:


Arquivos anexados:
 
Alexsandr San:

Do indicador, só abre posições, para fechar, tomei o caminho do Expert Advisor no terminal (Moving Average)

Eu multei um pouco ao contrário

Eu não gosto quando fecho uma posição. Estou procurando uma maneira de corrigir a função, de fechar uma posição a partir de um indicador

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

Eu o consertei. Eu o adicionei do indicador de Média Móvel

//+------------------------------------------------------------------+
//| 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);
  }
//+------------------------------------------------------------------+

e em OnTick()

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

Acontece que oSelectPosition() deve passar por ele

Arquivos anexados:
Razão: