#property version"1.00"#property strictint test_ticket[2]={0,0};
double gl_lots,
gl_ask,
gl_bid;
string gl_comm;
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit() {
//---//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason) {
//---
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick() {
gl_lots=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
gl_ask=NormalizeDouble(Ask,_Digits);
gl_bid=NormalizeDouble(Bid,_Digits);
gl_comm="test";
//---if(AccountFreeMarginCheck(_Symbol,OP_BUY,gl_lots)<=0 || GetLastError()==134) {
printf("Not enough money for the minimum lot: %.4f",gl_lots);
return;
}
if(test_ticket[1]<8 && test_ticket[0]==0) {
test_ticket[0]=OrderSend((StringCompare(_Symbol,"NZDUSD")==0?"NZDUSD":_Symbol),OP_BUY,gl_lots,gl_ask,30,0.0,0.0,gl_comm,33333,0,clrNONE);
if(test_ticket[0]>0) test_ticket[1]++;
elseif(Fun_Error(GetLastError())==1) return;
}
if(test_ticket[0]>0)
if(OrderSelect(test_ticket[0],SELECT_BY_TICKET)) {
if(OrderCloseTime()==0 && OrderOpenTime()+300<TimeCurrent())
if(OrderClose(test_ticket[0],OrderLots(),gl_bid,30,clrNONE)) {
printf("Test order closed, ticket #%d",test_ticket[0]);
test_ticket[0]=0;
} elseif(Fun_Error(GetLastError())==1) return;
} elseif(Fun_Error(GetLastError())==1) return;
}
//+-------------- ФУНКЦИЯ ОБРАБОТКИ ОШИБОК ---------------------------------+int Fun_Error(int Error)
{
switch(Error)
{
case0: return (0);
case1: Print("Trying to change already set values with the same values.");return(1);
case2: Print("Common mistake. Stop all trading attempts until the circumstances are clarified.");return(0);
case3: Print("Wrong parameters passed to the trading function.");return(1);
case4: Print("The trading server is busy. Let's try again ..");Sleep(3000);return(1);
case5: Print("Old version of the client terminal.");return(0);
case6: Print("No connection to the trading server.");return(1);
case7: Print("Not enough rights.");return(1);
case8: Print("Too frequent requests.");return(1);
case9: Print("Invalid operation disrupting server operation.");return(1);
case64: Print("The account is blocked. It is necessary to stop all attempts at trading operations.");return(0);
case65: Print("Invalid account number.");return(1);
case128: Print("The transaction has expired.");return(1);
case129: Print("Wrong bid or ask price, possibly not normalized price.");return(1);
case130: Print("Stops that are too close or incorrectly calculated or abnormal prices in stops (or in the opening price of a pending order).");return(1);
case131: Print("Wrong volume, error in granulation of volume.");return(1);
case132: Print("The market is closed.");return(1);
case133: Print("Trade is prohibited.");return(0);
case134: Print("Not enough money to complete the operation.");return(0);
case135: Print("The price has changed. We try again ..");RefreshRates();return(1);
case136: Print("No price. We are waiting for a new tick ..");
while(RefreshRates()==false)// До нового тикаSleep(1);
return(1);
case137: Print("The broker is busy. Let's try again ..");Sleep(3000);return(1);
case138: Print("The requested price is out of date, or bid and ask are confused.");return(1);
case139: Print("The order is blocked and is already being processed.");return(1);
case140: Print("Only purchase allowed. You cannot repeat the SELL operation.");return(1);
case141: Print("Too many requests.");return(1);
case142: Print("The order is queued.");return(1);
case143: Print("The order has been accepted by the dealer for execution.");return(1);
case144: Print("The order is canceled by the client upon manual confirmation of the transaction.");return(1);
case145: Print("Modification is prohibited, because the order is too close to the market and is blocked due to possible early execution.");return(1);
case146: Print("The trading subsystem is busy. Let's try again ..");Sleep(500);return(1);
case147: Print("Using the expiration date of the order is prohibited by the broker.");return(1);
case148: Print("The number of open and pending orders has reached the limit set by the broker.");return(1);
case149: Print("An attempt to open an opposite position to an existing one if hedging is prohibited.");return(1);
case4000: return (0);
case4001: Print("Invalid function pointer.");return(1);
case4002: Print("Array index is out of range.");return(1);
case4003: Print("No memory for function stack.");return(1);
case4004: Print("Stack overflow after recursive call.");return(1);
case4005: Print("There is no memory on the stack for passing parameters.");return(1);
case4006: Print("There is no memory for the string parameter.");return(1);
case4007: Print("There is no memory for the time line.");return(1);
case4008: Print("Uninitialized string.");return(1);
case4009: Print("An uninitialized string in an array.");return(1);
case4010: Print("There is no memory for the string array.");return(1);
case4011: Print("Line is too long.");return(1);
case4012: Print("The remainder of division by zero.");return(1);
case4013: Print("Division by zero.");return(1);
case4014: Print("Unknown team.");return(1);
case4015: Print("Wrong transition.");return(1);
case4016: Print("Uninitialized array.");return(1);
case4017: Print("DLL calls are not allowed.");return(1);
case4018: Print("Unable to load library.");return(1);
case4019: Print("Unable to call function.");return(1);
case4020: Print("Calls to external library functions are not allowed.");return(1);
case4021: Print("There is not enough memory for the string returned from the function.");return(1);
case4022: Print("The system is busy.");return(1);
case4050: Print("Incorrect number of function parameters.");return(1);
case4051: Print("Invalid function parameter value.");return(1);
case4052: Print("Internal error of string function.");return(1);
case4053: Print("Array error.");return(1);
case4054: Print("Misuse of timeseries array.");return(1);
case4055: Print("Custom indicator error.");return(1);
case4056: Print("Arrays are incompatible.");return(1);
case4057: Print("Error processing global variables.");return(1);
case4058: Print("Global variable not detected.");return(1);
case4059: Print("Function not allowed in test mode.");return(1);
case4060: Print("Enter the HTTP address !!!.");return(1);
case4061: Print("Error sending mail.");return(1);
case4062: Print("A parameter of type string is expected.");return(1);
case4063: Print("A parameter of type integer is expected.");return(1);
case4064: Print("A parameter of type double is expected.");return(1);
case4065: Print("An array is expected as a parameter.");return(1);
case4066: Print("The requested historical data is in an update state.");return(1);
case4067: Print("An error occurred while performing a trading operation.");return(1);
case4099: Print("End of file.");return(1);
case4100: Print("An error occurred while working with the file.");return(1);
case4101: Print("Invalid file name.");return(1);
case4102: Print("Too many open files.");return(1);
case4103: Print("Unable to open file.");return(1);
case4104: Print("Incompatible file access mode.");return(1);
case4105: Print("No order has been selected.");return(1);
case4106: Print("Unknown character.");return(1);
case4107: Print("Incorrect price parameter for the trading function.");return(1);
case4108: Print("Invalid ticket number.");return(1);
case4109: Print("Trading is not permitted. You must enable the option Allow Expert Advisor to trade in the expert properties.");return(1);
case4110: Print("Long positions are not allowed. It is necessary to check the properties of the expert.");return(1);
case4111: Print("Short positions are not allowed. It is necessary to check the properties of the expert.");return(1);
case4200: Print("The object already exists.");return(1);
case4201: Print("An unknown property of the object was requested.");return(1);
case4202: Print("The object does not exist.");return(1);
case4203: Print("Unknown object type.");return(1);
case4204: Print("No object name.");return(1);
case4205: Print("Error coordinates of the object.");return(1);
case4206: Print("The specified subwindow was not found.");return(1);
case4207: Print("An error occurred while working with the object.");return(1);
return(0);
}
return(0);
}
//+---------------------------------------------------------------
Nessun errore.
E perché dovrebbero essercene. Solo se il deposito non permette di aprire con un lotto minimo.
Non mi interessa se ha cento anni. Come ci si può lamentare di descrivere solo il codice di errore?
La funzione non dovrebbe solo essere in grado di descrivere il codice di errore (non dovete fare assolutamente nulla - basta copiarlo dalla guida), ma dovrebbe emettere il codice per il gestore. Avete o 0 o 1 codice ovunque.
Perché il tipo di funzione è int invece di bool?
E non hai un supervisore. Ma la vostra elaborazione significa che se una funzione emette il codice 1 a qualsiasi risposta del server, voi eseguite semplicemente return. Da dove e verso dove - nessuno lo sa.
Allora dov'è l'elaborazione? return non è l'elaborazione, è la fuga dal problema di dover gestire il codice di errore restituito dal server.
E perché dovrebbero essercene. Dovete aprire con un lotto minimo se il vostro deposito non lo permette.
Anch'io ho lottato con questo.
finché non ho impostato il lotto minimo a 0,1
Non riuscivo a capire perché non potevo fare trading perché il MarketInfo() del validatore non rispondeva 0,1 come minimo, rispondeva 0 (zero) o 0,01, non lo ricordo ;)
Artem, stiamo parlando di cose completamente diverse. Il codice è trasparente. Dimmi, dove può esserci un errore? Mostrami il luogo esatto e la situazione in cui avverrà.
Vedo solo una situazione,se il deposito non permette di aprire con lotto minimo . Ma questa è la colpa del tester, perché impostare condizioni che non permettono di aprire un affare con il lotto minimo.
Non ci sono parametri esterni in questo semplice codice, come si spera tutti abbiano notato. Apre stupidamente un trade con il lotto minimo offerto dall'ambiente informativo.
Andrey Kaunov: Questo codice rudimentale non ha alcun parametro, come si spera tutti abbiano notato. Apre stupidamente un trade con il lotto minimo offerto dall'ambiente informativo.
Consenti l'uso dei cookie per accedere al sito MQL5.com.
Abilita le impostazioni necessarie nel browser, altrimenti non sarà possibile accedere.
Hai effettuato l'accesso. L'autenticazione a due fattori è stata disattivata. Configurala di nuovo e scansiona un nuovo codice QR, oppure continua con l'autenticazione a due fattori disattivata.
Corretto il codice ed eseguito nel tester
Nessun errore.
E perché dovrebbero essercene. Solo se il deposito non permette di aprire con un lotto minimo.
10 anni con questo
Non posso lamentarmi.
Non mi interessa se ha cento anni. Come ci si può lamentare di descrivere solo il codice di errore?
La funzione non dovrebbe solo essere in grado di descrivere il codice di errore (non dovete fare assolutamente nulla - basta copiarlo dalla guida), ma dovrebbe emettere il codice per il gestore. Avete o 0 o 1 codice ovunque.
Perché il tipo di funzione è int invece di bool?
E non hai un supervisore. Ma la vostra elaborazione significa che se una funzione emette il codice 1 a qualsiasi risposta del server, voi eseguite semplicemente return. Da dove e verso dove - nessuno lo sa.
Allora dov'è l'elaborazione? return non è l'elaborazione, è la fuga dal problema di dover gestire il codice di errore restituito dal server.
Corretto il codice ed eseguito nel tester
Nessun errore.
E perché dovrebbero essercene. Se il deposito non vi permette di aprire con un lotto minimo.
In questa situazione, visualizzate un messaggio nel diario e continuate a lavorare con l'Expert Advisor.
Corretto il codice ed eseguito nel tester
Nessun errore.
E perché dovrebbero essercene. Dovete aprire con un lotto minimo se il vostro deposito non lo permette.
Anch'io ho lottato con questo.
finché non ho impostato il lotto minimo a 0,1
Non riuscivo a capire perché non potevo fare trading perché il MarketInfo() del validatore non rispondeva 0,1 come minimo, rispondeva 0 (zero) o 0,01, non lo ricordo ;)
Artem, stiamo parlando di cose completamente diverse. Il codice è trasparente. Dimmi, dove può esserci un errore? Mostrami il luogo esatto e la situazione in cui avverrà.
Vedo solo una situazione,se il deposito non permette di aprire con lotto minimo . Ma questa è la colpa del tester, perché impostare condizioni che non permettono di aprire un affare con il lotto minimo.
Lo fa sempre e solo su NZDUSD?
Questo codice rudimentale non ha alcun parametro, come si spera tutti abbiano notato. Apre stupidamente un trade con il lotto minimo offerto dall'ambiente informativo.
E se hanno un minlot di 0,1?
Personalmente ne sono sicuro.
;)
a proposito, sicuro che non c'è mai un biglietto #0 ? :-)
E se hanno un minlot di 0,1?
Personalmente, ne sono sicuro.
;)
Ho indovinato Renat, 0,2))) Ecco un test in cui non ho ancora verificato la possibilità di aprire con un lotto minimo
Tutto descritto nei post precedenti.
a proposito, sicuro che non c'è mai un biglietto #0 ? :-)
Non sono più sicuro di niente ))))
Ho indovinato, Renat, 0,2))) Ecco un test, dove non ho ancora verificato la possibilità di aprire con un lotto minimo
Tutto descritto nei post precedenti.
questo è tutto
tosto per min lot se tester e iniziare il trading a margine, naturalmente tenendo conto del costo dello spread
tipo: se margine libero*0,9 > lotto*margine, allora trade