Traducir mq4 a mq5

Foro dedicado a todo lo relacionado con la versión 4 de la plataforma de Metaquotes.
Responder
Avatar de Usuario
Fer137
Mensajes: 1371
Registrado: 12 Nov 2007 18:43

Traducir mq4 a mq5

Mensaje por Fer137 »

Fer137 escribió:Para pasar de mq4 a mq5 estoy haciendo un mqh, muchas de las funciones se pueden traducir en una linea.
Spirit, tu que decías que tenías muchos programadores a tu cargo, diles que traduzcan mql, que es mucho curro :)

Código: Seleccionar todo

//___________________________________________________________________________________________________________________________________________________
string OrderComment(){return(OrderGetString(ORDER_COMMENT));}
string OrderSymbol(){return(OrderGetString(ORDER_SYMBOL));}
long OrderType(){return(OrderGetInteger(ORDER_TYPE));}
long OrderMagicNumber(){return(OrderGetInteger(ORDER_MAGIC));}
long OrderOpenTime(){return(OrderGetInteger(ORDER_TIME_SETUP));}
long OrderCloseTime(){return(OrderGetInteger(ORDER_TIME_DONE));}
double OrderLots(){return(OrderGetDouble(ORDER_VOLUME_CURRENT));}
double OrderProfit(){return(OrderGetDouble(ORDER_VOLUME_CURRENT));}
double OrderOpenPrice(){return(OrderGetDouble(ORDER_PRICE_OPEN));}
double OrderStopLoss(){return(OrderGetDouble(ORDER_SL));}
double OrderTakeProfit(){return(OrderGetDouble(ORDER_TP));}
int OrdersHistoryTotal(){return(HistoryOrdersTotal());}
//___________________________________________________________________________________________________________________________________________________
int Day(){MqlDateTime tm;  TimeCurrent(tm); return(tm.day);}
int DayOfWeek(){MqlDateTime tm;TimeCurrent(tm);return(tm.day_of_week);}
int DayOfYear(){MqlDateTime tm;TimeCurrent(tm);return(tm.day_of_year);}
int Hour(){MqlDateTime tm;TimeCurrent(tm);return(tm.hour);}
int Minute(){MqlDateTime tm;TimeCurrent(tm);return(tm.min);}
int Seconds(){MqlDateTime tm;TimeCurrent(tm);return(tm.sec);}
int Year(){MqlDateTime tm;TimeCurrent(tm);return(tm.year);}
int TimeDay(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.day);}
int TimeDayOfWeek(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.day_of_week);}
int TimeDayOfYear(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.day_of_year);}
int TimeHour(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.hour);}
int TimeMinute(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.min);}
int TimeMonth(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.mon);}
int TimeSeconds(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.sec);}
int TimeYear(datetime date){MqlDateTime tm;TimeToStruct(date,tm);return(tm.year);}
//___________________________________________________________________________________________________________________________________________________
string TerminalPath(){return(TerminalInfoString(TERMINAL_PATH));}
string TerminalCompany(){return(TerminalInfoString(TERMINAL_COMPANY));}
string TerminalName(){return(TerminalInfoString(TERMINAL_NAME));}
//___________________________________________________________________________________________________________________________________________________
double AccountBalance(){  	return(AccountInfoDouble(ACCOUNT_BALANCE));}
double AccountCredit(){return(AccountInfoDouble(ACCOUNT_CREDIT));}
string AccountCompany(){return(AccountInfoString(ACCOUNT_COMPANY));}
string AccountCurrency(){return(AccountInfoString(ACCOUNT_CURRENCY));}
double AccountEquity(){return(AccountInfoDouble(ACCOUNT_EQUITY));}
double AccountFreeMargin(){return(AccountInfoDouble(ACCOUNT_FREEMARGIN));}
long   AccountLeverage(){return(AccountInfoInteger(ACCOUNT_LEVERAGE));}
double AccountMargin(){return(AccountInfoDouble(ACCOUNT_MARGIN));}
string AccountName(){return(AccountInfoString(ACCOUNT_NAME));}
long   AccountNumber(){return(AccountInfoInteger(ACCOUNT_LOGIN));}
double AccountProfit(){return(AccountInfoDouble(ACCOUNT_PROFIT));}
string AccountServer(){return(AccountInfoString(ACCOUNT_SERVER));}
double AccountStopoutLevel(){return(AccountInfoDouble(ACCOUNT_MARGIN_SO_SO));}
long   AccountStopoutMode(){return(AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE));}
//___________________________________________________________________________________________________________________________________________________
string   CharToStr(uchar ch ){return(CharToString(ch));}
string   DoubleToStr(double val, int dig ){return(DoubleToString(val,dig));}
double   StrToDouble(string str){return(StringToDouble(str));}
long     StrToInteger(string str ){return(StringToInteger(str));}
datetime StrToTime(string str){return(StringToTime(str));}
string   TimeToStr(datetime t,int mode=TIME_DATE|TIME_MINUTES){return(TimeToString(t,mode)); }
ushort   StringGetChar(string str, int pos){return(StringGetCharacter(str,pos));}
bool     StringSetChar(string& str,int pos, ushort character ){return(StringSetCharacter(str,pos,character));}


