第6号错误 - 页 2

 
<br / translate="no">图表的数量是有限制的--99。因此,专家的数量也是有限制的。


嗯,没有。不是我的情况。首先,我有不到99个专家顾问。第二,我不打算长时间工作--在一小时内重新启动和警戒。

那么,你能看一下专家吗?
 
而紧随其后的是。另一位专家。它是什么样的指标,并不重要。重要的是,我发现它在同一货币中开了两笔交易。专家顾问的逻辑不允许这样做。从逻辑上讲(如果你看图表),之前的交易应该已经关闭。而事实并非如此。日志中没有任何内容。同样的症状?

我上面给出的专家顾问是一个更好的想法。在代码方面,那里的一切都更简单。而且没有任何指标。

夸克。

// MT4 tested
#include "mylib.mq4"

extern double dBuyLevel;
extern double dSellLevel;
extern double dStopLoss;
extern double dTrailingStop;
extern double dTakeProfit;

extern int nNocInterval;
extern double dNocRange;
extern int nNocMa;

// ------

datetime timePrev = 0;

int nSlip = 5;
double dTp = 0;

double dProfit = 0;
double dInitAmount = 1000;
double dLotSize = 0.1;

int nNumOfExperts = 5;
int nMagic = 0;
bool bReportDone = false;

bool bUseMm = false;

//////////////////
int init ()
{
	if(Symbol() == "EURUSD" && Period() == 60)
	{
		if(!IsTesting())					
		{							// (0.21,0.94,240,40,0.02,3,240), (0.19,0.82,200,30,0.025,5,200)
			dBuyLevel = 0.19;		// (0.21,0.83,160,27,0.026,4,260), (), ()
			dSellLevel = 0.82;
									
			dStopLoss = 230 * Point;		
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;
			
			nNocInterval = 28;
			dNocRange = 0.024;
			nNocMa = 6;
			
			// Max: 0.19,0.82,230,230,0,28,0.024,6; dd: 653, balance: 6900
		}
		else
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = /*dTrailingStop * Point;*/dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 10;
	}
	else if(Symbol() == "EURJPY" && Period() == 60)
	{
		if(!IsTesting())					
		{							// (0.17,0.96,120,40,0.01,13)
			dBuyLevel = 0.17;		// balance: 3650, dd: 539
			dSellLevel = 0.96;
											
			dStopLoss = 120 * Point;		
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;
			
			nNocInterval = 40;
			dNocRange = 0.01;
			nNocMa = 13;
		}
		else
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 11;
	}
	else if(Symbol() == "USDCHF" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.19,0.82,200,35,0.01,5)
			dBuyLevel = 0.05;				// balance: 6200, dd: 763
			dSellLevel = 0.92;	
											// (0.05,092,250,30,0.025,3)
			dStopLoss = 250 * Point;		// balance: 3600, dd: 500
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				// (0.07,0.92, 250,40,0.025,9)
											// balance: 3500, dd: 362
			nNocInterval = 30;
			dNocRange = 0.025;				
			nNocMa = 3;						
		}
		else
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 12;
	}
	else if(Symbol() == "GBPUSD" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.21,0.84,250,30,0.01,11)	// BUY ONLY: retest!!!
			dBuyLevel = 0.15;				// balance: 6588, dd: 1169
			dSellLevel = 0.84;	
											// (0.15,0.86,250,20,0.025,9)	// BUY ONLY: retest!!!
			dStopLoss = 200 * Point;		// balance: 3337, dd: 552
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				// (0.15,0.84,200,20,0.025,7)	// buy and sell
											// balance: 4171, dd: 850
			nNocInterval = 20;
			dNocRange = 0.025;				// (0.15,0.88,200,20,0.025,9)	// buy only? retest
			nNocMa = 9;						// balance: 2895, dd: 424
		}
		else
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 13;
	}
	else if(Symbol() == "GBPCHF" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.11,0.86,280,20,0.025,7)
			dBuyLevel = 0.11;				// balance: 5564, dd: 777
			dSellLevel = 0.86;	
											// (0.15,0.84,280,25,0.025,11)
			dStopLoss = 280 * Point;		// balance: 4275, dd: 685
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				// (0.11,0.86,280,25,0.025,9)
											// balance: 4159, dd: 456
			nNocInterval = 25;
			dNocRange = 0.025;				
			nNocMa = 9;						
		}
		else 
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 14;
	}
	else if(Symbol() == "USDJPY" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.07,0.82,280,25,0.025,3)
			dBuyLevel = 0.07;				// balance: 3764, dd: 527
			dSellLevel = 0.82;	
											// (0.07,0.8,160,30,0.025,3)
			dStopLoss = 280 * Point;		// balance: 3297, dd: 491
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				// (0.09, 0.94,280,15,0.025,3)
											// balance: 2703, dd: 541
			nNocInterval = 25;
			dNocRange = 0.025;				
			nNocMa = 3;						
		}
		else 
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 15;
	}
	else if(Symbol() == "AUDUSD" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.14,0.9,280,40,0.015,11)
			dBuyLevel = 0.14;				// balance: 3834, dd: 468
			dSellLevel = 0.9;	
											// (0.13,0.92,240,35,0.01,13)
			dStopLoss = 280 * Point;		// balance: 3463, dd: 303
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				
											
			nNocInterval = 40;
			dNocRange = 0.015;				
			nNocMa = 11;						
		}
		else 
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 16;
	}
	else if(Symbol() == "EURGBP" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.09,0.84,200,35,0.01,3)
			dBuyLevel = 0.21;				// balance: 2517, dd: 486
			dSellLevel = 0.82;	
											// (0.21,0.82,280,40,0.015,3)
			dStopLoss = 280 * Point;		// balance: 2726, dd: 324
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				// (0.21,0.84,160,15,0.01,3)
											// balance: 2255, dd: 314
			nNocInterval = 40;
			dNocRange = 0.015;				
			nNocMa = 3;						
		}
		else 
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 17;
	}
	else if(Symbol() == "USDCAD" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.05,0.88,280,25,0.015,7)
			dBuyLevel = 0.07;				// balance: 3536, dd: 235
			dSellLevel = 0.86;	
											// (0.07,0.86,280,15,0.015,3)
			dStopLoss = 280 * Point;		// balance: 3414, dd: 380
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				
											
			nNocInterval = 15;
			dNocRange = 0.015;				
			nNocMa = 3;						
		}
		else 
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 18;
	}
	else if(Symbol() == "EURCHF" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.17,0.84,280,15,0.01,5)
			dBuyLevel = 0.17;				// balance: 1471, dd: 221
			dSellLevel = 0.84;	
											// (0.17,0.88,200,15,0.01,5)
			dStopLoss = 200 * Point;		// balance: 1433, dd: 135
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				
											
			nNocInterval = 15;
			dNocRange = 0.01;				
			nNocMa = 5;						
		}
		else 
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 19;
	}
	else if(Symbol() == "EURAUD" && Period() == 60)
	{
		if(!IsTesting())					
		{									// (0.05,0.8,240,30,0.025,9)
			dBuyLevel = 0.05;				// balance: , dd: 
			dSellLevel = 0.8;	
											// ()
			dStopLoss = 240 * Point;		// balance: , dd: 
			dTrailingStop = dStopLoss;
			dTakeProfit = 0;				
											
			nNocInterval = 30;
			dNocRange = 0.025;				
			nNocMa = 9;						
		}
		else 
		{
			dStopLoss = dStopLoss * Point;

			if(dTakeProfit == 700)
				dTakeProfit = 0;			
			dTakeProfit = dTakeProfit * Point;

			dTrailingStop = dStopLoss;
		}

//		bBuy = false;
//		bSell = false;

		nMagic = 20;
	}

	return(0);
}
// ------
int deinit()
{
	return(0);
}

// ------

int start()
{
	if(Bars < nNocInterval + nNocMa)
		return(0);
	
	Report("Noc_1", nMagic, bReportDone);

	// The previous bar just closed
	bool bIsBarEnd = false;
	if(timePrev != Time[0]) 
		bIsBarEnd = true;
	timePrev = Time[0];
	
	if(!bIsBarEnd)
		return(0);
	
	// ------
	
	double dNoc = iCustom(NULL, 0, "_Noc_Ind", nNocInterval, dNocRange, nNocMa, 0, 1);
	double dNocPrev = iCustom(NULL, 0, "_Noc_Ind", nNocInterval, dNocRange, nNocMa, 0, 2);
		
	int nNumOfOpenedOrders = 0;
	for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++)
	{
		OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
		if(OrderMagicNumber() == nMagic)
		{
			if(OrderType() <= OP_SELL)
				nNumOfOpenedOrders++;
		}
	}

	if(bUseMm == true)
	{
		dProfit = 0;
		
		for(nCnt = 0; nCnt < HistoryTotal(); nCnt++)
		{
			OrderSelect(nCnt, SELECT_BY_POS, MODE_HISTORY);
			if(OrderMagicNumber() == nMagic && OrderType() <= OP_SELL)
			{
				dProfit += OrderProfit();
			}
		}   
 	}
 	
	if(nNumOfOpenedOrders == 0)
	{
		if(dNocPrev <= dBuyLevel && dNoc >= dBuyLevel) 
			Buy();
		else if(dNocPrev >= dSellLevel && dNoc <= dSellLevel) 
			Sell();
		
		return(0);
	}
	else
	{
		for(nCnt = 0; nCnt < OrdersTotal(); nCnt++)
		{
			OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
			if(OrderMagicNumber() == nMagic)
			{
				if(OrderType() == OP_BUY)
				{         
					if(dNocPrev >= dSellLevel && dNoc <= dSellLevel)
					{
						OrderClose(OrderTicket(), OrderLots(), Bid, nSlip, Aqua);

						Sell();

						return(0);
					}
				}
				else if(OrderType() == OP_SELL)
				{
        			if(dNocPrev <= dBuyLevel && dNoc >= dBuyLevel)
					{
						OrderClose(OrderTicket(), OrderLots(), Ask, nSlip, OrangeRed);

						Buy();

						return(0);
					}
				}
			}
		}
	}
	
	// ------
	
	for(nCnt = 0; nCnt < OrdersTotal(); nCnt++)
	{
		OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
		if(OrderMagicNumber() == nMagic && OrderSymbol() == Symbol())
		{
			if(OrderType() == OP_BUY)// && Bid - OrderOpenPrice() > dStopLoss) 
			{
				if(OrderStopLoss() < Bid - dTrailingStop - 5 * Point)
				{
					OrderModify(OrderTicket(), OrderOpenPrice(), 
						Bid - dTrailingStop, OrderTakeProfit(), 0, Aqua);

					return(0);
				}
			}
			
			if(OrderType() == OP_SELL)// && OrderOpenPrice() - Ask > dStopLoss)
			{
				if(OrderStopLoss() > Ask + dTrailingStop + 5 * Point)// || OrderStopLoss() == 0)
				{
					OrderModify(OrderTicket(), OrderOpenPrice(), 
						Ask + dTrailingStop, OrderTakeProfit(), 0, OrangeRed);

					return(0);
				}
			}
		}
	}
	
	return(0);
}

// ------

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

	dLotSize = GetLotSize();

	if(dTakeProfit == 0)
		dTp = 0;
	else
		dTp = Bid - dTakeProfit;

	OrderSend(Symbol(), OP_SELL, dLotSize, Bid, nSlip, Bid + dStopLoss, 
		dTp, "Noc_1", nMagic, 0, OrangeRed);

}

// ------

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

	dLotSize = GetLotSize();

	if(dTakeProfit == 0)
		dTp = 0;
	else
		dTp = Ask + dTakeProfit;

	OrderSend(Symbol(), OP_BUY, dLotSize, Ask, nSlip, Ask - dStopLoss, 
		dTp, "Noc_1", nMagic, 0, Aqua);
}
// ------
double GetLotSize()
{
	double dLot = 0.1;
	
	if(bUseMm)
	{
		dLot  = (0.1 * dInitAmount + 0.2 * dProfit) / 1000;

		if(dLot * 2 * dInitAmount > AccountFreeMargin() / nNumOfExperts)
			dLot = AccountFreeMargin() / (2 * dInitAmount * nNumOfExperts);

		dLot = MathFloor(dLot * 10) / 10;
	
		if(dLot < 0.1)
			dLot = 0.1;
	}
	
	return(dLot);
}

// ------


 
我在一个账户里有9个EA,现在已经2个月了。我已经在所有这些人中实施了这样的建设。
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point, "sell",ExpertMagicNumber,0,Red); if(ticket<0) { Print("OrderSend failed with error #," GetLastError()); return(0); }



日志干净了,订单也下了。

 
我在一个账户上有9个EA,现在已经2个月了。所有这些都有相同的结构:<br/ translate="no">
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point, "sell",ExpertMagicNumber,0,Red); if(ticket<0) { Print("OrderSend failed with error #," GetLastError(); return(0); }



日志干净了,订单也下了。



我还能说什么呢?试试我的专家顾问,也就是我首先引用的那个。它每小时给出一个交易。通常,第二次交易会导致错误信息。如果24小时内没有错误,我甚至不知道...
 
挂了电话,显然应该在10分钟内做一些事情。我希望他不要破坏我的其他EA。Yo000,他已经开了一个订单,你答应每小时一次,但还没到一分钟。
 
挂了电话,显然应该在10分钟内做一些事情。我希望他不要破坏我的其他EA。Yo000,他已经开了一个订单,你答应每小时一次,但还没到一分钟。


第一次是一次性开单(见条形图开始时的条件检查)。然后,如果你不碰它,在下一个小时的开始。
 
好吧,马戏团继续。在第二位专家那里挂断了Alert的电话。在一开始的时候,预计有两条曲线会交叉,他诚实地试图开出一个订单。相反,它得到了6号错误。先生们 开发者?
 
Rosh,听着,当然要感谢你的帮助。但我想知道,我的EA通过神奇的数字跟踪 "它 "的交易。如果你的方法是一样的(每个EA都有自己的观点),那么我想确保它不会关闭其他人的订单。如果你的方法是一样的(每个EA都有自己的mn),那么你必须确保这个EA的mn不与你的重合。
 
我之所以写洪水,是因为阅读这类帖子让我非常难过,需要说些什么,尤其是我已经喝了几杯......

我非常希望夸克在他的专家中搞砸了。我自己还不能检查,因为我是用远离电脑的PDA写的。但是,如果是MT,那么F......,然而,轻骑兵沉默了!
 
真正的无声胜有声 :)