Quaisquer perguntas de recém-chegados sobre MQL4 e MQL5, ajuda e discussão sobre algoritmos e códigos - página 62

 

Pessoal, qual é a melhor maneira de fazer isso: quero ver a distribuição de greves por perdas e negócios lucrativos... Eu não sou bom em arrays.

Depois de uma venda perdida

Price_LastSell=5; Vol=Vol*Y; Izm=2; Opn_B=true; k=k+1;

/* Buf1[p]=Buf1[p]+1; p=0;

Alerta ("Lucrativo", Buf1[1], ", ", Buf1[2], ", ", Buf1[3], ", ", Buf1[4], ", ", Buf1[5], ", ", Buf1[6], ", ", Buf1[7], ", ", Buf1[8], ", Buf1[9], ", Buf1[10]); */

após a venda lucrativa

Price_LastSell=5; Vol=VolumeOpen; Izm=2; Opn_S=true; p=p+1;

/* Buf2[k]=Buf2[k]+1; k=0;

Alerta ("Perdas", Buf2[1], ", ", Buf2[2], ", ", Buf2[3], ", ", Buf2[4], ", ", Buf2[5], ",", Buf2[6], ", ", ", Buf2[7], ", ", Buf2[8], ", ", Buf2[9], ", ", Buf2[10], ", ", Buf2[11], ", ", Buf2[12], ", ", Buf2[13], ", ", Buf2[14], ", Buf2[15]); */

O que há de errado aqui? Sem escrever para /* tudo funciona bem...

 
Сергей:

Pessoal, qual é a melhor maneira de fazer isso: quero ver a distribuição de greves por perdas e negócios lucrativos... Eu não sou bom em arrays.

Depois de uma venda perdida

Price_LastSell=5; Vol=Vol*Y; Izm=2; Opn_B=true; k=k+1;

/* Buf1[p]=Buf1[p]+1; p=0;

Alerta ("Lucrativo", Buf1[1], ", ", Buf1[2], ", ", Buf1[3], ", ", Buf1[4], ", ", Buf1[5], ", ", Buf1[6], ", ", Buf1[7], ", ", Buf1[8], ", Buf1[9], ", Buf1[10]); */

após a venda lucrativa

Price_LastSell=5; Vol=VolumeOpen; Izm=2; Opn_S=true; p=p+1;

/* Buf2[k]=Buf2[k]+1; k=0;

Alerta ("Perdas", Buf2[1], ", ", Buf2[2], ", ", Buf2[3], ", ", Buf2[4], ", ", Buf2[5], ",", Buf2[6], ", ", ", Buf2[7], ", ", Buf2[8], ", ", Buf2[9], ", ", Buf2[10], ", ", Buf2[11], ", ", Buf2[12], ", ", Buf2[13], ", ", Buf2[14], ", ", Buf2[15]); */

O que há de errado aqui? Sem escrever para /* tudo funciona bem...

Uh-oh... Quem são os "stricks" e o que é "sua distribuição"?
 

Uma série de negócios perdidos e lucrativos. Distribuição - por exemplo, temos 360 negócios perdidos (isso pode ser visto no relatório), 110 séries de 1 negócio perdido, 80 séries de 2 negócios perdidos e 30 de 3 negócios perdidos.

Eu o fiz desta maneira:

Depois de identificar o comércio perdido

k=k+1;

Depois de determinar um comércio lucrativo

se k===1 {k1=k1+1;}

se k===2 {k2=k2+1;}

se k===3 {k3=k3+1;}

k=0;

Mas esta entrada é muito grande e inconveniente para séries de 15 ou mais perdas

 
Сергей:

Uma série de negócios perdidos e lucrativos. Distribuição - por exemplo, temos 360 negócios perdidos (isso pode ser visto no relatório), 110 séries de 1 negócio perdido, 80 séries de 2 negócios perdidos e 30 de 3 negócios perdidos.

Eu o fiz desta maneira:

Depois de identificar o comércio perdido

k=k+1;

Depois de determinar um comércio lucrativo

se k===1 {k1=k1+1;}

se k===2 {k2=k2+1;}

se k===3 {k3=k3+1;}

k=0;

Mas esta notação é muito grande e inconveniente para séries de 15 ou mais perdas

Não estou muito claro sobre sua tarefa.

Você precisa determinar a série das últimas posições lucrativas/perdas, ou você precisa coletar todas essas séries de todo o histórico comercial?

 
Ao longo da história. Coletar e emitir dados no final do teste. Mas faço-o de forma simples: após o primeiro lucro depois de uma série de perdas, eu produzo um número separado por vírgula... Mas quero simplificar o código e usar arrays. É possível? E qual é a melhor maneira de fazer isso?
 
Ibragim Dzhanaev:

Fez isso, agora não abre em cada tique, mas passa sinais para a entrada...

double tp,sl,OrderBuy=0,OrderSell=0;
double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=OrdersTotal()-1; i>=0; i--) //Цикл по всем ордерам
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) //Выбрали ордер
        {
         if(OrderType()==OP_BUY)
           {
            TotalBiu++;                      //Кол. покупок
           }
         if(OrderType()==OP_SELL)
           {
            TotalSell++;                     //Кол. продаж
           }
        }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+

   double StopLossLevel;
   double TakeProfitLevel;
   if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
   if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;

   tpBuy=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   slBuy=NormalizeDouble(Bid-StopLoss*_Point,_Digits);

   tpSell=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
   slSell=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
///---
if(TotalBiu==0)
   if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);      
     }
      if(TotalSell==0)    
   if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed);      
     }
  }
//+------------------------------------------------------------------+


deve funcionar.

double tp,sl,OrderBuy=0,OrderSell=0;
double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=OrdersTotal()-1; i>=0; i--) //Цикл по всем ордерам
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) //Выбрали ордер
        {
         if(OrderType()==OP_BUY)
           {
            OrderBuy++;                      //Кол. покупок
           }
         if(OrderType()==OP_SELL)
           {
            OrderSell++;                     //Кол. продаж
           }
        }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+

   double StopLossLevel;
   double TakeProfitLevel;
   if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
   if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;

   tpBuy=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   slBuy=NormalizeDouble(Bid-StopLoss*_Point,_Digits);

   tpSell=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
   slSell=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
///---
   if(OrderBuy==0 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);  
      if(ticket<0)Print("Ошибка открытия ордера № - ",GetLastError());    
     }
   if(OrderSell==0 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed);  
      if(ticket<0)Print("Ошибка открытия ордера № - ",GetLastError());    
     }
  }
//+------------------------------------------------------------------+

...

 
Sergey Gritsay:

Fixou-o. Deve funcionar.

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=OrdersTotal()-1; i>=0; i--) //Цикл по всем ордерам
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) //Выбрали ордер
        {
         if(OrderType()==OP_BUY)
           {
            OrderBuy++;                      //Кол. покупок
           }
         if(OrderType()==OP_SELL)
           {
            OrderSell++;                     //Кол. продаж
           }
        }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+


meio que precisa de zerar o destaque

double tp,sl,OrderBuy=0,OrderSell=0;
double slSell,slBuy,tpSell,tpBuy;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  OrderBuy=0; OrderSell=0;
//-
   for(int i=OrdersTotal()-1; i>=0; i--) //Цикл по всем ордерам
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) //Выбрали ордер
        {
         if(OrderType()==OP_BUY)
           {
            OrderBuy++;                      //Кол. покупок
           }
         if(OrderType()==OP_SELL)
           {
            OrderSell++;                     //Кол. продаж
           }
        }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
   tpBuy=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   slBuy=NormalizeDouble(Bid-StopLoss*_Point,_Digits);

   tpSell=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
   slSell=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
///---
   if(OrderBuy==0 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);  
      if(ticket<0)Print("Ошибка открытия ордера № - ",GetLastError());    
     }
   if(OrderSell==0 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed);  
      if(ticket<0)Print("Ошибка открытия ордера № - ",GetLastError());    
     }
  }
//+------------------------------------------------------------------+
 
Vitaly Muzichenko:

tipo de necessidade de zerar o destacado

double tp,sl,OrderBuy=0,OrderSell=0;
double slSell,slBuy,tpSell,tpBuy;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  OrderBuy=0; OrderSell=0;
//-
   for(int i=OrdersTotal()-1; i>=0; i--) //Цикл по всем ордерам
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) //Выбрали ордер
        {
         if(OrderType()==OP_BUY)
           {
            OrderBuy++;                      //Кол. покупок
           }
         if(OrderType()==OP_SELL)
           {
            OrderSell++;                     //Кол. продаж
           }
        }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
   tpBuy=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   slBuy=NormalizeDouble(Bid-StopLoss*_Point,_Digits);

   tpSell=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
   slSell=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
///---
   if(OrderBuy==0 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);  
      if(ticket<0)Print("Ошибка открытия ордера № - ",GetLastError());    
     }
   if(OrderSell==0 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed);  
      if(ticket<0)Print("Ошибка открытия ордера № - ",GetLastError());    
     }
  }
//+------------------------------------------------------------------+

Obrigado. Agora abre algumas ordens que não estão em sinal e outras que não estão corretas.

 
Sergey Gritsay:

Fixou-o. Deve funcionar.

 

...

O que você escreveu não ajudou...
 
Ibragim Dzhanaev:

Obrigado. Agora abre algumas ordens que não estão em sinal e outras que não estão corretas.

Você verifica em uma barra existente rsi=iRSI dupla(_Símbolo,0,RSIperiod,PRICE_CLOSE,0);

O preço sobe, há uma cruz de nível 70 e a entrada no comércio. No fato de fechar a barra, você já vê que o LER é mais baixo, mas antes disso era mais alto, e depois voltou abaixo do nível.

Faça a verificação em um bar fechado, então isso não acontecerá, e as entradas estarão em um sinal confirmado:

duplo rsi=iRSI(_Símbolo,0,período de RSI,PREÇO_CLOSE,1);

duplo rsi1=iRSI(_Símbolo,0,período de RSI,PREÇO_CLOSE,2);

Razão: