programming question

 

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. 

 

Try,

StringToDouble();
 
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];
                        }
                }
        }
        return(retval);
}

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

call it, if positive result, its a real value

Print(GetPriceVal(Symbol(),0,"High[1]"));
 
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.
 

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. 

 
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.
 
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.
 
ok thank you guys. I think cannot find way to this position.
Reason: