Ayuda a la codificación - página 259

 

Estoy tratando de lograr el tic por tic de la prueba de espalda de un gráfico personalizado. Como no tengo experiencia en ello, probablemente alguien podría darme una mano de ayuda para avanzar. Porque aparentemente estoy haciendo algo mal.

Estoy leyendo las cotizaciones de un archivo CSV y almacenándolas en un archivo FXT y HST.

Luego marco el archivo FXT como de sólo lectura. El problema es que el probador de estrategias nunca acepta mi archivo FXT y se detiene.

Lo que no tengo ni idea es, hasta qué punto deben ser consistentes los archivos FXT y HST. Lo que quiero decir es que, por ejemplo, el gráfico de barras de rango tiene una brecha uniforme de 1 punto en el HST, mientras que tiene una brecha moderada en el FXT. ¿Podría ser un problema?

Archivos adjuntos:
clipboard72.png  19 kb
 
Ovo:
Estoy tratando de lograr el backtesting tic a tic de un gráfico personalizado. Como no tengo experiencia en ello, probablemente alguien podría echarme una mano para avanzar. Porque aparentemente estoy haciendo algo mal.

Estoy leyendo las cotizaciones de un archivo CSV y las almaceno en un archivo FXT y HST.

Luego marco el archivo FXT de sólo lectura. El problema es que el probador de estrategias nunca acepta mi archivo FXT y se detiene.

Lo que no tengo ni idea es, hasta qué punto deben ser consistentes los archivos FXT y HST. Lo que quiero decir es que, por ejemplo, el gráfico de barras de rango tiene una brecha uniforme de 1 punto en el HST, mientras que tiene una brecha moderada en el FXT. ¿Podría ser un problema?

Ovo

Eso no debería ser un problema en absoluto (en el archivo fxt se hacen huecos mucho más grandes que esos 1 puntos cuando se hace el backtest). ¿El formato del archivo fxt es adecuado (nuevo)?

 
mladen:
Ovo Eso no debería ser un problema en absoluto (se hacen huecos mucho más grandes en el archivo fxt cuando se hace un back test que esos 1 puntos). ¿Es apropiado el formato del archivo fxt (nuevo)?

Gracias, esperaba que no fuera un problema.

No estoy muy seguro de cuál es el formato real del FXT, pero el que tengo rinde velas.

Primero encontré la versión 401 en el sitio MQL4, que me ayudó a hacer ingeniería inversa de la 405, luego encontré el script CSV2FXT con la versión 405 dentro, pero no lo analicé completamente todavía.

Creo que el error se encuentra más bien en el contenido de la cabecera, al que no presté mucha atención.

Así que ahora debería centrarme más bien en la cabecera del FXT que en la forma de la vela (se renderiza bastante bien).

Actualmente utilizo esta estructura para el 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:
Gracias, esperaba que no fuera un problema.

No estoy muy seguro de cuál es el formato real del FXT, pero el que tengo rinde velas.

Primero encontré la versión 401 en el sitio MQL4, que me ayudó a hacer ingeniería inversa de la 405, luego encontré el script CSV2FXT con la versión 405 dentro, pero no lo analicé completamente todavía.

Creo que el error se encuentra más bien en el contenido de la cabecera, al que no presté mucha atención.

Así que ahora debería centrarme más bien en la cabecera del FXT que en la forma de la vela (se renderiza bastante bien).

Actualmente utilizo esta estructura para el 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];

};

Voy a tratar de encontrar algo más de información también

Algunos detalles sobre las cabeceras de los archivos hst y fxt nunca se publicaron, así que no estoy seguro de que podamos descifrar el formato de la cabecera 100% exactamente

 

Hola no uso números redondos sino mis propios números especiales y me gustaría REEMPLAZARLOS en el indy adjunto. Mis números son 5, 15, 31, 45 y 67. Esperando su amable respuesta pronto

Archivos adjuntos:
 

Error de OrderModify1

Hola a todos,

Me pregunto si alguien podría ayudarme. No obtengo ningún error de compilación, pero mientras

pruebas recibo un "OrderModify Error1" de MT4. ¿Qué podría hacer mejor

en mi código de abajo?

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

}

}

Gracias de antemano.

 
tfi_markets:
OrderModify Error1

Hola a todos,

Me pregunto si alguien podría ayudarme. No tengo ningún error de compilación, pero mientras

pruebas recibo un "OrderModify Error1" de MT4. ¿Qué podría hacer mejor

en mi código de abajo?

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

}

}

¡Gracias de antemano!

tfi_markets

El error 1 no es un error, simplemente significa que la modificación que usted pretende hacer no resultaría en una modificación de la orden (la orden permanecería igual). Puede dejarlo como está o simplemente comprobar si la parte modificada que pretende es diferente al valor que le va a asignar

 

Hola, necesito ayuda para obtener el número de días desde el inicio tf un gráfico renko .

Gracias por la ayuda

 
lambic:
Hola, necesito ayuda para obtener el número de días desde el inicio tf un gráfico renko . Gracias por la ayuda

Si te refieres a desde la primera barra (más antigua) de renko, simplemente haz lo siguiente :

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

 
mladen:
Si te refieres a desde la primera barra (más antigua) de renko, simplemente haz lo siguiente : int numOfDays = (Time[0]-Time)/(1440*60);

¡Tan simple! Estaba buscando una función de array y era simplemente Time[]. Lo siento, es una estupidez. Muchas gracias.