[Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate oltre. Non potrei andare da nessuna parte senza di te - 2. - pagina 83

 

Per favore, aiutatemi. La versione dell'EA a pagina 82 funziona (scritta per aprire 1 tipo di trade), ma quella sotto (per tutti i tipi di ordine) si è rivelata avere un errore: apre gli ordini su ogni tick.

Qual è il mio errore?

extern int     Magic       = 0;        //уникальный номер ордера
extern bool    BUY         = false;    //открыть ордер BUY
extern bool    BUY_STOP    = false;    //поставить ордер BUY STOP
extern bool    BUY_LIMIT   = false;    //поставить ордер BUY LIMIT
extern bool    SELL        = false;    //открыть ордер SELL
extern bool    SELL_STOP   = false;    //поставить ордер SELL STOP
extern bool    SELL_LIMIT  = false;    //поставить ордер SELL LIMIT
extern double  Lot         = 0.1;      //объем ордера
extern int     takeprofit  = 0;        //уровень выставления TP, если 0, то TP не выставляется
extern int     stoploss    = 0;        //уровень выставления SL, если 0, то SL не выставляется
extern int     DistanceSet = 40;       //расстояние от рынка для отложенника
extern int     slippage    = 3;        //максимально допустимое отклонение цены для рыночных ордеров
//--------------------------------------------------------------------
double SL,TP;
//--------------------------------------------------------------------
int start()
{
   if (BUY)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy");
   }
   if (SELL)
   {  
      if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL = NormalizeDouble(Bid + stoploss*Point,Digits);  else SL=0;              
      OPENORDER ("Sell");
   }
   if (BUY_STOP)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + DistanceSet*Point + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask + DistanceSet*Point - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy Stop");
   }
   if (SELL_STOP)
   {  
      if (takeprofit!=0) TP = NormalizeDouble(Bid - DistanceSet*Point - takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL = NormalizeDouble(Bid - DistanceSet*Point + stoploss*Point,Digits);  else SL=0;              
      OPENORDER ("Sell Stop");
   }
   if (BUY_LIMIT)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask - DistanceSet*Point + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - DistanceSet*Point - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy Limit");
   }
   if (SELL_LIMIT)
   {  
      if (takeprofit!=0) TP = NormalizeDouble(Bid + DistanceSet*Point - takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL = NormalizeDouble(Bid + DistanceSet*Point + stoploss*Point,Digits);  else SL=0;              
      OPENORDER ("Sell Limit");
   }
return(0);
}
void OPENORDER(string ord)
{
int ticket = -1;
int err;
while (ticket<0)
{
if (ord=="Buy") ticket=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Sell") ticket=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Buy Stop" ) ticket=OrderSend(Symbol(),OP_BUYSTOP, Lot,NormalizeDouble(Ask + DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Sell Stop") ticket=OrderSend(Symbol(),OP_SELLSTOP,Lot,NormalizeDouble(Bid - DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Buy Limit" ) ticket=OrderSend(Symbol(),OP_BUYLIMIT, Lot,NormalizeDouble(Ask - DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Sell Limit") ticket=OrderSend(Symbol(),OP_SELLLIMIT,Lot,NormalizeDouble(Bid + DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ticket==-1) //неудачная попытка
{  
ShowERROR();
err++;Sleep(2000);RefreshRates();
}
}
return;
}
void ShowERROR()
{
   int err=GetLastError();
   switch ( err )
   {                  
      case 1:   return;
      case 2:   Alert("Нет связи с торговым сервером ",Symbol());return;
      case 3:   Alert("Error неправильные параметры ",Symbol());return;
      case 130: Alert("Error близкие стопы   Ticket ",Symbol());return;
      case 134: Alert("Недостаточно денег   ",Symbol());return;
      case 146: Alert("Error Подсистема торговли занята ",Symbol());return;
      case 129: Alert("Error Неправильная цена ",Symbol());return;
      case 131: Alert("Error Неправильный объем ",Symbol());return;
      case 4200:Alert("Error Объект уже существует ",Symbol());return;
   }
}

Vi ringrazio in anticipo.

 
nemo811:

Per favore, aiutatemi. La versione dell'EA a pagina 82 funziona (scritta per aprire 1 tipo di trade), ma quella sotto (per tutti i tipi di ordine) si è rivelata avere un errore: apre gli ordini su ogni tick.

Qual è il mio errore?

Vi ringrazio in anticipo.

dove si trova nel codice il controllo del numero di ordini?

 
nemo811:


In breve, qual è l'idea dietro l'EA? a prima vista, questo codice non aprirà affatto dei trade.

Ho cambiato i valori delle bandiere, i trade si sono aperti una volta, ma non capisco cosa sta facendo questo EA)))

 
nemo811:


