Aiutatemi a scrivere un EA, grazie in anticipo - pagina 13

 
In cima, naturalmente, lasciate che tutti pensino.
 
edikjefimov:
Penso che gli indicatori sarà solo ritardare l'apertura dell'ordine, e un sacco di falsi segnali, penso che sia meglio mettere Shto chiuso a 000,00 quando si raggiunge, diciamo, 12 ordini o Shto cambiare questo numero può essere a volontà e a seconda del deposito
A proposito - non è una cattiva idea !!!!!!
 
//+------------------------------------------------------------------+
//|                                                        Канал.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));
}
// Окончание функции приведения значений к точности одного тика ---------------------------------------------------------------------// 
File:
gwssp.mq4  12 kb
 
)))A proposito - zig-zagare è più interessante!!!!!
 
OK, comincio a rendermi conto che sto perdendo la comprensione di come funziona questa strategia, se potessi descriverla di nuovo punto per punto e specificamente con esempi.
 
)))Tutto è esattamente lo stesso algoritmo descritto da Edik!!!!
 
Lucas_SPb:
)))Tutto è assolutamente secondo l'algoritmo descritto da Edik!!!!


Lo capisco, ma ora credo di vederla un po' diversamente, non so nemmeno come spiegarlo a parole...

Ecco perché ho chiesto di nuovo e punto per punto.

%)

 

Qui:

 

1.Controllare lo ZigZag (anche se si potrebbe anche aggiungere trovare il punto più basso del rientro)

2. Aprire un ordine di acquisto

3. Piazzare un ordine di vendita allo stesso tempo

4. Quando scatta un ordine di vendita, apriamo un ordine di acquisto, ecc.

5.In questo caso aumentiamo il lotto

 
scusate - non tutto il codice !!!! Non è arrivato alla fine della selezione