Ajuda na codificação - página 726

 

Olá, Mladen,

Estou tentando codificar isto no MT5, mas acho que não estou usando a implementação correta,

minha idéia é usar mais indicadores, por favor me dêem uma luz... ;-)

I need help to make this modular, because I will work with more indicators (6 to 8), 
this is a sample to understand I'm trying to do..

in this sample:
I put only 3 indicadors.

//global variables
bool m_buy = true;
bool m_sell = true;
enum Signal{
   IN_OUT=0,  //in & out
   IN=1,      //in
   OUT=2,     //out
};

I have a EA with indicators that I want to mix and optimize it in BackTest.

//some sample data for signal for In/Out states only for exemplification
iT_InOut = IN_OUT;  //Itrend usage => In & Out
RSI_InOut = IN_;     //RSI usage =>only IN 
MFI_InOut = OUT_;     //MFI usage =>only OUT
//

//this is the complete sequence IF I USE all signals in+out
//only to show the completly sequence (I will not use it)
m_buy=(m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0] && m_rsi0[0]>m_rsi1[0] && m_mfi0[0]>m_mfi1[0]);
// The green is growing and more than red, RSI is growing, MFI is growing
m_sell=(m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0] && m_rsi0[0]<m_rsi1[0] && m_mfi0[0]<m_mfi1[0]);
// The green falls and less than red, RSI falls, MFI falls


//now the skeleton that I'm trying to make work (in future I will use much more indicators)
               
              if(!PositionSelect(Symbol()))   ///No opened it's first entrance
                 {              
                 
                 if (!iT_InOut==OUT_) //Itrend (only options with IN)
                     {
                     m_buy= (m_buy  && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
                     m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
                     }
                  
                 if (!RSI_InOut==OUT_) //RSI (only options with IN)
                     {
                     m_buy =(m_buy  && m_rsi0[0]>m_rsi1[0]);
                     m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
                     }                
                
                 if (!MFI_InOut==OUT_) //MFI (only options with IN)
                     {
                     m_buy =(m_buy  && m_mfi0[0]>m_mfi1[0]);
                     m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
                     }                 
                  }
                 
                 ///We have opened order it's EXIT
                 else
                 {
                 //Itrend (only options with EXIT)
                 if (!iT_InOut==IN_)
                     {
                     m_buy =(m_buy  && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
                     m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
                     }
                 //RSI (only options with EXIT)
                 if (!RSI_InOut==IN_)
                     {
                     m_buy =(m_buy  && m_rsi0[0]>m_rsi1[0]);
                     m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
                     }                     
                 //MFI (only options with EXIT)
                 if (!MFI_InOut==IN_)
                     {
                     m_buy =(m_buy  && m_mfi0[0]>m_mfi1[0]);
                     m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
                     }
                 }
 
baraozemo:

Olá, Mladen,

Estou tentando codificar isto no MT5, mas acho que não estou usando a implementação correta,

minha idéia é usar mais indicadores, por favor me dêem uma luz... ;-)

I need help to make this modular, because I will work with more indicators (6 to 8), 
this is a sample to understand I'm trying to do..

in this sample:
I put only 3 indicadors.

//global variables
bool m_buy = true;
bool m_sell = true;
enum Signal{
   IN_OUT=0,  //in & out
   IN=1,      //in
   OUT=2,     //out
};

I have a EA with indicators that I want to mix and optimize it in BackTest.

//some sample data for signal for In/Out states only for exemplification
iT_InOut = IN_OUT;  //Itrend usage => In & Out
RSI_InOut = IN_;     //RSI usage =>only IN 
MFI_InOut = OUT_;     //MFI usage =>only OUT
//

//this is the complete sequence IF I USE all signals in+out
//only to show the completly sequence (I will not use it)
m_buy=(m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0] && m_rsi0[0]>m_rsi1[0] && m_mfi0[0]>m_mfi1[0]);
// The green is growing and more than red, RSI is growing, MFI is growing
m_sell=(m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0] && m_rsi0[0]<m_rsi1[0] && m_mfi0[0]<m_mfi1[0]);
// The green falls and less than red, RSI falls, MFI falls


//now the skeleton that I'm trying to make work (in future I will use much more indicators)
               
              if(!PositionSelect(Symbol()))   ///No opened it's first entrance
                 {              
                 
                 if (!iT_InOut==OUT_) //Itrend (only options with IN)
                     {
                     m_buy= (m_buy  && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
                     m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
                     }
                  
                 if (!RSI_InOut==OUT_) //RSI (only options with IN)
                     {
                     m_buy =(m_buy  && m_rsi0[0]>m_rsi1[0]);
                     m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
                     }                
                
                 if (!MFI_InOut==OUT_) //MFI (only options with IN)
                     {
                     m_buy =(m_buy  && m_mfi0[0]>m_mfi1[0]);
                     m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
                     }                 
                  }
                 
                 ///We have opened order it's EXIT
                 else
                 {
                 //Itrend (only options with EXIT)
                 if (!iT_InOut==IN_)
                     {
                     m_buy =(m_buy  && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
                     m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
                     }
                 //RSI (only options with EXIT)
                 if (!RSI_InOut==IN_)
                     {
                     m_buy =(m_buy  && m_rsi0[0]>m_rsi1[0]);
                     m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
                     }                     
                 //MFI (only options with EXIT)
                 if (!MFI_InOut==IN_)
                     {
                     m_buy =(m_buy  && m_mfi0[0]>m_mfi1[0]);
                     m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
                     }
                 }
Nesse código eu não vejo o uso do indicador (e como os valores são copiados para as matrizes correspondentes)
 

Olá, pessoal,

Eu realmente preciso de ajuda, estou construindo um especialista com o indicador de escalpe waddah attar, a lógica está funcionando, tudo está bem.

Exceto uma coisa, como você vê na tela de fundo, em cada barra verde o especialista abre uma compra, o mesmo para as barras vermelhas. Eu quero apenas 1 troca por mudança de cor.

O que eu quero é :

INDICADOR TURNS GREEN ---> abre uma compra ---> a compra fecha ---> INDICADOR TURNS RED ---> abre uma venda ---> a venda fecha ---> repete

Quero apenas 1 comércio por mudança de cor.

Aqui está meu código : (o mesmo para abreviar)

//Trading decision.
   bool SendLong = false, SendShort = false;
  
    double clnowsell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar);
    double clpresell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar+1);
  
    double clnowbuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar);
    double clprebuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar+1);

   //Long trade
  
   //Specific system filters
   //if (some condition) SendLong = true;
  
   if (clnowbuy > 0) SendLong = true;

Alguém pode por favor vir com uma solução simples, veja a linha 1265, a lógica vem aqui.

Muito obrigado!

 
LittleCaro:

Olá, pessoal,

Eu realmente preciso de ajuda, estou construindo um especialista com o indicador de escalpe waddah attar, a lógica está funcionando, tudo está bem.

Exceto uma coisa, como você vê na tela de fundo, em cada barra verde o especialista abre uma compra, o mesmo para as barras vermelhas. Eu quero apenas 1 troca por mudança de cor.

O que eu quero é :

INDICADOR TURNS GREEN ---> abre uma compra ---> a compra fecha ---> INDICADOR TURNS RED ---> abre uma venda ---> a venda fecha ---> repete

Quero apenas 1 comércio por mudança de cor.

Aqui está meu código : (o mesmo para abreviar)

//Trading decision.
   bool SendLong = false, SendShort = false;
  
    double clnowsell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar);
    double clpresell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar+1);
  
    double clnowbuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar);
    double clprebuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar+1);

   //Long trade
  
   //Specific system filters
   //if (some condition) SendLong = true;
  
   if (clnowbuy > 0) SendLong = true;

Alguém pode por favor vir com uma solução simples, veja a linha 1265, a lógica vem aqui.

Muito obrigado!

Mude a condição para

  if (clnowbuy > 0 && clprebuy == 0) SendLong = true;

O mesmo para os calções

 

Obrigado Mladen!

Às vezes ficamos presos, e precisamos de um novo olhar sobre nosso trabalho.

Mais uma vez obrigado !

 
LittleCaro:

Obrigado Mladen!

Às vezes ficamos presos, e precisamos de um novo olhar sobre nosso trabalho.

Mais uma vez obrigado !

Bonjour,

Ravi de voir une Française, tiens moi au courant des tes résultats avec waddah attar ;)

Pips verdes

 

Oi pessoal, estou tentando editar um indicador ema-rsi que pode mostrar uma seta para cima ou para baixo quando 4 ema cross acontece e rsi é > ou < 50.

Meu problema é que essas setas não atualizam paracada tique uma vez que apareceram, preciso mudar o tempo se quiser verificar se as condições ainda estão boas para mostrar a seta. Você pode me dizer onde está o problema? Eu afixo o código.

Obrigado.

#property indicator_chart_window
#property indicator_buffers 2
#property  indicator_color1 Green
#property  indicator_color2 Red

#property  indicator_width1 4
#property  indicator_width2 4

double CrossUp[];
double CrossDown[];
extern int FasterEMA1     = 6;
extern int SlowerEMA1     = 12;
extern int FasterEMA2     = 7;
extern int SlowerEMA2     = 14;
extern int RSInowPeriod   = 6;
extern int barsBack       = 2000;
extern bool AlertsMessage = true;
extern bool AlertsSound   = true;
extern bool debug         = false;
extern double K           = 1.0 ;

bool EMACrossedUp = false;
bool RSICrossedUp = false;
bool EMACrossedDown = false;
bool RSICrossedDown = false;
int SignalLabeled = 0// 0: initial state; 1: up; 2: down.
int upalert=false,downalert=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0DRAW_ARROWEMPTY);
   SetIndexArrow(0241);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1DRAW_ARROWEMPTY);
   SetIndexArrow(1242);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double fasterEMA1now, slowerEMA1now, fasterEMA1previous, slowerEMA1previous, fasterEMA2now, slowerEMA2now, fasterEMA2previous, slowerEMA2previous;
   double RSInow;
   double Range, AvgRange;

   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=MathMin(Bars-counted_bars,barsBack);
   
   for(i = limit; i>=0; i--) {
       
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
        AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;

      fasterEMA1now = iMA(NULL0, FasterEMA1, 0MODE_EMAPRICE_CLOSE, i);
      fasterEMA1previous = iMA(NULL0, FasterEMA1, 0MODE_EMAPRICE_CLOSE, i+1);
      
      fasterEMA2now = iMA(NULL0, FasterEMA2, 0MODE_EMAPRICE_CLOSE, i);
      fasterEMA2previous = iMA(NULL0, FasterEMA2, 0MODE_EMAPRICE_CLOSE, i+1);
      
      slowerEMA1now = iMA(NULL0, SlowerEMA1, 0MODE_EMAPRICE_CLOSE, i);
      slowerEMA1previous = iMA(NULL0, SlowerEMA1, 0MODE_EMAPRICE_CLOSE, i+1);
      
      slowerEMA2now = iMA(NULL0, SlowerEMA2, 0MODE_EMAPRICE_CLOSE, i);
      slowerEMA2previous = iMA(NULL0, SlowerEMA2, 0MODE_EMAPRICE_CLOSE, i+1);
      
      RSInow=iRSI(NULL,0,RSInowPeriod,PRICE_CLOSE,i);
      
      if (RSInow > 50) {
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" RSI UP ");
         RSICrossedUp = true;
         RSICrossedDown = false;
      }
      
      if (RSInow < 50) {
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" RSI DOWN ");
         RSICrossedUp = false;
         RSICrossedDown = true;
      }
      
      if ((fasterEMA1now >= slowerEMA1now) && (fasterEMA1previous < slowerEMA1previous) && (fasterEMA2now >= slowerEMA2now) && (fasterEMA2previous < slowerEMA2previous) ) {
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" EMA UP ");
         EMACrossedUp = true;
         EMACrossedDown = false;
      }

      if ((fasterEMA1now <= slowerEMA1now) && (fasterEMA1previous > slowerEMA1previous) && (fasterEMA2now <= slowerEMA2now) && (fasterEMA2previous > slowerEMA2previous)) {
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" EMA DOWN ");
         EMACrossedUp = false;
         EMACrossedDown = true;
      }

      if ((EMACrossedUp == true) && (RSICrossedUp == true) && (SignalLabeled != 1)) {
         CrossUp[i] = Low[i] - K*Range;
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" SIGNAL UP ");
         if(i<=2 && AlertsMessage && !upalert)
           {
            Alert (Symbol()," ",Period(),"M  BUY SIGNAL ");
            //SendMail("EMA Cross Up on "+Symbol(),"");
            upalert=true;
            downalert=false;
           }           
         if(i<=2 && AlertsSound && !upalert)
           {
            PlaySound("alert.wav");
            upalert=true;
            downalert=false;
           }
         SignalLabeled = 1;
      }

      else if ((EMACrossedDown == true) && (RSICrossedDown == true) && (SignalLabeled != 2)) {
         CrossDown[i] = High[i] + K*Range;
         if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" SIGNAL DOWN ");
         if(i<=2 && AlertsMessage && !downalert)
           {
            Alert (Symbol()," ",Period(),"M  SELL SIGNAL ");
            //SendMail("EMA Cross Down on "+Symbol(),"");
            downalert=true;
            upalert=false;
           }
         if(i<=2 && AlertsSound && !downalert)
           {
            PlaySound("alert.wav");
            downalert=true;
            upalert=false;
           }
         SignalLabeled = 2;
      }
   }
   return(0);
}
//end
 
mladen:
Nesse código eu não vejo o uso do indicador (e como os valores são copiados para as matrizes correspondentes)

Olá, Mladen,

Aqui está o "sample-ea-modular.mq5" com algum código dentro... e com a interface que tem a Idéia que eu quero.

Estou tentando torná-lo modular , a idéia é otimizar separadamente dentro/fora de cada indicador...

Se eu puder fazer isso com o "sample-ea-modular.mq5", mudarei o EA real.

a base real é o Ea-sample.mq5. (estou afixando apenas para você ver todos os indicadores)

Arquivos anexados:
 
oguz:

Prezado @mladen,

Se você for capaz de resolver o erro mencionado abaixo, por favor, fique muito satisfeito.

Obrigado...

"Pergunta : Há um aviso quando eu atesto que há um gráfico e uso de compensação automática de gmt.


Advertência como esta: Aviso, use o GMToffset manual somente no backtest.

O cálculo automático de offset GMT funciona somente em negociação ao vivo/demo
e deve ser definido como FALSO para testes de retaguarda - teste de estratégia.

Isto é normal? Ou devo tornar o gmt automático compensado em falso?

Resposta : Desliguei o AutoGMTOffset e ajustei o offset GMT manualmente. Chega de mensagem de aviso e parece estar funcionando muito bem na demonstração. Vá em figura. Talvez seja um bug. Oh sim, é definitivamente um bug.

Eu olhei para o código e uma operação "outra" ou é omitida ou mal colocada. A mensagem só deve ser emitida se o UseAutoGMTOffset estiver configurado para FALSE.

Portanto, ignore esta mensagem e fique feliz. Tudo está funcionando como (ahem) projetado".

oguz

Como sempre (você já sabe disso) eu não comento o código descompilado, mas vejo que você está no caminho certo: se ele funciona (a opção), use-o. Se não funcionar, então não o utilize. Na minha opinião, isso é apenas uma mensagem (não um erro), então ...

 

Prezado @mladen,

Se você for capaz de resolver o erro mencionado abaixo, por favor, fique muito satisfeito.

Obrigado...

"Pergunta : Há um aviso quando eu atesto que há um gráfico e uso de compensação automática de gmt.


Advertência como esta: Aviso, use o GMToffset manual somente no backtest.

O cálculo automático de offset GMT funciona somente em negociação ao vivo/demo
e deve ser definido como FALSO para testes de retaguarda - teste de estratégia.

Isto é normal? Ou devo tornar o gmt automático compensado em falso?

Resposta : Desliguei o AutoGMTOffset e ajustei o offset GMT manualmente. Chega de mensagem de aviso e parece estar funcionando muito bem na demonstração. Vá em figura. Talvez seja um bug. Oh sim, é definitivamente um bug.

Eu olhei para o código e uma operação "outra" ou é omitida ou mal colocada. A mensagem só deve ser emitida se o UseAutoGMTOffset estiver configurado para FALSE.

Portanto, ignore esta mensagem e fique feliz. Tudo está funcionando como (ahem) projetado".
Razão: