编码帮助 - 页 259

 

我正试图实现自定义图表的tick by tick回测。由于我没有这方面的经验,也许有人能给我一个帮助,让我站出来。因为我显然是做错了什么。

我正在从CSV文件中读取报价,并将其存储到FXT和HST文件中。

然后我把FXT文件标记为只读。问题是,策略测试器 从不接受我的FXT文件,并停止运行。

我不知道的是,FXT和HST文件必须有多大的一致性。我的意思是--例如,rangebars图表在HST中具有统一的1点差距,而在FXT中具有适度的差距。这可能是一个问题吗?

附加的文件:
clipboard72.png  19 kb
 
Ovo:
我正试图实现对一个自定义图表进行逐点回测。由于我没有这方面的经验,也许有人可以给我一个帮助,让我站出来。因为我显然是做错了什么。

我正在从CSV文件中读取报价,并将其存储到FXT和HST文件中。

然后我把FXT文件标记为只读。问题是,策略测试器从来没有接受过我的FXT文件,并且停止了。

我不知道的是,FXT和HST文件必须有多大的一致性。我的意思是--例如,在HST中,rangebars图表有1个点的统一差距,而在FXT中,它有适度的差距。这可能是一个问题吗?

奥沃

这根本不应该是个问题(当你回测时,fxt文件中的缺口比这1个点大得多)。fxt文件的格式是否合适(新)?

 
mladen:
Ovo 这应该不是一个问题(当你回测时,fxt文件中的缺口要比这1个点大得多)。fxt文件的格式是否合适(新)?

谢谢,我希望这不是一个问题。

我不太清楚FXT的实际格式是什么,但我有一个渲染的蜡烛。

首先,我在MQL4网站上找到了401版本,这有助于我反向开发405版本,然后我找到了CSV2FXT脚本,里面有405版本,但我还没有完全分析它。

我认为错误在于头的内容,我没有太注意到这一点。

所以现在我应该把注意力放在FXT的标题上,而不是蜡烛的形状上(它的渲染很合适)。

我目前在FXT上使用这种结构。

struct Shortdate {

int date;

};

struct Padding {

char padding;

};

struct MT4FxtCandle {

datetime openTime;

double open;

double high;

double low;

double close;

uint volume;

uint spread;

Shortdate tickTime;

int flag;

};

struct MT4FxtHeader {

int version;

char copyright[64];

char server[128];

char symbol[12];

int period;

TestModelEnum model;

int bars;

Shortdate fromdate;

Shortdate todate;

Padding p1[4];

double modelquality;

char currency[12];

int spread;

int digits;

Padding p2[4];

double point;

int lot_min;

int lot_max;

int lot_step;

int stops_level;

int gtc_pendings;

Padding p3[4];

double contract_size;

double tick_value;

double tick_size;

ProfitCalcModeEnum profit_mode;

int swap_enable;

int swap_type;

Padding p4[4];

double swap_long;

double swap_short;

int swap_rollover3days;

int leverage;

FreeMarginCalcModeEnum free_margin_mode;

MarginCalcModeEnum margin_mode;

int margin_stopout;

ENUM_ACCOUNT_STOPOUT_MODE margin_stopout_mode;

double margin_initial;

double margin_maintenance;

double margin_hedged;

double margin_divider;

char margin_currency[12];

Padding p5[4];

double comm_base;

int comm_type;

int comm_lots;

int from_bar;

int to_bar;

int start_period[6];

int from;

int to;

int freeze_level;

int reserved[61];

};

 
Ovo:
谢谢,我希望这不是一个问题。

我不太清楚FXT的实际格式是什么,但我有一个渲染的蜡烛。

首先,我在MQL4网站上找到了401版本,这有助于我反向开发405版本,然后我找到了CSV2FXT脚本,里面有405版本,但我还没有完全分析它。

我认为错误在于头的内容,我没有太注意到这一点。

所以现在我应该把注意力放在FXT的标题上,而不是蜡烛的形状上(它的渲染很合适)。

我目前在FXT上使用这种结构。

struct Shortdate {

int date;

};

struct Padding {

char padding;

};

