This project is read-only.

How can I do now? - solved

Nov 24, 2012 at 7:20 AM
Edited Nov 24, 2012 at 7:21 AM

How can I use iCustom ? and also iClose, iHigh, iLow.

when I add the below code in C#, when I invoke them, the expert_net return "###NORESULT###".

 

namespace MyForexRobot
{
    public static class CustomIndicators
    {
        public static double iCustom(this MqlHandler handler, string symbol, TIME_FRAME timeframe, params object[] parameters)
        {
            string returnValue = handler.CallMqlMethod("iCustom", symbol, ((int)timeframe), parameters);

            return Convertor.ToDouble(returnValue);
        }

        public static double iClose(this MqlHandler handler, string symbol, TIME_FRAME timeframe, int shift)
        {
            string returnValue = handler.CallMqlMethod("iClose", new object[] { symbol, (int) timeframe, shift });

            return Convertor.ToDouble(returnValue);
        }
        public static double iHigh(this MqlHandler handler, string symbol, TIME_FRAME timeframe, int shift)
        {
            string returnValue = handler.CallMqlMethod("iHigh", new object[] { symbol, (int) timeframe, shift });

            return Convertor.ToDouble(returnValue);
        }
        public static double iLow(this MqlHandler handler, string symbol, TIME_FRAME timeframe, int shift)
        {
            string returnValue = handler.CallMqlMethod("iLow", new object[] { symbol, (int) timeframe, shift });

            return Convertor.ToDouble(returnValue);
        }
    }
}
Dec 9, 2012 at 8:31 AM
Edited Dec 9, 2012 at 8:34 AM

I have solved my problems, and now I post my solution to here.

1. first of all, add some C# code just like below:

 

    public static class CustomIndicators
    {
        public static double iCustom(this MqlHandler handler, string symbol, TIME_FRAME timeframe, string name, params object[] parameters)
        {
            if (parameters.Length >= 2) { //if use iCustom method, the last two must be mode and shift.
                object[] parms = new object[parameters.Length + 4];
                parms[0] = symbol;
                parms[1] = timeframe;
                parms[2] = name;
                parms[3] = parms.Length;//for mql to switch some method.

                for (int i = 0; i < parameters.Length; i++) {
                    parms[i + 4] = parameters[i];
                }

                string returnValue = handler.CallMqlMethod("iCustom", parms);
                return Convertor.ToDouble(string.IsNullOrEmpty(returnValue) ? "0" : returnValue);
            }

            return double.NaN;
        }
        public static double iOpen(this MqlHandler handler, string symbol, TIME_FRAME timeframe, int shift)
        {
            string returnValue = handler.CallMqlMethod("iOpen", new object[] { symbol, (int) timeframe, shift });

            return Convertor.ToDouble(returnValue);
        }
        public static double iClose(this MqlHandler handler, string symbol, TIME_FRAME timeframe, int shift)
        {
            string returnValue = handler.CallMqlMethod("iClose", new object[] { symbol, (int) timeframe, shift });

            return Convertor.ToDouble(returnValue);
        }
        public static double iHigh(this MqlHandler handler, string symbol, TIME_FRAME timeframe, int shift)
        {
            string returnValue = handler.CallMqlMethod("iHigh", new object[] { symbol, (int) timeframe, shift });

            return Convertor.ToDouble(returnValue);
        }
        public static double iLow(this MqlHandler handler, string symbol, TIME_FRAME timeframe, int shift)
        {
            string returnValue = handler.CallMqlMethod("iLow", new object[] { symbol, (int) timeframe, shift });

            return Convertor.ToDouble(returnValue);
        }
    }

2. the second is modify the MQL API for .net file System_NET_MQL.mqh which is at $MT4$\experts\include directory. Add the below code in System_NET_MQL_TechIndicators method.
	//////////////////////////////////////////////////////////////////////////
	if(message[1] == "iCustom"){
	  switch(StrToInteger(message[5])){
	     case 6:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], StrToInteger(message[6]), StrToInteger(message[7])));
	        break;
	     case 7:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], StrToInteger(message[7]), StrToInteger(message[8])));
	        break;
	     case 8:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], StrToInteger(message[8]), StrToInteger(message[9])));
	        break;
	     case 9:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], StrToInteger(message[9]), StrToInteger(message[10])));
	        break;
	     case 10:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], message[9], StrToInteger(message[10]), StrToInteger(message[11])));
	        break;
	     case 11:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], message[9], message[10],StrToInteger(message[11]), StrToInteger(message[12])));
	        break;
	     case 12:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], message[9], message[10],message[11], StrToInteger(message[12]), StrToInteger(message[13])));
	        break;
	     case 13:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], message[9],message[10], message[11], message[12], StrToInteger(message[13]), StrToInteger(message[14])));
	        break;
	     case 14:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], message[9],message[10], message[11], message[12], message[13], StrToInteger(message[14]), StrToInteger(message[15])));
	        break;
	     case 15:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], message[9],message[10], message[11], message[12], message[13], message[14], StrToInteger(message[15]), StrToInteger(message[16])));
	        break;
	     case 16:
	        return(iCustom(message[2], StrToInteger(message[3]), message[4], message[6], message[7], message[8], message[9],message[10], message[11], message[12], message[13],message[14], message[15], StrToInteger(message[16]), StrToInteger(message[17])));
	        break;
	  }
	}
	if(message[1] == "iClose"){
	return(iClose(message[2], StrToInteger(message[3]), StrToInteger(message[4])));
	}
	if(message[1] == "iHigh")
	return(iHigh(message[2], StrToInteger(message[3]), StrToInteger(message[4])));
	
	if(message[1] == "iLow")
	return(iLow(message[2], StrToInteger(message[3]), StrToInteger(message[4])));

 

3. that's all, you can test on your ea now.
Jan 11, 2013 at 3:03 PM
Edited Jan 11, 2013 at 3:03 PM

Hi, I made changes you described. But still get "###NORESULT###". May be I have to do something else?

Jan 15, 2013 at 10:22 AM

Solved.

Open [Terminal path]\experts\Expert_NET.mq4 in MQL Editor and compile it. Then added code start to work.