//___________________________________________________________________________________________________________________________________________________
// overrideando
int OrderSend(string symbol, int cmd, double volumen, double precio, int slippage, double stoploss, double takeprofit, 
              string comentario=NULL, int magicn=0, datetime expiracion=0, color arrow_color=CLR_NONE){
    MqlTradeRequest op;   MqlTradeResult res;
    op.action=TRADE_ACTION_DEAL;
    op.symbol=symbol;
    op.type=cmd;
    op.volume=volumen;
    op.price=precio;
    op.deviation=slippage;
    op.sl=stoploss;
    op.tp=takeprofit;
    op.comment=comentario;
    op.magic=magicn;
    op.expiration=expiracion;
   if(OrderSend(op,res)){if(cmd<2)return(res.deal);else return(res.order);}else return(-1);
}

//___________________________________________________________________________________________________________________________________________________
Última edición por Fer137 el 12 Dic 2010 04:48, editado 1 vez en total.
Avatar de Usuario
X-Trader
Administrador
Mensajes: 12798
Registrado: 06 Sep 2004 10:18
Contactar:

Re: Traducir mq4 a mq5

Mensaje por X-Trader »

Empecemos por el principio :)

http://www.x-trader.net/articulos/softw ... -mql5.html

Saludos,
X-Trader
"Los sistemas de trading pueden funcionar en ciertas condiciones de mercado todo el tiempo, en todas las condiciones de mercado en algún momento del tiempo, pero nunca en todas las condiciones de mercado todo el tiempo."
Avatar de Usuario
cu6yu4
Mensajes: 632
Registrado: 10 Oct 2009 15:31
Ubicación: Barcelona

Re: Traducir mq4 a mq5

Mensaje por cu6yu4 »

Dale fuerte Fer137, que no es cosa fácil.

Pero... ¿no habrás caído en el pecado por antonomasia del programador? Que no es otro que querer ser creativo y empezar de cero(pobres informáticos; los tienen picando código tonto; se aburren) una aplicación, cuando lo más productivo es adaptar/mejorar algo ya presente...

Como programador de mql hay trabajo... se trataría de saber venderse, como todo... Si alguien va a montar algo yo le puedo hacer de secretario si quiere, y picar código tonto por un % modesto.
Uno es esclavo de sus palabras y dueño de sus silencios (José María García).
Avatar de Usuario
Fer137
Mensajes: 1371
Registrado: 12 Nov 2007 18:43

Re: Traducir mq4 a mq5

Mensaje por Fer137 »

X-Trader escribió:Empecemos por el principio :)

http://www.x-trader.net/articulos/softw ... -mql5.html

Saludos,
X-Trader
De ahí he copipasteao y condensado una gran parte. Pero ese script tal cual no funciona, es mas bien como una guía o prototipo.
Fijate que tiene varios 'Etc.' :

Código: Seleccionar todo

   return("\n//:::::::::::::::::::::::::::::::::::::::::::::\n"+
         "#include <mt4accountinfo.mqh>\n"+
         "#include <mt4string.mqh>\n"+
         "#include <mt4datetime.mqh>\n"+
         "#include <mt4objects_1.mqh>\n"+
         "#include <mt4timeseries_2.mqh>\n"+
         "//Etc.\n"+

Código: Seleccionar todo

return("\n  //:::::::::::::::::::::::::::::::::::::::::::::\n"+
         "  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);\n"+
         "  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);\n"+
         "  int Bars=Bars(Symbol(),PERIOD_CURRENT);\n"+
         "  double Point=Point();\n"+
         "  //Etc.\n"+
Última edición por Fer137 el 12 Dic 2010 13:26, editado 1 vez en total.
Avatar de Usuario
Fer137
Mensajes: 1371
Registrado: 12 Nov 2007 18:43

Re: Traducir mq4 a mq5

Mensaje por Fer137 »

cu6yu4 escribió:Dale fuerte Fer137, que no es cosa fácil.

Pero... ¿no habrás caído en el pecado por antonomasia del programador? Que no es otro que querer ser creativo y empezar de cero(pobres informáticos; los tienen picando código tonto; se aburren) una aplicación, cuando lo más productivo es adaptar/mejorar algo ya presente...
Tranquilo, ya utilizo lo que veo hecho. El viejo proverbio "La Pereza, la madre de la Ciencia."
Si te ha gustado este hilo del Foro, ¡compártelo en redes!


Responder

Volver a “Metatrader 4”