struct MT4FxtCandle {

datetime openTime;

double open;

double high;

double low;

double close;

uint volume;

uint spread;

Shortdate tickTime;

int flag;

};

struct MT4FxtHeader {

int version;

char copyright[64];

char server[128];

char symbol[12];

int period;

TestModelEnum model;

int bars;

Shortdate fromdate;

Shortdate todate;

Padding p1[4];

double modelquality;

char currency[12];

int spread;

int digits;

Padding p2[4];

double point;

int lot_min;

int lot_max;

int lot_step;

int stops_level;

int gtc_pendings;

Padding p3[4];

double contract_size;

double tick_value;

double tick_size;

ProfitCalcModeEnum profit_mode;

int swap_enable;

int swap_type;

Padding p4[4];

double swap_long;

double swap_short;

int swap_rollover3days;

int leverage;

FreeMarginCalcModeEnum free_margin_mode;

MarginCalcModeEnum margin_mode;

int margin_stopout;

ENUM_ACCOUNT_STOPOUT_MODE margin_stopout_mode;

double margin_initial;

double margin_maintenance;

double margin_hedged;

double margin_divider;

char margin_currency[12];

Padding p5[4];

double comm_base;

int comm_type;

int comm_lots;

int from_bar;

int to_bar;

int start_period[6];

int from;

int to;

int freeze_level;

int reserved[61];

};

我也会试着找一些更多的信息

关于hst和fxt文件头的一些细节,他们从未公布过,所以我不确定我们是否能100%准确地破译头的格式。

 

你好,我不使用圆形数字,而是使用我个人的特殊数字,我想把它们替换到所附的indy上。我的数字是5、15、31、45和67。等待您的回复

附加的文件:
 

订单修改错误1

大家好。

我想知道是否有人能帮助我。我没有得到任何编译错误,但是当

时,我从MT4得到一个 "OrderModify Error1"。我可以在以下代码中做得更好

我下面的代码?

bool ModifyOrder(int nOrderType,int ord_ticket,double op,double price,double tp,color mColor=CLR_NONE)

{

int cnt,err;

double myStop;

myStop=ValidStopLoss(nOrderType,price);

cnt=0;

while(cnt<totalTries)

{

if(OrderModify(ord_ticket,op,myStop,tp,0,mColor))

{

return(true);

}

else

{

err=GetLastError();

if(err>1) Print(cnt," Error modifying order : (",ord_ticket,") "+ErrorDescription(err)," err ",err);

if(err>0) cnt++;

Sleep(retryDelay);

}

}

return(false);

}

[/CODE]

void OpenBuyOrder()

{

int ticket;

int err,digits;

double myStopLoss=0,myTakeProfit=0,myPrice=0;

myPrice=MarketInfo(Symbol(),MODE_ASK);

myStopLoss=0;

if(StopLoss>0) myStopLoss=myPrice-StopLoss*point;

if(myStopLoss!=0) ValidStopLoss(OP_BUY,myStopLoss);

myTakeProfit=0;

if(UseTakeProfit && TakeProfit>0) myTakeProfit=myPrice+TakeProfit*point;

// Normalize all price / stoploss / takeprofit to the proper # of digits.

digits=MarketInfo(Symbol(),MODE_DIGITS);

if(digits>0)

{

myPrice=NormalizeDouble(myPrice,digits);

myStopLoss=NormalizeDouble(myStopLoss,digits);

myTakeProfit=NormalizeDouble(myTakeProfit,digits);

}

ticket=OrderSend(Symbol(),OP_BUY,lotMM,myPrice,Slippage,myStopLoss,myTakeProfit,setup,MagicNumber,0,LimeGreen);

if(ticket>0 && ModifyOrder(OP_BUY,ticket,OrderOpenPrice(),myStopLoss,myTakeProfit,CLR_NONE))

{

if(Debug) Print("BUY order opened : ",OrderOpenPrice());

}

else

{

err=GetLastError();

Print("Error opening BUY order : ("+err+") "+ErrorDescription(err));

}

}

[/CODE]

[CODE]

void OpenSellOrder()

