//+------------------------------------------------------------------+//| cci on ma.mq4 |//| Copyright 2014, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"2005-2014, MetaQuotes Software Corp."#property link"https://www.mql4.com"#property strictinputdouble Lots =0.1;
inputint Expiration =5; //laikas minutemis//---- input parametersinputint cci_p = 89;
inputint ma = 13;
inputint NumberOfBarsToCalculate = 100;
inputstring comment=".csv or .txt";//коментарийinputstring FileType="csv";//тип файла datetime op_time=0,cl_time=0;
double op_price=0,cl_price=0;
int op_type=0;
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnTick(void)
{
int cnt,ticket,total;
//---if(Bars<cci_p+1)
{
Print("bars less than ",cci_p);
return;
}
//--- to simplify the coding and speed up access data are put into internal variablesdouble cci_dn=iCustom(NULL,0,"cci_ma",cci_p,ma,NumberOfBarsToCalculate,2,0);
double cci_up=iCustom(NULL,0,"cci_ma",cci_p,ma,NumberOfBarsToCalculate,3,0);
total=OrdersTotal();
if(total<1)
{
//--- check for long position (BUY) possibilityif(cci_up>0 && cci_up!=EMPTY_VALUE)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"cci sample",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
op_time=TimeLocal();
op_price=Close[0];
op_type=1;
Print("BUY order opened : ",OrderOpenPrice());
Print("op_price : ",op_price, "op_time : ",op_time);
}
elsePrint("Error opening BUY order : ",GetLastError());
return;
}
//--- check for short position (SELL) possibilityif(cci_dn<0 && cci_dn!=EMPTY_VALUE)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"cci sample",16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
op_time=TimeLocal();
op_price=Close[0];
op_type=-1;
Print("BUY order opened : ",OrderOpenPrice());
Print("op_price : ",op_price, "op_time : ",op_time);
}
elsePrint("Error opening SELL order : ",GetLastError());
}
//--- exit from the "no opened orders" blockreturn;
}
//--- it is important to enter the market correctly, but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++)
{
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
//--- long position is openedif(OrderType()==OP_BUY)
{
//--- should it be closed?if(TimeCurrent()>=op_time+Expiration*60)
{
//--- close order and exitif(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet))
cl_time=TimeCurrent();//op_time+Expiration*60;
cl_price=Close[0];
Print("OrderClose error ",GetLastError());
PrintToFile(op_price, cl_price, op_type, op_time, cl_time);
return;
}
}
else// go to short position
{
//--- should it be closed?if(TimeCurrent()>=op_time+Expiration*60)
{
//--- close order and exitif(!OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet))
cl_time=TimeCurrent();//op_time+Expiration*60;
cl_price=Close[0];
Print("OrderClose error ",GetLastError());
PrintToFile(op_price, cl_price, op_type, op_time, cl_time);
return;
}
}
}
}
//---
}
//+------------------------------------------------------------------+void PrintToFile(double opPrice=0,double clPrice=0,int opType=0, datetime opTime=0, datetime clTime=0)
{
string fileName=StringConcatenate(Symbol()," ",Period()," ","gi_EA_cci");
int handle;
handle=FileOpen(fileName+FileType, FILE_WRITE|FILE_READ,";");
if(handle!=INVALID_HANDLE)
{
PrintFormat("Файл %s открыт для записи",fileName);
PrintFormat("Путь к файлу: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));
//--- сначала запишем количество сигналовFileSeek(handle, 0, SEEK_END);
FileWrite(handle,
opPrice,
clPrice,
opType,
TimeToString(opTime,TIME_MINUTES|TIME_SECONDS),
TimeToString(clTime,TIME_MINUTES|TIME_SECONDS));
//--- закрываем файлFileClose(handle);
PrintFormat("Данные записаны, файл %s закрыт",fileName);
}
elsePrintFormat("Не удалось открыть файл %s, Код ошибки = %d",fileName,GetLastError());
}
大家好!
请告知在EA中 iCustom 价值转移的问题是什么。
2014.10.12 10:23:06.656 TestGenerator: unmatched data error (volume limit 470 at 2014.03.14 21:45 exceeded)
2014.10.12 10:23:53.468 2014.03.06 18:15 ClusterExp2 GBPUSD,M15: 2147483647 2147483647
回形针上的Correl8指标。
提前感谢您!
上传被测试角色的历史记录。错误是在历史数据中,而不是在iCustom()中。
早上好,阿尔乔姆!是的,关于魔术师的事情很清楚!我想说的是,我们应该把我们的工作做好。但当某些东西不是在一个循环中,而是在if-else类型的条件中时,只要把第一个条件if(Symbol()==mySymbol)(当然没有else),之前呈现mySymbol=Symbol() 就够了!这样,所有EA的所有变量都是一样的,但每个人都在自己的图形上!我还不能检查,我还在写,"做出来"!:)
如果字符串mySymbol=Symbol();,那么这个变量将持有当前符号的值。因此,对于每个在自己的图表上进行交易的EA,这个变量的值将等于该EA启动的符号的值。
打印到一个文件。我正在学习在这个文件上打印。
为什么在cl_time中打印零?
你能告诉我如何在董事会上定义提款吗?
对于一些 "订单",OrderType()产生一个数值等于6的值。这些是提款和存款。
在成功调用OrderSelect() 后(返回true),你可以通过OrderProfit()返回的值来确定提款/充值的大小,并通过这个值的符号--是提款还是存款...
另外,有些经纪商收取佣金,按佣金的数额模仿提款。你可以尝试通过使用OrderComment()获得的注释来区分收取佣金和从账户中提款。
然而,要小心:这都是没有记录的,可能随时停止工作。
亲爱的程序员!在优化专家顾问时,我个人认为,与其他许多参与者一样,试图找到利润与最大缩水的最大比率(比率:利润/损失),我认为这是最重要的指标。我在完成测试器的运行后手动进行这一程序。是否有可能使这一过程自动化?或者说,你们每个人是如何确定这个参数的?预先感谢你。
我是这样做的