Ajude-me a escrever um EA, obrigado de antemão - página 13

 
Para o topo, é claro, deixe todos pensarem.
 
edikjefimov:
Acho que os indicadores só atrasarão a abertura da ordem, e muitos sinais falsos, acho que é melhor colocar Shto fechado em 000,00 quando chegar, digamos, a 12 ordens ou Shto mudar este número pode ser à vontade e dependendo do depósito
A propósito - não é uma má idéia !!!!!!
 
//+------------------------------------------------------------------+
//|                                                        Канал.mq4 |
//|                                          Copyright © 2011, Лукас |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Лукас"
#property link      "http://www.metaquotes.net"
extern int    magicnumber    = 1210;
extern double  Nach_Lot = 0.05;

extern int SL_BUY  = 500; 
extern int TP_BUY  = 700;
extern int Shirina_Kanala_STOP  = 200;

//int SL_SELL  = 400; 
//int TP_SELL  = 400; 
double Lot,Lot_BUY,Lot_SELL,Min_Lot;
string TF,Metka;
int Ticket_Open_BUYSTOP, Ticket_Open_SELLSTOP,Ticket_Open_BUY,Ticket_Open_SELL;
double Cena_Otkr_BUY,Cena_Otkr_SELL,TP_Otkr_BUY,SL_Otkr_BUY,TP_Otkr_SELL,SL_Otkr_SELL;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   Lot=Nach_Lot;
   Lot_BUY=Nach_Lot;
   Lot_SELL=Nach_Lot;
   Min_Lot =MarketInfo(Symbol(), MODE_MINLOT);   
   //StopLevel = ND(MarketInfo(Symbol(), MODE_STOPLEVEL)*Point);  
   return(0);

  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  Metka=Symbol()+"-''Канал(v.1.0)''";

 double ZigZag_0=iCustom(NULL, 0, "ZigZag",12,5,3,1,0);
 double ZigZag_1=iCustom(NULL, 0, "ZigZag",12,5,3,1,1);
 
if((CalculateCurrentOrders_STOP(Symbol())==1)&&(CalculateCurrentOrders_OPEN(Symbol())==0))
  {
    Close_Order_BUYSTOP();
    Close_Order_SELLSTOP();
  }
if  (ZigZag_0>ZigZag_1)
{  
if((CalculateCurrentOrders_STOP(Symbol())==0)&&(CalculateCurrentOrders_OPEN(Symbol())==0))
  {
    Lot_BUY=Nach_Lot;
    Ticket_Open_BUY=OrderSend(Symbol(),OP_BUY,Lot_BUY,Ask,3,ND(Bid-SL_BUY*Point),ND(Ask+TP_BUY*Point),Metka,magicnumber,0,Green);
    Cena_Otkr_BUY=ND(Ask);
    TP_Otkr_BUY=ND(Ask+TP_BUY*Point);
    SL_Otkr_BUY=ND(Bid-SL_BUY*Point);
    TP_Otkr_SELL=SL_Otkr_BUY;
    SL_Otkr_SELL=TP_Otkr_BUY;
    Cena_Otkr_SELL=ND(Ask-Shirina_Kanala_STOP*Point);
    Lot_SELL=Nach_Lot*2;
    Ticket_Open_SELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,Lot_SELL,Cena_Otkr_SELL,3,SL_Otkr_SELL,TP_Otkr_SELL,Metka,magicnumber,0,Blue);
  }
}  
if((CalculateCurrentOrders_STOP(Symbol())==0)&&(CalculateCurrentOrders_OPEN(Symbol())==1))
  { 
    Lot_BUY=Nach_Lot*4;
    Ticket_Open_BUYSTOP=OrderSend(Symbol(),OP_BUYSTOP,Lot_BUY,Cena_Otkr_BUY,3,SL_Otkr_BUY,TP_Otkr_BUY,Metka,magicnumber,0,Blue);
  }
  
if((CalculateCurrentOrders_SELL(Symbol())==1)&&(CalculateCurrentOrders_BUY(Symbol())==2)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_SELL=Nach_Lot*8;
    Ticket_Open_SELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,Lot_SELL,Cena_Otkr_SELL,3,SL_Otkr_SELL,TP_Otkr_SELL,Metka,magicnumber,0,Blue);
  }  
  
if((CalculateCurrentOrders_SELL(Symbol())==2)&&(CalculateCurrentOrders_BUY(Symbol())==2)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_BUY=Nach_Lot*16;
    Ticket_Open_BUYSTOP=OrderSend(Symbol(),OP_BUYSTOP,Lot_BUY,Cena_Otkr_BUY,3,SL_Otkr_BUY,TP_Otkr_BUY,Metka,magicnumber,0,Blue);
  }  
  
if((CalculateCurrentOrders_SELL(Symbol())==2)&&(CalculateCurrentOrders_BUY(Symbol())==3)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_SELL=Nach_Lot*32;
    Ticket_Open_SELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,Lot_SELL,Cena_Otkr_SELL,3,SL_Otkr_SELL,TP_Otkr_SELL,Metka,magicnumber,0,Blue);
  }  
  
if((CalculateCurrentOrders_SELL(Symbol())==3)&&(CalculateCurrentOrders_BUY(Symbol())==3)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_BUY=Nach_Lot*64;
    Ticket_Open_BUYSTOP=OrderSend(Symbol(),OP_BUYSTOP,Lot_BUY,Cena_Otkr_BUY,3,SL_Otkr_BUY,TP_Otkr_BUY,Metka,magicnumber,0,Blue);
  }  

if((CalculateCurrentOrders_SELL(Symbol())==3)&&(CalculateCurrentOrders_BUY(Symbol())==4)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_SELL=Nach_Lot*128;
    Ticket_Open_SELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,Lot_SELL,Cena_Otkr_SELL,3,SL_Otkr_SELL,TP_Otkr_SELL,Metka,magicnumber,0,Blue);
  }   
  
if((CalculateCurrentOrders_SELL(Symbol())==4)&&(CalculateCurrentOrders_BUY(Symbol())==4)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_BUY=Nach_Lot*256;
    Ticket_Open_BUYSTOP=OrderSend(Symbol(),OP_BUYSTOP,Lot_BUY,Cena_Otkr_BUY,3,SL_Otkr_BUY,TP_Otkr_BUY,Metka,magicnumber,0,Blue);
  } 
  
if((CalculateCurrentOrders_SELL(Symbol())==4)&&(CalculateCurrentOrders_BUY(Symbol())==5)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_SELL=Nach_Lot*512;
    Ticket_Open_SELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,Lot_SELL,Cena_Otkr_SELL,3,SL_Otkr_SELL,TP_Otkr_SELL,Metka,magicnumber,0,Blue);
  } 
  
if((CalculateCurrentOrders_SELL(Symbol())==5)&&(CalculateCurrentOrders_BUY(Symbol())==5)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_BUY=Nach_Lot*1024;
    Ticket_Open_BUYSTOP=OrderSend(Symbol(),OP_BUYSTOP,Lot_BUY,Cena_Otkr_BUY,3,SL_Otkr_BUY,TP_Otkr_BUY,Metka,magicnumber,0,Blue);
  }
  
if((CalculateCurrentOrders_SELL(Symbol())==5)&&(CalculateCurrentOrders_BUY(Symbol())==6)&&(CalculateCurrentOrders_STOP(Symbol())==0))
  { 
    Lot_SELL=Nach_Lot*2048;
    Ticket_Open_SELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,Lot_SELL,Cena_Otkr_SELL,3,SL_Otkr_SELL,TP_Otkr_SELL,Metka,magicnumber,0,Blue);
  }  
        
  /*
if((CalculateCurrentOrders_STOP(Symbol())==0)&&(CalculateCurrentOrders_OPEN(Symbol())==0))
  {
    if (Key_BUY==true) Ticket_Open_BUYSTOP=OrderSend(Symbol(),OP_BUYSTOP,Lot_BUY,Cena_Buy,3,SL_Buy,TP_Buy1,Metka,magicnumber,0,Blue);
    if (Key_SELL==true) Ticket_Open_SELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,Lot_SELL,Cena_Sell,3,SL_Sell,TP_Sell1,Metka,magicnumber,0,Blue);
  }
  */
 
  
  
  
   return(0);
  }
