Error number 6

 
"No connection with trade server". It would be fine, but it pops up every once in a while when trying to open an order. When I restart MT, the order opens immediately. Does anybody know what is the matter?
 
Also, a question for the developers. If I'm trading at the beginning of the bar, and 1000 other people too, isn't that the reason why the server is unavailable at the beginning of the bar?

Answer, please. If it is, I'll just provide a delay, but I'd like to know the reason first.
 
Dear developers!
I am repeating my question with a slightly different wording: Error number six (quotes are available, but the trade server is not) - is it because at the beginning of the hour bar the server is overloaded? Should I search the problem in an Expert Advisor or just open deals, say, 3 minutes after the beginning of a bar, when the load on the server is less?

The second question of the same series: if I have a lot of Expert Advisors at one time and all of them do something at the beginning of a bar, will there be problems? Or calculations just line up? For example, what will happen if EA has not had time to complete the calculation, and a new tick has arrived - will it finish the calculation at the old price? And if there is a new tick, will you guarantee that the calculation (I check the beginning of the bar with the code you have recommended in your tutorial) will still show the beginning of the bar?

These are important questions, I would like more details.

Regards,
Quark
 
1. what is your operating system?
2. experts work in parallel, each in its own thread. if a new tick comes and the expert is still working, the tick will be ignored. all price data with which the expert works remain original (the expert actually works with a copy of the data). in order to take the most recent, changed, data, there is a function RefreshRates
 
Windows 2000

Actually, I asked the question because I got error 6 twice when trying to open a position at the beginning of a bar:

bool bIsBarEnd = false; if(timePrev != Time[0]) bIsBarEnd = true; timePrev = Time[0]; if(!bIsBarEnd) return(0); ....



The question remains - is it because of server overload, as ALL is more active at the beginning of the bar? Or is it due to something else?

 
I don't think it's from the server. we're currently dealing with this error on win98. but it's clear what's causing it there - the handles are missing.
 
Now, at 13:00 Moscow time, the same Expert Advisor has got error number 2 - common error.
If anyone from Alpari is reading this post - account 116122.

This is the only one of my Expert Advisors that gives an alert for errors of this nature. I suggest those who have demo EAs to put alerts if OrderSend returns -1 (in case this situation happens quite often). Here is the code for buying, the principle is the same for selling:

int nResult = OrderSend(Symbol(), OP_BUY, dLotSize, Ask, nSlip, Ask - dStopLoss, 0, "Comment", nMagic, 0, Aqua); if(nResult == -1) { int nError = GetLastError(); Alert(nError); }



Also, just in case, I am quoting the whole expert, except for the part where logic is involved (it certainly has nothing to do with it). Have a look, please. Still, it seems to me that it is about MT. The Expert Advisor just hangs on the hour chart of EURUSD and periodically generates errors instead of trades.

I want to note that the first run (when EA is attached to a chart or when its code is recompiled) does not show errors and runs normally. That is, you get an error, press F5 in the editor after 5 seconds, the Expert Advisor has started and a trade has opened.

Help in general, please!

double dStopLoss;
int nHoursToHold;

datetime timePrev = 0;
bool bIsFirst = true;

int nSlip = 5;

double dTp = 0;

double dLotSize = 0.1;

int nNumOfExperts = 5;
int nMagic = 0;

//////////////////
int init ()
{
	timePrev = 0;
	
	if(Symbol() == "EURUSD" && Period() == 60)
	{
		dStopLoss = 110 * Point;
		nHoursToHold = 1;
		
		nMagic = 23;
	}

	return(0);	
}

// ------

int deinit()
{
	return(0);
}
// ------
int start()
{
	if(Bars < 5)
		return(0);
	
	// The previous bar just closed
	bool bIsBarEnd = false;
	if(timePrev != Time[0]) 
		bIsBarEnd = true;
	timePrev = Time[0];
	
	if(!bIsBarEnd)
		return(0);

	// ------
	
	int nSignal = GetSignal();

	if(nSignal == OP_BUY) 
		Buy();
	else if(nSignal == OP_SELL) 
		Sell();

	for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++)
	{
		OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);

		if(OrderMagicNumber() == nMagic)
		{
			if(CurTime() - OrderOpenTime() > (nHoursToHold - 1) * 60 * 60)
			{
				if(OrderType() == OP_BUY)
					OrderClose(OrderTicket(), OrderLots(), Bid, nSlip, Aqua);
				else if(OrderType() == OP_SELL)
					OrderClose(OrderTicket(), OrderLots(), Ask, nSlip, OrangeRed);
			}
		}
	}

	return(0);
}
// ------

void Sell()
{
	if(AccountFreeMargin() < 500)
		return;

	dLotSize = GetLotSize();

	int nResult = OrderSend(Symbol(), OP_SELL, dLotSize, Bid, nSlip, Bid + dStopLoss, 
		0, "Comment", nMagic, 0, OrangeRed);

	if(nResult == -1)
	{
		int nError = GetLastError();
		Alert(nError);
	}
}
// ------
void Buy()
{
	if(AccountFreeMargin() < 500)
		return;

	dLotSize = GetLotSize();

	int nResult = OrderSend(Symbol(), OP_BUY, dLotSize, Ask, nSlip, Ask - dStopLoss, 
		0, "Comment", nMagic, 0, Aqua);

	if(nResult == -1)
	{
		int nError = GetLastError();
		Alert(nError);
	}
}
// ------

double GetLotSize()
{
	double dLot = 0.1;
	
	return(dLot);
}

// ------

int GetSignal()
{
	int nSignal = OP_BUY;
	return(nSignal);
}

// ------




 
I don't think it's from the server. we're currently dealing with this error on win98. but it's clear what's causing it there - there are not enough handles.


Handles of what? How many handles do you have? Is there a limit to the number of EAs, graphs, etc.?

P.S. This question does not invalidate my previous post :)
 
Expert Advisor has given out error number 2 - common error.
Rare enough error =)
I've had Expert Advisors give this error only 5 times in half a year
About alerts - inconvenient. I have a sending to email + writing to file. Soon I'll finish libraries with appropriate functions - I'll post them
 
эксперт выдал ошибку номер 2 - common error.
quite a rare error =)
I have only had this error 5 times in half a year
About the alerts - inconvenient. I have a sending to email + writing to file. I'll soon finalize the library with appropriate functions - I'll post it.


On the contrary, it's convenient. Alert doesn't interfere with anything, MT keeps working, but you can see it right away... um... if you're sitting at your computer... Yeah, I get it :)

"My" expert gives this error 70% of the time. I mean, not this one, but 2, 6, 14... in short, no systematically. Checked the prices, seems to be correct... Since the MT sources are with the developers and the servers are with Alpari, it's basically up to them. Although it would be great if someone else ran the thing, and confirmed that the problem is reproduced on their computer.
 
вряд ли это от сервера. сейчас мы разбираем такую ошибку на вин98. но там понятно отчего происходит - хэндлов не хватает.


Handles of what? How many of these handles do you have? Is there a limit to the number of experts, graphs, etc.?

on 98, where the number of handles per process is an order of magnitude smaller than in 2000, the error of resource shortage appeared very quickly, including the inability to open a socket for trade. during long work this error appeared in 2000 as well. why this bug appeared only in recent builds is a natural mystery.
there is a limit on the number of charts - 99. so there is also a limit on the number of EAs
Reason: