FileWrite(handle,"Winning Long OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",borderOpen);
FileClose(handle);
Print(" Winning Long ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
FileWrite(handle,"Losing Long OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",buyorderOpen);
FileClose(handle);
Print(" Losing Long ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
FileWrite(handle,"Winning Short OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",borderOpen);
FileClose(handle);
Print(" Winning Short ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
FileWrite(handle,"Losing Short OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",sellorderOpen);
FileClose(handle);
Print(" Losing Short ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
FileWrite(handle, "BuyPossibilityMid:", BuyPossibilityMid); FileWrite(handle, "Winning Short OrderTicket:",OrderTicket()," Opened @:",OrderOpenPrice()," Closed @:",OrderClosePrice()," Order Open Time: ",borderOpen)。
这里还有一个写文件的样本,就在MT编辑器里......
这将允许你记录到一个csv文件,修改你的输出,你想。
int handle;
datetime orderOpen=OrderOpenTime();
handle=FileOpen("c:\cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
if(handle>0)
{
FileWrite(handle, Close[0], Open[0], High[0], Low[0], TimeToStr(orderOpen));
FileClose(handle);
}
我是在IBFX的现场,我可以为你转发测试微型手的现场。但是我的账户上还有其他的实盘交易,所以我必须把CT的结果单独拿出来。
请给我发电子邮件地址我必须把所有这些打印到文件中,以及我评估的任何指标....,目前它只是把这些打印到日志中。
if(ticket > 0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
{
int handle;
datetime orderOpen=OrderOpenTime();
handle=FileOpen("C:\cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
if(handle>0)
{
FileWrite(handle,"Hour: ",TimeHour(CurTime())," Minute: ",TimeMinute(CurTime()));
FileWrite(handle,"SellPossibilityMid*SellPossibilityQuality:", SellPossibilityMid*SellPossibilityQuality);
FileWrite(handle,"BuyPossibilityMid*BuyPossibilityQuality:", BuyPossibilityMid*BuyPossibilityQuality);
FileWrite(handle,"UndefinedPossibilityMid*UndefinedPossibilityQuality:", UndefinedPossibilityMid*UndefinedPossibilityQuality);
FileWrite(handle,"UndefinedSucPossibilityQuality:", UndefinedSucPossibilityQuality);
FileWrite(handle,"SellSucPossibilityQuality:", SellSucPossibilityQuality);
FileWrite(handle,"BuySucPossibilityQuality:", BuySucPossibilityQuality);
FileWrite(handle,"UndefinedPossibilityQuality:", UndefinedPossibilityQuality);
FileWrite(handle,"SellPossibilityQuality:", SellPossibilityQuality);
FileWrite(handle,"BuyPossibilityQuality:", BuyPossibilityQuality);
FileWrite(handle,"UndefinedSucPossibilityMid:", UndefinedSucPossibilityMid);
FileWrite(handle,"SellSucPossibilityMid:", SellSucPossibilityMid);
FileWrite(handle,"BuySucPossibilityMid:", BuySucPossibilityMid);
FileWrite(handle,"UndefinedPossibilityMid:", UndefinedPossibilityMid);
FileWrite(handle,"SellPossibilityMid:", SellPossibilityMid);
FileWrite(handle,"BuyPossibilityMid:", BuyPossibilityMid);
FileClose(handle);
}
我不知道该怎么做......但这是正确的吗?这不是生成文件。一定是不对的。
2006.11.08 11:21:54 2006.10.06 12:08 Cyberia Trader1.9 R2.2 AlertEuro EURUSDm,H1: error(4101): wrong file name
2006.11.08 11:21:54 2006.10.06 12:08 Cyberia Trader1.9 R2.2 AlertEuro:绝对文件路径 "C:cyberia_log.csv "不允许。
????
这有什么问题吗?
好的,这样就好了....
if(ticket > 0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
{
datetime sorderOpen=OrderOpenTime();
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
if(handle!=-1)
{
FileWrite(handle,"Hour: ",TimeHour(CurTime())," Minute: ",TimeMinute(CurTime()));
FileWrite(handle,"SellPossibilityMid*SellPossibilityQuality:", SellPossibilityMid*SellPossibilityQuality);
FileWrite(handle,"BuyPossibilityMid*BuyPossibilityQuality:", BuyPossibilityMid*BuyPossibilityQuality);
FileWrite(handle,"UndefinedPossibilityMid*UndefinedPossibilityQuality:", UndefinedPossibilityMid*UndefinedPossibilityQuality);
FileWrite(handle,"UndefinedSucPossibilityQuality:", UndefinedSucPossibilityQuality);
FileWrite(handle,"SellSucPossibilityQuality:", SellSucPossibilityQuality);
FileWrite(handle,"BuySucPossibilityQuality:", BuySucPossibilityQuality);
FileWrite(handle,"UndefinedPossibilityQuality:", UndefinedPossibilityQuality);
FileWrite(handle,"SellPossibilityQuality:", SellPossibilityQuality);
FileWrite(handle,"BuyPossibilityQuality:", BuyPossibilityQuality);
FileWrite(handle,"UndefinedSucPossibilityMid:", UndefinedSucPossibilityMid);
FileWrite(handle,"SellSucPossibilityMid:", SellSucPossibilityMid);
FileWrite(handle,"BuySucPossibilityMid:", BuySucPossibilityMid);
FileWrite(handle,"UndefinedPossibilityMid:", UndefinedPossibilityMid);
FileWrite(handle,"SellPossibilityMid:", SellPossibilityMid);
FileWrite(handle,"BuyPossibilityMid:", BuyPossibilityMid);
FileClose(handle);
}
else
{
int err;
err=GetLastError();
Print("error(",err,"): ",ErrorDescription(err));
return(0);
}好的,这就产生了一个文件,但该文件只包含一个条目,而不是所有的订单....oy。
我会为你编码,给我今晚的时间,告诉我你还想甩掉什么?
除了上面的cyberia逻辑外...
我正在考虑测试熊市和牛市的力量指标、cci、adx的3个值、macd和随机指数、rsi,以及基于当前条形图中的收盘价的1MA(收盘价的MA),如果还有其他你认为可以评估的指标,请继续并抛出它们。你明白我的意思,我只是想生成一个轮廓,所以角度越多越好,真的......在一定程度上我想。
还有一件事我必须补充。我在另一个EA上做了一项工作,在订单开仓时保存账户净值,然后在订单关闭时将其与账户净值进行比较,并确定交易是赢家还是输家......我需要这个数据转储也包括这样的交易结果,以便我们在分析交易时知道将其归入哪个类别。
我想我要重新设计一下,用订单开盘价和订单收盘价来代替,因为多笔交易可能会改变账户资产...等一下....
我已经走了一半的路,我已经在代码中得到了这个,只是需要再调整一下......
/////////////record outcomes/////////////////
空白记录长线成果()
{
如果(Bid<OrderOpenPrice())
{
OrderSelect(OrderTicket(),SELECT_BY_POS,MODE_TRADES) 。
Print(" Loser Long ",OrderTicket()," Opened:",OrderOpenPrice()," Closed:",Bid)。
}
返回(0)。
}
空白记录空头结果()
{
如果(Ask>OrderOpenPrice())
{
OrderSelect(OrderTicket(),SELECT_BY_POS,MODE_TRADES) 。
Print(" Loser Short ",OrderTicket()," Opened:",OrderOpenPrice()," Closed:",Bid)。
}
return(0);
}
所以我们在这里的工作方向......也是我前段时间的想法,但我太懒了......是在每个订单的时候记录所有的变量和指标值,这样我们可以看到每个订单到底发生了什么,以确定相关性。
我一直很好奇,当它最终给出一个订单信号时,哪些可能性是存在的,所以这确实应该显示。
然而,每行的宽度可能相当宽,但我认为我们可以进入,如果我们使我们只记录实际选择的指标。
我认为MT4文件的宽度是64个字段......所以有足够的空间来进行操作。
我把我的电子邮件发给你了
所以,我们在这里的工作方向......也是我前一阵子的想法,但我太懒了......是在每笔订单的时候记录所有的变量和指标值,这样我们就可以看到每笔订单的确切情况,以确定相关性
我一直很好奇,当它最终给出一个订单信号时,有哪些可能性,所以这确实应该显示。
然而,每行的宽度可能相当宽,但我认为我们可以进入,如果我们使我们只记录实际选择的指标。
我想,MT4文件的宽度是64个字段......所以有足够的空间进行操作。
我把我的电子邮件发给你了准确地说!精确性确实是我们在过滤器中寻找的,这可能揭示了如何使它对我们有用。
好的,我把我的病人项目发给你,让你探索一下,但不要让它分散你对这个数据转储的注意力,好吗?
当我遇到困难时,我欢迎身边有一个更有经验的开发者。我真的还是个新手,还没有太多的经验。
至于输出。你从这个平台上输出的东西都不可能超过excel的尺寸。我需要的是,它要容易识别,所以当我把 它导入excel时,我可以看到我在做什么,而不是一堆没有记录的数字,都挤在一起,用定界符隔开。我需要每个值的数据标签。我们正在寻找15个CT字段,加上8个指标,CCI,RSI,1MA,bearspower,bullspower,adx(threevalues),再加上无论你怎么做macd和stochastics,如果你计算6,那么总字段=29,加上赢(见以前的帖子)或输=30,开盘和收盘以及时间加3,总和=33,因为我计算。
33个字段/订单。这应该能说明一些问题,是吗?还有一个小忙,如果你能让日期时间真正打印出来(打印到文件),而不是计算机使用的intergervalue,人类可以理解的日期时间,这也会有帮助。
关于这一点,我得到了错误信息......
在我关闭OrderSelect之前,"OrderClose函数 的无效票"。
但我想你能明白我想从中得到什么。
void RecordLongOutcomes()
{
//OrderSelect(OrderTicket(),SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if(OrderType()==OP_BUY)
{
if(OrderOpenPrice() + Spread < OrderClosePrice())
{
datetime borderOpen=OrderOpenTime();
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
if(handle!=-1)
{
FileWrite(handle,"Winning Long OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",borderOpen);
FileClose(handle);
Print(" Winning Long ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
}
else
{
int err;
err=GetLastError();
Print("error(",err,"): ",ErrorDescription(err));
return(0);
}
}
else
{
datetime buyorderOpen=OrderOpenTime();
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
if(handle!=-1)
{
FileWrite(handle,"Losing Long OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",buyorderOpen);
FileClose(handle);
Print(" Losing Long ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
}
else
{
int err1;
err=GetLastError();
Print("error(",err1,"): ",ErrorDescription(err1));
return(0);
}
}//if win or lose
}//if buy
}//if symbol and magic number
return (0);
}//record long outcomes
void RecordShortOutcomes()
{
//OrderSelect(OrderTicket(),SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if(OrderType()==OP_SELL)
{
if(OrderOpenPrice() - Spread > OrderClosePrice())
{
datetime borderOpen=OrderOpenTime();
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
if(handle!=-1)
{
FileWrite(handle,"Winning Short OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",borderOpen);
FileClose(handle);
Print(" Winning Short ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
}
else
{
int err3;
err3=GetLastError();
Print("error(",err3,"): ",ErrorDescription(err3));
return(0);
}
}
else
{
datetime sellorderOpen=OrderOpenTime();
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
if(handle!=-1)
{
FileWrite(handle,"Losing Short OrderTicket: ",OrderTicket()," Opened @: ",OrderOpenPrice()," Closed @: ",OrderClosePrice()," Order Open Time: ",sellorderOpen);
FileClose(handle);
Print(" Losing Short ",OrderTicket()," Opened: ",OrderOpenPrice()," Closed: ", Bid);
}
else
{
int err4;
err4=GetLastError();
Print("error(",err4,"): ",ErrorDescription(err4));
return(0);
}
}//if win or lose
}//if buy
}//if symbol and magic number
return (0);
}//record short outcomes我刚刚添加的记录结果的代码运行良好,除了filewrite()。
我现在正在生成文件,但它只有一个条目,似乎是通过测试器运行的最终订单,所以我认为发生在我身上的是它正在覆盖每个条目,而不是将其追加到文件的末尾。如果我知道如何解决这个问题,我可能现在就能把这个数据转储出来。
好的,这就产生了一个文件,但该文件只包含一个条目,而不是每一个订单....oy。
每次你打开文件时都会被覆盖。一个解决方案是在init()函数 中打开文件,在deinit()中关闭它。
每次你打开文件时,文件都会被覆盖。一个解决方案是在init()函数中打开文件,并在deinit()中关闭它。
我不确定我是否理解如何使用读写标志。
我在这样的例子中看到这些...
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, '; ')。
或
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, ';')。
这是否可行呢?
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_READ|FILE_WRITE, ';') 。
你看,我不明白如何准确地追加到最后。
我不确定如何在init()中打开它
然后
将每个新的命令附加到它的末尾
然后
在deinit()中关闭它
我想它应该是这样的。
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_READ, '; ')。
在初始程序中,然后
FileWrite(handle, "OrderOpen Time:",sorderOpen)。
FileWrite(handle, "SellPossibilityMid*SellPossibilityQuality:", SellPossibilityMid*SellPossibilityQuality)。
FileWrite(handle, "BuyPossibilityMid*BuyPossibilityQuality:", BuyPossibilityMid*BuyPossibilityQuality)。
FileWrite(handle, "UndefinedPossibilityMid*UndefinedPossibilityQuality:", UndefinedPossibilityMid*UndefinedPossibilityQuality)。
FileWrite(handle, "UndefinedSucPossibilityQuality:", UndefinedSucPossibilityQuality)。
FileWrite(handle, "SellSucPossibilityQuality:", SellSucPossibilityQuality);
FileWrite(handle, "BuySucPossibilityQuality:", BuySucPossibilityQuality);
FileWrite(handle, "UndefinedPossibilityQuality:", UndefinedPossibilityQuality);
FileWrite(handle, "SellPossibilityQuality:", SellPossibilityQuality);
FileWrite(handle, "BuyPossibilityQuality:", BuyPossibilityQuality);
FileWrite(handle, "UndefinedSucPossibilityMid:", UndefinedSucPossibilityMid);
FileWrite(handle, "SellSucPossibilityMid:", SellSucPossibilityMid);
FileWrite(handle, "BuySucPossibilityMid:", BuySucPossibilityMid);
FileWrite(handle, "UndefinedPossibilityMid:", UndefinedPossibilityMid);
FileWrite(handle, "SellPossibilityMid:", SellPossibilityMid);
FileWrite(handle, "BuyPossibilityMid:", BuyPossibilityMid); FileWrite(handle, "Winning Short OrderTicket:",OrderTicket()," Opened @:",OrderOpenPrice()," Closed @:",OrderClosePrice()," Order Open Time: ",borderOpen)。
然后在脱机时
FileClose(handle)。
这样做对吗?
//| We initialize the adviser |
//+------------------------------------------------------------------+
int init()
{
handle=FileOpen("cyberia_log.csv", FILE_CSV|FILE_WRITE, ';');
SavedBlockSell = BlockSell;
SavedBlockBuy = BlockBuy;
AccountStatus();
GetMarketInfo();
ModelingPeriod = ValuePeriod * ValuesPeriodCount; // Period of simulation in minutes
if (ValuePeriod != 0 )
ModelingBars = ModelingPeriod / ValuePeriod; // Quantity of steps in the period
CalculateSpread();
return(0);
}我得到一个错误,说 "有太多的文件打开"?