//+------------------------------------------------------------------+

//***********************************************************************************************************************************//
// Функция определения количества отложенных стоп ордеров ---------------------------------------------------------------------------//
//***********************************************************************************************************************************//
int CalculateCurrentOrders_STOP(string symbol)
{
   int buys=0,sells=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==magicnumber)
        {
         if(OrderType()==OP_BUYSTOP)  buys++;
         if(OrderType()==OP_SELLSTOP) sells++;
        }
     }
//---- return orders volume
   return(buys+sells);   
}
// Окончание функции определения количества отложенных стоп ордеров------------------------------------------------------------------//










//***********************************************************************************************************************************//
// Функция определения количества открытых ордеров ----------------------------------------------------------------------------------//
//***********************************************************************************************************************************//
int CalculateCurrentOrders_OPEN(string symbol)
  {
   int buys=0,sells=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==magicnumber)
        {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
        }
     }
//---- return orders volume
   if(buys>0) return(buys);
   else       return(-sells);
  }
// Окончание функции определения количества открытых ордеров--------------------------------------------------------------------------//

//***********************************************************************************************************************************//
// Функция определения количества открытых ордеров BUY ------------------------------------------------------------------------------//
//***********************************************************************************************************************************//
int CalculateCurrentOrders_BUY(string symbol)
  {
   int buys_b=0,sells_b=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==magicnumber)
        {
         if(OrderType()==OP_BUY)  buys_b++;
        }
     }
   if(buys_b>0) return(buys_b);
   else       return(-sells_b);
  }
// Окончание функции определения количества открытых ордеров BUY --------------------------------------------------------------------//

//***********************************************************************************************************************************//
// Функция определения количества открытых ордеров SELL -----------------------------------------------------------------------------//
//***********************************************************************************************************************************//
int CalculateCurrentOrders_SELL(string symbol)
  {
   int buys_s=0,sells_s=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==magicnumber)
        {
         if(OrderType()==OP_SELL)  sells_s++;
        }
     }
   if(sells_s>0) return(sells_s);
   else       return(-buys_s);
  }
// Окончание функции определения количества открытых ордеров SELL -------------------------------------------------------------------//







//***********************************************************************************************************************************//
// Функция приведения значений к точности одного тика -------------------------------------------------------------------------------//
//***********************************************************************************************************************************//
double ND(double A)
{
 return(NormalizeDouble(A, Digits));
}
// Окончание функции приведения значений к точности одного тика ---------------------------------------------------------------------// 
Arquivos anexados:
gwssp.mq4  12 kb
 
)))A propósito - zig-zagging is more interesting!!!!!
 
OK, estou começando a perceber que estou perdendo meu entendimento de como esta estratégia funciona, se você pudesse descrevê-la novamente ponto por ponto e especificamente com exemplos.
 
)))Tudo é exatamente o mesmo algoritmo descrito por Edik!!!!
 
Lucas_SPb:
)))Tudo está absolutamente de acordo com o algoritmo descrito por Edik!!!!


Entendo, mas agora acho que vejo um pouco diferente, não sei nem como explicar por palavras...

Foi por isso que perguntei novamente e ponto por ponto.

%)

 

Aqui :

 

1.Verifique o ZigZag (embora você também possa acrescentar o ponto inferior do travessão)

2.Abrir uma ordem de compra

3. fazer uma ordem de venda ao mesmo tempo

4.Quando um pedido de Venda é acionado, abrimos um pedido de Compra, etc.

5.Neste caso, aumentamos o lote

 
desculpe - nem todo o código !!!! Não chegou ao final da seleção