Hilfe bei der Codierung - Seite 259

 

Ich versuche, das Tick-by-Tick-Back-Testing eines benutzerdefinierten Diagramms zu erreichen. Da ich keine Erfahrung damit habe, könnte mir vielleicht jemand eine Hilfe an die Hand geben, um weiterzukommen. Ich mache nämlich offensichtlich etwas falsch.

Ich lese Kurse aus einer CSV-Datei und speichere sie in einer FXT- und HST-Datei.

Dann markiere ich die FXT-Datei als schreibgeschützt. Das Problem ist, dass der Strategietester meine FXT-Datei nie akzeptiert und anhält.

Wovon ich keine Ahnung habe, ist, wie weit die FXT- und HST-Dateien konsistent sein müssen. Was ich meine - z.B. hat ein Rangebar-Chart eine einheitliche Lücke von 1 Punkt in der HST, während er eine moderate Lücke in der FXT hat. Könnte das ein Problem sein?

Dateien:
clipboard72.png  19 kb
 
Ovo:
Ich versuche, das Tick-by-Tick-Backtesting eines benutzerdefinierten Charts durchzuführen. Da ich keine Erfahrung damit habe, könnte mir vielleicht jemand eine Hilfestellung geben, um weiterzukommen. Denn offensichtlich mache ich etwas falsch.

Ich lese Kurse aus einer CSV-Datei und speichere sie in einer FXT- und einer HST-Datei.

Dann markiere ich die FXT-Datei als schreibgeschützt. Das Problem ist, dass der Strategietester meine FXT-Datei nie akzeptiert und anhält.

Wovon ich keine Ahnung habe, ist, wie weit die FXT- und HST-Dateien konsistent sein müssen. Was ich meine - z.B. hat ein Rangebar-Chart eine einheitliche Lücke von 1 Punkt in der HST, während er in der FXT eine moderate Lücke hat. Könnte das ein Problem sein?

Ovo

Das sollte überhaupt kein Problem sein (die Lücken in der fxt-Datei sind viel größer, wenn Sie einen Backtest durchführen, als diese 1 Punkt). Ist das Format der fxt-Datei angemessen (neu)?

 
mladen:
Ovo Das sollte überhaupt kein Problem sein (in der fxt-Datei entstehen beim Backtest viel größere Lücken als diese 1 Punkte). Ist das Format der fxt-Datei angemessen (neu)?

Danke, ich hatte gehofft, dass das kein Problem ist.

Ich bin nicht ganz sicher, was das tatsächliche Format der FXT ist, aber die, die ich habe, rendert Kerzen.

Zunächst fand ich die 401-Version in MQL4 Website, die mir geholfen, die 405 Reverse-Engineering, dann fand ich die CSV2FXT Skript mit der 405-Version in, aber ich habe nicht vollständig analysieren es noch.

Ich denke, der Fehler liegt eher im Header-Inhalt, dem ich nicht viel Aufmerksamkeit geschenkt habe.

Daher sollte ich mich jetzt eher auf den FXT-Header als auf die Kerzenform konzentrieren (sie wird recht gut wiedergegeben).

Ich verwende derzeit diese Struktur für den 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:
Danke, ich hatte gehofft, dass das kein Problem ist.

Ich bin nicht ganz sicher, was das tatsächliche Format des FXT ist, aber das, das ich habe, gibt Kerzen wieder.

Zuerst fand ich die 401-Version auf der MQL4-Website, die mir half, die 405-Version zurückzuentwickeln, dann fand ich das CSV2FXT-Skript mit der 405-Version darin, aber ich habe es noch nicht vollständig analysiert.

Ich denke, der Fehler liegt eher im Header-Inhalt, dem ich nicht viel Aufmerksamkeit geschenkt habe.

Daher sollte ich mich jetzt eher auf den FXT-Header als auf die Kerzenform konzentrieren (sie wird recht gut wiedergegeben).

Ich verwende derzeit diese Struktur für den 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];

};

Ich werde auch versuchen, weitere Informationen zu finden

Einige Details über die Header der hst- und fxt-Dateien wurden nie veröffentlicht, daher bin ich mir nicht sicher, ob wir das Format des Headers 100%ig genau entschlüsseln können

 

Hallo, ich verwende keine runden Zahlen, sondern meine eigenen, speziellen Zahlen und ich möchte sie auf dem beigefügten Indy ersetzen. Meine Zahlen sind 5, 15, 31, 45 und 67. Ich warte auf Ihre freundliche Antwort

Dateien:
 

OrderModify Fehler1

Hallo zusammen,

Ich frage mich, ob mir jemand helfen kann. Ich bekomme keinen Kompilierfehler, aber beim

Testen erhalte ich einen "OrderModify Error1" von MT4. Was könnte ich besser machen

in meinem Code unten?

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);

}

}

Ich danke Ihnen im Voraus!

 
tfi_markets:
OrderModify Fehler1

Hallo zusammen,

ich frage mich, ob mir jemand helfen kann. Ich bekomme keinen Kompilierfehler, aber beim

aber beim Testen erhalte ich einen "OrderModify Error1" von MT4. Was könnte ich besser machen

in meinem Code unten?

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);

}

}

Ich danke Ihnen im Voraus!

tfi_markets

Fehler 1 ist kein Fehler, sondern bedeutet lediglich, dass die von Ihnen beabsichtigte Änderung nicht zu einer Änderung der Order führen würde (die Order würde unverändert bleiben). Sie können es so lassen, wie es ist, oder einfach prüfen, ob der beabsichtigte geänderte Teil ein anderer ist als der Wert, den Sie ihm zuweisen werden

 

Hallo, ich brauche Hilfe, um die Anzahl der Tage seit Beginn eines Renko-Charts zu ermitteln.

Vielen Dank für Hilfe

 
lambic:
Hallo, ich brauche Hilfe, um die Anzahl der Tage seit dem Beginn eines Renko-Charts zu ermitteln. Danke für die Hilfe

Wenn Sie den Zeitraum seit dem ersten (ältesten) Renko-Balken meinen, gehen Sie einfach wie folgt vor:

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

 
mladen:
Wenn Sie seit dem ersten (ältesten) Renko-Balken meinen, machen Sie einfach folgendes: int numOfDays = (Time[0]-Time)/(1440*60);

So einfach! Ich habe nach einer Array-Funktion gesucht und es war einfach Time[]. Tut mir leid, dass es dumm ist. Vielen Dank dafür!

Grund der Beschwerde: