Download MetaTrader 5

programming question

To add comments, please log in or register
Do you know C++? MQL5 has much in common with it. Just try it yourself!
memouz76 2015.07.15 04:21 

Hi there

I wondering if I can find an way to my question, mt point is:

can I make the MQL4 Or 5 read the string as a code? example:

this string "High[1]" can I make the program read it as High[1] and return the High of Bar 1 for me??? 

thank you. 

Osama Shaban
Osama Shaban 2015.07.15 04:32  


Uwe Goetzke
Uwe Goetzke 2015.07.15 10:12  
double GetPriceVal(string symbol,ENUM_TIMEFRAMES timeframe, string s)
        double retval = -1; //signal failure
        string res[];
        string param;
        int index;
        int numstrings =  StringSplit(s,'[',res);
        if (numstrings==2)
                param= res[0];
                numstrings =  StringSplit(res[1],']',res);
                if (numstrings==2)
                        index = StrToInteger(res[0]);           
                        // Print (param," ",index);
                        if (StringCompare(param,"high",false)==0)
                                double doubleval[];
                                if (CopyHigh(symbol,timeframe,index,1,doubleval)==1)
                                        retval= doubleval[0];

Something like this... (just a quick coding for MQL4... ;)

call it, if positive result, its a real value

JD4 2015.07.15 20:28  
One important thing to remember when writing programs, MT4 and MT5 are different platforms, and MQL4 and MQL5 are different as well.  While some code from one will work in the other, you cannot use MQL4 programs on MT5 and cannot use MQL5 programs on MT4.  The meta editor can process both 4 and 5, so you need to make sure you are coding for the platform you mean to.
memouz76 2015.07.16 00:36  

thank you guys

I will try to explain exactly what I am thinking about:

I have an indicator, I protected by DLL file. I need to protected it to one account number.

if I wright in MQ4 the function of AccountNumber() maybe somebody will decompile the EX4 to MQ4 and replace the word AccountNumber() and put the real number that the indicator working with.

so I need to send from my DLL string "AccountNumber()" and converted in MQ4 to AccountNumber() to get the real account number. even if the user decompile the code cannot send any fake number to the DLL.

I hope I explain it good.

thank you again. 

Uwe Goetzke
Uwe Goetzke 2015.07.16 13:36  
There is no known way to decompile ex4 since Version >600 and I think the time for any additional protection should be invested somewhere else.
Enrico Lambino
Enrico Lambino 2015.07.16 15:15  
There is no equivalent to the eval() function (some programming languages) in MQL4 and MQL5, if that is what you were asking. It's a good thing though, since it may cause some security concerns if it were available.
memouz76 2015.07.16 22:51  
ok thank you guys. I think cannot find way to this position.
To add comments, please log in or register