HELP NEEDED : New to MQL4 Coding >>> iCustom Error

To add comments, please log in or register

This is my first go around at coding. I hope I am not overlooking something obvious here. But, I have looked at this and rewrote it multiple times. I have searched existing forums and reference manual and can not seem to make sense of what I am getting this compiling error. 

Any advice would be appreciated.

double iCustom(

               string NULL,

               int 0, 

               string "mm4x_tdi", 

               int RSI_Period, int RSI_Price, int Volaltility_Band, int RSI_Price_Line, int RSI_Price_Type, int Trade_Signal_Line, int Trade_Signal_Type, int RSI_Price_Line_shift, int Volaltility_Band_shift,

               int 0, 

               int 0




//--- TDI input parameters 

         input int            RSI_Period =21;         // RSI

         input int            RSI_Price =0;           // RSI Price   

         input int            Volaltility_Band =34;   // Blue Bands

         input int            RSI_Price_Line =2;      // Green Line

         input int            RSI_Price_Type =0;      // Price Type

         input int            Trade_Signal_Line =7;   // Red Line

         input int            Trade_Signal_Type =0;   // Signal Type

         input int            RSI_Price_Line_shift =0; 

         input int            Volaltility_Band_shift =0;

Andres Sigala
Andres Sigala  
you have to use this format for iCustom


Andres Sigala:
you have to use this format for iCustom


tried that first, it returns more errors.

Ehsan Tarakemeh
Ehsan Tarakemeh  
This is a syntax error. You don't need to define the iCustom function like the first lines of your code. You've copied it from the manual. Just use it like this in a function:
double val=iCustom(NULL,0,"SampleInd",13,1,0);
You need to learn the basics of the C or C++ language programing. 
Ehsan Tarakemeh:

I appreciate your response, made changes and it fixed the errors.

You are right I have no experience in C or C++. I took an MQL4 class on Udemy that had about 6 hours of lectures plus training exercises. 

William Roeder
William Roeder  
  1. double val = iCustom(NULL,0,"mm4x_tdi",13,1,0);
    Global and static variables work exactly the same way in MT4/MT5/C/C++.
    1. They are initialized once on program load.
    2. They don't update unless you assign to them.
    3. In C/C++ you can only initialize them with constants, and they default to zero.
    4. In MTx you should only initialize them with constants. There is no default in MT5 or (MT4 with strict which you should always use.)

      MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:

      1. Terminal starts.
      2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
      3. OnInit is called.
      4. For indicators OnCalculate is called with any existing history.
      5. Human may have to enter password, connection to server begins.
      6. New history is received, OnCalculate called again.
      7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
    5. Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
                external static variable - Inflation - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. Get the value(s) of the indicator(s) into the EA (using iCustom) and do what you want with it.
    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. Please don't post image of code. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  4. Don't use NULL.
    • You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
    • Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    • Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    • MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].

To add comments, please log in or register