Torcendo e virando, o iMA está tentando enganar - página 9

 
imtochukwu:

Vladimir, descobriu, colocou-o em funcionamento. Onde posso trocar ordens de venda com ordens de compra aqui?

Cada módulo de sinais tem duas funções, que são usadas para emitir sinais de compra ou venda. Estas são "LongCondition" e "ShortCondition".
 
Vladimir Karputov:

Cada módulo de sinais tem duas funções, que são usadas para emitir sinais de compra ou venda. Estas são "LongCondition" e "ShortCondition".


Entendo que em sua EA estas são:

int CSignalMA::LongCondition(void)
  {
   int result=0;
   int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(m_reverse)
      if(DiffCloseMA(idx)>0.0)
        {
         //--- the close price is above the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
   if(!m_reverse)
      if(DiffCloseMA(idx)<0.0)
        {
         //--- the close price is below the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
//--- return the result
   return(result);
  }
//+------------------------------------------------------------------+
//| "Voting" that price will fall.                                   |
//+------------------------------------------------------------------+
int CSignalMA::ShortCondition(void)
  {
   int result=0;
   int idx   =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(m_reverse)
      if(DiffCloseMA(idx)<0.0)
        {
         //--- the close price is below the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
   if(!m_reverse)
      if(DiffCloseMA(idx)>0.0)
        {
         //--- the close price is above the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
//--- return the result
   return(result);
  }
//+------------------------------------------------------------------+‌

e onde está a linha aqui que é responsável pela ação? E como posso mudar esta propriedade?

 
imtochukwu:


Entendo que em sua EA isto é:

int CSignalMA::LongCondition(void)
  {
   int result=0;
   int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(m_reverse)
      if(DiffCloseMA(idx)>0.0)
        {
         //--- the close price is above the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
   if(!m_reverse)
      if(DiffCloseMA(idx)<0.0)
        {
         //--- the close price is below the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
//--- return the result
   return(result);
  }
//+------------------------------------------------------------------+
//| "Voting" that price will fall.                                   |
//+------------------------------------------------------------------+
int CSignalMA::ShortCondition(void)
  {
   int result=0;
   int idx   =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(m_reverse)
      if(DiffCloseMA(idx)<0.0)
        {
         //--- the close price is below the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
   if(!m_reverse)
      if(DiffCloseMA(idx)>0.0)
        {
         //--- the close price is above the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
//--- return the result
   return(result);
  }
//+------------------------------------------------------------------+‌

e onde está a linha aqui que é responsável pela ação? E como posso mudar esta propriedade?

Favor inserir o código corretamente:Insira o código corretamente no fórum

Você citou o código NÃO DO CÓDIGO, mas do MÓDULO DE SINALIZAÇÕES.

Você não precisa mudar nada em meu módulo para mudar a direção do sinal, porque ele tem a configuração "Reverter" - dependendo do valor que tem (verdadeiro ou falso) os sinais podem ser revertidos diretamente.

Usando o exemplo "LongCondition":

se o inverso ("m_reverse") for verdadeiro e o preço de fechamento menos o valor do indicador for maior que zero - então nós damos o sinal "Long" (Comprar, comprar)

int CSignalMA::LongCondition(void)
  {
   int result=0;
   int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(m_reverse)
      if(DiffCloseMA(idx)>0.0)
        {
         //--- the close price is above the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
   if(!m_reverse)
      if(DiffCloseMA(idx)<0.0)
        {
         //--- the close price is below the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
//--- return the result
   return(result);
  }
 
Vladimir Karputov:

Favor inserir o código corretamente:Insira o código corretamente no fórum

Você NÃO colou o código do CONSELHEIRO, mas do MÓDULO SINAL.

Você não precisa mudar nada para mudar a direção do sinal em meu módulo, porque ele tem a configuração "Reverter" - dependendo do valor que ele tem (verdadeiro ou falso) os sinais podem ser revertidos diretamente.

Usando o exemplo "LongCondition":

se "m_reverse" for verdadeiro e o preço de fechamento menos o valor do indicador for maior que zero - então o sinal é "Long" (Comprar, comprar)

int CSignalMA::LongCondition(void)
  {
   int result=0;
   int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(m_reverse)
      if(DiffCloseMA(idx)>0.0)
        {
         //--- the close price is above the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
   if(!m_reverse)
      if(DiffCloseMA(idx)<0.0)
        {
         //--- the close price is below the indicator (the indicator has no objections to buying)
         if(IS_PATTERN_USAGE(0))
            result=m_pattern_0;
        }
//--- return the result
   return(result);
  }

Vladimir, há um novo problema. Seu consultor especializado compilou, mas quando tento arrastá-lo até a tabela e concordo com as configurações. Vejo um ícone no canto direito mostrando que o Expert Advisor foi lançado. Depois desaparece de uma vez. Qual pode ser a razão? Este reverso é bom. Como pode ser aplicado em outros EAs?
 
imtochukwu:

Vladimir, há um novo problema. Sua EA compilou, mas quando tento arrastá-la para uma tabela e concordo com as configurações. Vejo um ícone no canto direito dizendo que a EA está funcionando por um tempo. Depois desaparece de uma vez. Qual pode ser a razão? Este reverso é bom. Como pode ser aplicado a outros EAs?

Procure por mensagens de erro na janela "Caixa de ferramentas" do terminal nas guias "Especialistas" e "Diário"...
 

Entendo que esta é a seção responsável por abrir uma posição se o "preço subirá" no arquivo SignalMA.mqh ?

//+------------------------------------------------------------------+
//| "Voting" that price will grow.                                   |
//+------------------------------------------------------------------+
int CSignalMA::LongCondition(void)
  {
   int result=0;
   int idx   =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(DiffCloseMA(idx)<0.0)
     {
      //--- the close price is below the indicator
      if(IS_PATTERN_USAGE(1) && DiffOpenMA(idx)>0.0 && DiffMA(idx)>0.0)
        {
         //--- the open price is above the indicator (i.e. there was an intersection), but the indicator is directed upwards
         result=m_pattern_1;
         //--- consider that this is an unformed "piercing" and suggest to enter the market at the current price
         m_base_price=0.0;
        }
     }
   else
     {
      //--- the close price is above the indicator (the indicator has no objections to buying)
      if(IS_PATTERN_USAGE(0))
         result=m_pattern_0;
      //--- if the indicator is directed upwards
      if(DiffMA(idx)>0.0)
        {
         if(DiffOpenMA(idx)<0.0)
           {
            //--- if the model 2 is used
            if(IS_PATTERN_USAGE(2))
              {
               //--- the open price is below the indicator (i.e. there was an intersection)
               result=m_pattern_2;
               //--- suggest to enter the market at the "roll back"
               m_base_price=m_symbol.NormalizePrice(MA(idx));
              }
           }
         else
           {
            //--- if the model 3 is used and the open price is above the indicator
            if(IS_PATTERN_USAGE(3) && DiffLowMA(idx)<0.0)
              {
               //--- the low price is below the indicator
               result=m_pattern_3;
               //--- consider that this is a formed "piercing" and suggest to enter the market at the current price
               m_base_price=0.0;
              }
           }
        }
     }
//--- return the result
   return(result);
  }


E se você substituir isto por código de seu módulo, ele funcionará corretamente. O problema é que o conteúdo é ligeiramente diferente do seu. Há mais código aqui... hmm.

 
imtochukwu:

Entendo que esta é a seção responsável por abrir uma posição se o "preço subirá" no arquivo SignalMA.mqh ?

//+------------------------------------------------------------------+
//| "Voting" that price will grow.                                   |
//+------------------------------------------------------------------+
int CSignalMA::LongCondition(void)
  {
   int result=0;
   int idx   =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
   if(DiffCloseMA(idx)<0.0)
     {
      //--- the close price is below the indicator
      if(IS_PATTERN_USAGE(1) && DiffOpenMA(idx)>0.0 && DiffMA(idx)>0.0)
        {
         //--- the open price is above the indicator (i.e. there was an intersection), but the indicator is directed upwards
         result=m_pattern_1;
         //--- consider that this is an unformed "piercing" and suggest to enter the market at the current price
         m_base_price=0.0;
        }
     }
   else
     {
      //--- the close price is above the indicator (the indicator has no objections to buying)
      if(IS_PATTERN_USAGE(0))
         result=m_pattern_0;
      //--- if the indicator is directed upwards
      if(DiffMA(idx)>0.0)
        {
         if(DiffOpenMA(idx)<0.0)
           {
            //--- if the model 2 is used
            if(IS_PATTERN_USAGE(2))
              {
               //--- the open price is below the indicator (i.e. there was an intersection)
               result=m_pattern_2;
               //--- suggest to enter the market at the "roll back"
               m_base_price=m_symbol.NormalizePrice(MA(idx));
              }
           }
         else
           {
            //--- if the model 3 is used and the open price is above the indicator
            if(IS_PATTERN_USAGE(3) && DiffLowMA(idx)<0.0)
              {
               //--- the low price is below the indicator
               result=m_pattern_3;
               //--- consider that this is a formed "piercing" and suggest to enter the market at the current price
               m_base_price=0.0;
              }
           }
        }
     }
//--- return the result
   return(result);
  }


E se você substituir este código pelo código de seu módulo, ele funcionará corretamente. O problema é que o conteúdo é ligeiramente diferente do seu. Há mais código aqui... hmm.


Se você simplesmente pegar meu código e colá-lo aqui, não vai funcionar.
 
Vladimir Karputov:

Se você simplesmente pegar meu código e colá-lo aqui, não vai funcionar.

Vladimir Karputov:

Se você apenas pegar meu código e colá-lo aqui - não vai funcionar.


Vladimir, onde devemos colar o inverso para que funcione?

É claro que você precisará criar uma cópia do arquivo e mudar o nome deste inlude.

 

Se você quiser mudar os sinais para inverter no módulo de sinal padrão:

  • criar uma cópia do arquivo com um nome diferente
  • Alterar a descrição do módulo

// wizard description start
//+------------------------------------------------------------------+
//| Description of the class                                         |
//| Title=***          |
//| Type=SignalAdvanced                                              |
//| Name=Moving Average                                              |

  • basta mudar os nomes das funções : LongCondition <--> ShortCondition

 
Vladimir Karputov:

Se você quiser mudar os sinais para inverter no módulo de sinal padrão:

  • criar uma cópia do arquivo com um nome diferente
  • Alterar a descrição do módulo

// wizard description start
//+------------------------------------------------------------------+
//| Description of the class                                         |
//| Title=***          |
//| Type=SignalAdvanced                                              |
//| Name=Moving Average                                              |

  • basta mudar os nomes das funções : LongCondition <--> ShortCondition


Vladimir, obrigado, você tem sido muito útil. Agora a questão continua sendo como fazer as ordens de Take Profit e Stop Loss que a EA coloca. Como faço para limitá-los?