Error number 6 - page 6

 
Not bad, but essentially the same :)<br / translate="no"> What is SetTrace?


Oopsie :) I'm going to do a commercial now, pay attention - http://forexsystems.ru/phpBB/viewtopic.php?t=694&start=45
 
хэндлов не хватает.


Can I change the number of handles in system settings (W'XP) and how?
 
Another question to the developers.

What's the right way to do it:

1.
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); } }



2.

for(int nCnt = OrdersTotal() - 1; nCnt >= 0; 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); } }



3. indifferent.
4. We should set return and process the next order in the next tick
5. It should be done somehow else.

Let me explain. Assume that we have two open orders and they both need to be closed. The loop

for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++)



It will close the zero order, after which the first order will become zero. Then it will try to close the first order, and there will be an error. Right?

I do not think that all errors of the EA discussed in this thread are related to this issue, e.g., common error has nothing to do with it. But if I'm right, maybe it explains a) order locked and such like it and b) the fact that we need several EAs for errors to appear.



 
хэндлов не хватает.


Можно ли изменить число хэндлов в системных установках (W'XP) и как?

If a program lacks handles, it is written with errors. Otherwise, there are enough handles to go around.
 
Of course, the second option is correct, but instead of return you should put Sleep() for 30 seconds and that's it.
 
I should add that by substituting
for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++)
by
for(int nCnt = OrdersTotal() - 1; nCnt >= 0; nCnt--)
I went from error 139 to 138 and 4109
(requote, Not initialized string in array)
The last one has no comments at all...
 
Of course, the second variant is correct, but instead of return you should put Sleep() for 30 seconds and that's it.


At 10 Expert Advisors in a minute interval, 30 seconds for each... Wrong, it is impossible to live that way.
 
Do you think that's it? I had 12 windows, each with a different currency and a different Expert Advisor. I prohibited (Allow live trading) trading in 11 of them. All my errors are still coming from them. One more bug.
 
Конечно, второй вариант правилен, только вместо return надо ставить Sleep() секунд на 30 и усе.


With 10 experts on a one-minute interval, 30 seconds for each... Wrong, this is no way to live.



This is the way to live, and what you are doing is a test of the strength of the iron.
 
A new version of EA for testing. What has changed:
1. Cycles fixed.
2. Magik number is privatized to bar start time. This gives, if I am not mistaken, a delay in opening. That is, EA with mn 7 will open 7 seconds after the start of the bar. It will avoid server overloading, computer CPU and conflict with 2.5 second maximum, if it's still there somewhere...

But alas, errors remain.

The rules are the same - open several windows, on any timeframe (minutes, for example) and wait.

double dStopLoss;
int nHoursToHold;

datetime timePrev = 0;

int nSlip = 5;

double dLotSize = 0.1;

int nMagic = 0;

//////////////////
int init ()
{
	timePrev = 0;

	dStopLoss = 110 * Point;
	nHoursToHold = 1;
	
	if(Symbol() == "EURUSD")
		nMagic = 1;
	else if(Symbol() == "EURJPY")
		nMagic = 2;
	else if(Symbol() == "USDCHF")
		nMagic = 3;
	else if(Symbol() == "GBPUSD")
		nMagic = 4;
	else if(Symbol() == "GBPJPY")
		nMagic = 5;
	else if(Symbol() == "GBPCHF")
		nMagic = 6;
	else if(Symbol() == "USDJPY")
		nMagic = 7;
	else if(Symbol() == "AUDUSD")
		nMagic = 8;
	else if(Symbol() == "EURGBP")
		nMagic = 9;
	else if(Symbol() == "USDCAD")
		nMagic = 10;
	else if(Symbol() == "EURCHF")
		nMagic = 11;
	else if(Symbol() == "EURAUD")
		nMagic = 12;
		
	timePrev += nMagic;	// Open nMagic seconds after the new bar

	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] + nMagic) 
		bIsBarEnd = true;
	timePrev = Time[0] + nMagic;
	
	if(!bIsBarEnd)
		return(0);

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

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

	for(int nCnt = OrdersTotal() - 1; nCnt >= 0; 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, "Friday", nMagic, 0, OrangeRed);

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

	dLotSize = GetLotSize();

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

	if(nResult == -1)
	{
		int nError = GetLastError();
		Alert(Symbol() + ", " + nError);
	}
}
// ------

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

// ------

int GetSignal()
{
	int nSignal;
	if(MathMod(Hour(), 2) == 0)
		nSignal = OP_BUY;
	else
		nSignal = OP_SELL;
		
	return(nSignal);
}

// ------