{

int ticket;

int err,digits;

double myStopLoss=0,myTakeProfit=0,myPrice=0;

myPrice=MarketInfo(Symbol(),MODE_BID);

myStopLoss=0;

if(StopLoss>0) myStopLoss=myPrice+StopLoss*point;

if(myStopLoss!=0) ValidStopLoss(OP_SELL,myStopLoss);

myTakeProfit=0;

if(UseTakeProfit && TakeProfit>0) myTakeProfit=myPrice-TakeProfit*point;

// Normalize all price / stoploss / takeprofit to the proper # of digits.

digits=MarketInfo(Symbol(),MODE_DIGITS);

if(digits>0)

{

myPrice=NormalizeDouble(myPrice,digits);

myStopLoss=NormalizeDouble(myStopLoss,digits);

myTakeProfit=NormalizeDouble(myTakeProfit,digits);

}

ticket=OrderSend(Symbol(),OP_SELL,lotMM,myPrice,Slippage,myStopLoss,myTakeProfit,setup,MagicNumber,0,Red);

if(ticket>0 && ModifyOrder(OP_SELL,ticket,OrderOpenPrice(),myStopLoss,myTakeProfit,CLR_NONE))

{

if(Debug) Print("SELL order opened : ",OrderOpenPrice());

}

else

{

err=GetLastError();

Print("Error opening SELL order : ("+err+") "+ErrorDescription(err));

}

return(0);

}

[CODE]

int HandleTrailingStop(int type,int ticket,double op,double os,double tp)

{

double pt,TS=0,myAsk,myBid;

switch(type)

{

case OP_BUY:

{

myBid=MarketInfo(Symbol(),MODE_BID);

switch(TrailingStopType)

{

case 1: pt=point*StopLoss;

if(myBid-os>pt)

ModifyOrder(type,ticket,op,myBid-pt,tp,Aqua);

break;

case 2: pt=point*TrailingStop;

if(myBid-op>pt && os<myBid-pt)

ModifyOrder(type,ticket,op,myBid-pt,tp,Aqua);

break;

}

return(0);

break;

}

case OP_SELL:

{

myAsk=MarketInfo(Symbol(),MODE_ASK);

switch(TrailingStopType)

{

case 1: pt=point*StopLoss;

if(os-myAsk>pt)

ModifyOrder(type,ticket,op,myAsk+pt,tp,Aqua);

break;

case 2: pt=point*TrailingStop;

if(op-myAsk>pt && os>myAsk+pt)

ModifyOrder(type,ticket,op,myAsk+pt,tp,Aqua);

break;

}

}

return(0);

}

}

谢谢您的帮助。

 
tfi_markets:
OrderModify Error1

大家好。

我想知道是否有人能帮助我。我没有得到任何编译错误,但是当

时,我从MT4得到一个 "OrderModify Error1"。我在下面的代码中可以做得更好

在我下面的代码中做得更好?

bool ModifyOrder(int nOrderType,int ord_ticket,double op,double price,double tp,color mColor=CLR_NONE)

{

int cnt,err;

double myStop;

myStop=ValidStopLoss(nOrderType,price);

cnt=0;

while(cnt<totalTries)

{

if(OrderModify(ord_ticket,op,myStop,tp,0,mColor))

{

return(true);

}

else

{

err=GetLastError();

if(err>1) Print(cnt," Error modifying order : (",ord_ticket,") "+ErrorDescription(err)," err ",err);

if(err>0) cnt++;

Sleep(retryDelay);

}

}

return(false);

}

[/CODE]

void OpenBuyOrder()

{

int ticket;

int err,digits;

double myStopLoss=0,myTakeProfit=0,myPrice=0;

myPrice=MarketInfo(Symbol(),MODE_ASK);

myStopLoss=0;

if(StopLoss>0) myStopLoss=myPrice-StopLoss*point;

if(myStopLoss!=0) ValidStopLoss(OP_BUY,myStopLoss);

myTakeProfit=0;

if(UseTakeProfit && TakeProfit>0) myTakeProfit=myPrice+TakeProfit*point;

// Normalize all price / stoploss / takeprofit to the proper # of digits.

digits=MarketInfo(Symbol(),MODE_DIGITS);

if(digits>0)

{

myPrice=NormalizeDouble(myPrice,digits);

myStopLoss=NormalizeDouble(myStopLoss,digits);

myTakeProfit=NormalizeDouble(myTakeProfit,digits);

}

ticket=OrderSend(Symbol(),OP_BUY,lotMM,myPrice,Slippage,myStopLoss,myTakeProfit,setup,MagicNumber,0,LimeGreen);

if(ticket>0 && ModifyOrder(OP_BUY,ticket,OrderOpenPrice(),myStopLoss,myTakeProfit,CLR_NONE))

{

if(Debug) Print("BUY order opened : ",OrderOpenPrice());

}

else

{

err=GetLastError();

Print("Error opening BUY order : ("+err+") "+ErrorDescription(err));

}

}

[/CODE]

[CODE]

void OpenSellOrder()

{

int ticket;

int err,digits;

double myStopLoss=0,myTakeProfit=0,myPrice=0;

myPrice=MarketInfo(Symbol(),MODE_BID);

myStopLoss=0;

if(StopLoss>0) myStopLoss=myPrice+StopLoss*point;

if(myStopLoss!=0) ValidStopLoss(OP_SELL,myStopLoss);

myTakeProfit=0;

if(UseTakeProfit && TakeProfit>0) myTakeProfit=myPrice-TakeProfit*point;

// Normalize all price / stoploss / takeprofit to the proper # of digits.

digits=MarketInfo(Symbol(),MODE_DIGITS);

if(digits>0)

{

myPrice=NormalizeDouble(myPrice,digits);

myStopLoss=NormalizeDouble(myStopLoss,digits);

myTakeProfit=NormalizeDouble(myTakeProfit,digits);

}

ticket=OrderSend(Symbol(),OP_SELL,lotMM,myPrice,Slippage,myStopLoss,myTakeProfit,setup,MagicNumber,0,Red);

if(ticket>0 && ModifyOrder(OP_SELL,ticket,OrderOpenPrice(),myStopLoss,myTakeProfit,CLR_NONE))

{

if(Debug) Print("SELL order opened : ",OrderOpenPrice());

}

else

{

err=GetLastError();

Print("Error opening SELL order : ("+err+") "+ErrorDescription(err));

}

return(0);

}

[CODE]

int HandleTrailingStop(int type,int ticket,double op,double os,double tp)

{

double pt,TS=0,myAsk,myBid;

switch(type)

{

case OP_BUY:

{

myBid=MarketInfo(Symbol(),MODE_BID);

switch(TrailingStopType)

{

case 1: pt=point*StopLoss;

if(myBid-os>pt)

ModifyOrder(type,ticket,op,myBid-pt,tp,Aqua);

break;

case 2: pt=point*TrailingStop;

if(myBid-op>pt && os<myBid-pt)

ModifyOrder(type,ticket,op,myBid-pt,tp,Aqua);

break;

}

return(0);

break;

}

case OP_SELL:

{

myAsk=MarketInfo(Symbol(),MODE_ASK);

switch(TrailingStopType)

{

case 1: pt=point*StopLoss;

if(os-myAsk>pt)

ModifyOrder(type,ticket,op,myAsk+pt,tp,Aqua);

break;

case 2: pt=point*TrailingStop;

if(op-myAsk>pt && os>myAsk+pt)

ModifyOrder(type,ticket,op,myAsk+pt,tp,Aqua);

break;

}

}

return(0);

}

}

谢谢你的帮助!

tfi_markets

错误1不是一个错误,它只是意味着您打算做的修改不会导致订单修改(订单将保持不变)。你可以让它保持原样,或者简单地检查 打算修改的部分是否与你要分配给它的值不同

 

你好,我需要帮助来获得自renko图表开始的天数。

谢谢你的帮助

 
lambic:
你好,我需要帮助,以获得自renko图表开始以来的天数。 谢谢你的帮助。

如果你是指从renko的第一个(最古老的)条形图开始,只需做以下工作。

int numOfDays = (Time[0]-Time)/(1440*60);

 
mladen:
如果你的意思是自renko的第一个(最古老的)条形图开始,只需做如下操作:int numOfDays = (Time[0]-Time)/(1440*60)。

太简单了! 我正在寻找一个数组函数,而它仅仅是Time[]。对不起,这很愚蠢。非常感谢!