extern int Magic = 0; //уникальный номер ордера
extern bool BUY = true; //открыть ордер BUY
extern bool BUY_STOP = true; //поставить ордер BUY STOP
extern bool BUY_LIMIT = true; //поставить ордер BUY LIMIT
extern bool SELL = true; //открыть ордер SELL
extern bool SELL_STOP = true; //поставить ордер SELL STOP
extern bool SELL_LIMIT = true; //поставить ордер SELL LIMIT
extern double Lot = 0.1; //объем ордера
extern int takeprofit = 0; //уровень выставления TP, если 0, то TP не выставляется
extern int stoploss = 0; //уровень выставления SL, если 0, то SL не выставляется
extern int DistanceSet = 40; //расстояние от рынка для отложенника
extern int slippage = 3; //максимально допустимое отклонение цены для рыночных ордеров
//--------------------------------------------------------------------
double SL,TP;
//--------------------------------------------------------------------
int start()
{
if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
OPENORDER ("Buy");
BUY=false;
}
if (SELL)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
OPENORDER ("Sell");
SELL=false;
}
if (BUY_STOP)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + DistanceSet*Point + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask + DistanceSet*Point - stoploss*Point,Digits); else SL=0;
OPENORDER ("Buy Stop");
BUY_STOP=false;

}
if (SELL_STOP)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - DistanceSet*Point - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid - DistanceSet*Point + stoploss*Point,Digits); else SL=0;
OPENORDER ("Sell Stop");
SELL_STOP=false;
}
if (BUY_LIMIT)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask - DistanceSet*Point + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - DistanceSet*Point - stoploss*Point,Digits); else SL=0;
OPENORDER ("Buy Limit");
BUY_LIMIT=false;
}
if (SELL_LIMIT)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid + DistanceSet*Point - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + DistanceSet*Point + stoploss*Point,Digits); else SL=0;
OPENORDER ("Sell Limit");
SELL_LIMIT=false;
}
return(0);
}
void OPENORDER(string ord)
{
int ticket = -1;
int err;
while (ticket<0)
{
if (ord=="Buy") ticket=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Sell") ticket=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Buy Stop" ) ticket=OrderSend(Symbol(),OP_BUYSTOP, Lot,NormalizeDouble(Ask + DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Sell Stop") ticket=OrderSend(Symbol(),OP_SELLSTOP,Lot,NormalizeDouble(Bid - DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Buy Limit" ) ticket=OrderSend(Symbol(),OP_BUYLIMIT, Lot,NormalizeDouble(Ask - DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Sell Limit") ticket=OrderSend(Symbol(),OP_SELLLIMIT,Lot,NormalizeDouble(Bid + DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ticket==-1) //неудачная попытка
{
ShowERROR();
err++;Sleep(2000);RefreshRates();
}
}
return;
}
void ShowERROR()
{
int err=GetLastError();
switch ( err )
{
case 1: return;
case 2: Alert("Нет связи с торговым сервером ",Symbol());return;
case 3: Alert("Error неправильные параметры ",Symbol());return;
case 130: Alert("Error близкие стопы Ticket ",Symbol());return;
case 134: Alert("Недостаточно денег ",Symbol());return;
case 146: Alert("Error Подсистема торговли занята ",Symbol());return;
case 129: Alert("Error Неправильная цена ",Symbol());return;
case 131: Alert("Error Неправильный объем ",Symbol());return;
case 4200:Alert("Error Объект уже существует ",Symbol());return;
}
}

In generale, apre gli ordini una volta e piazza un ordine pendente alla volta.

 
NameLess:


In breve, qual è l'idea dietro l'EA? a prima vista, questo codice non aprirà affatto dei trade.

Ho cambiato i valori delle bandiere, i trade si sono aperti una volta, ma non capisco cosa sta facendo questo EA)))


))))Questo fa parte di un altro EA. Mettendo insieme mattone per mattone ))
 
Il punto dell'altro è quello di prendere il profitto totale o il profitto separatamente per ogni coppia (conveniente quando si usa la diversificazione). + Trailing what you can e altre funzionalità. Questo è basato sul drknn universal_1_7 Expert Advisor
 
nemo811:
Il punto dell'altro è quello di prendere il profitto totale o il profitto separatamente per ogni coppia (conveniente quando si usa la diversificazione). + Trailing what you can e altre funzionalità. Stiamo usando drknn universal_1_7 Expert Advisor come base.

Questo codice non farà altro che sommare lo spread e la differenza tra le aperture, quindiotvno la versione attuale accumulerà il meno. non so dove verrà preso il profitto)
 
NameLess:

Questo codice aggiungerà semplicemente lo spread e la differenza tra le aperture, quindi la versione attuale accumulerà il meno).

Questa è una versione leggermente obsoleta di quello su cui sto lavorando ora. L'autore drknn mi ha dato il permesso di pubblicarlo.
File:
 
NameLess:

In generale, apre gli ordini una volta e piazza un ordine pendente alla volta.

Grazie, funziona! )) Dobbiamo ancora determinare come controllare il numero di ordini
 
nemo811:
Grazie, ha funzionato! )) Bisogna ancora determinare come controllare il numero di ordini


))) È un compito ingrato grattare il codice di qualcun altro per capire come funziona. Se hai fiducia nell'EA ti auguro buona fortuna e tutto si risolverà)

Personalmente ho inventato una bicicletta e ho scritto il mio gufo da zero, ma so dove e come funzionano le cose e so perché non funzionano e dove cercare gli errori)

Le cose stanno cos).

Motivazione: