iCustom problem with multiple instances

 

Hello,

I'm newbie on the coding expert advisor and try to do some thoughts.

I have a problem at the start of my first project. I want to use the data of an indicator that have been coded before and just prepare statements for orders. However I can't get and data and could't find and solution.

I'm sharing the code.

enum ENUM_TRADE_SIGNAL{
   SIGNAL_BUY=1,     //BUY
   SIGNAL_SELL=-1,   //SELL
   SIGNAL_NEUTRAL=0  //NEUTRAL
};

enum ENUM_CANDLE_TO_CHECK{
   CURRENT_CANDLE=0,    //CURRENT CANDLE
   CLOSED_CANDLE=1      //PREVIOUS CANDLE
};

enum ENUM_ALERT_SIGNAL{
   MACD_MAIN_SWITCH_SIDE=0,   //MACD MAIN SWITCH SIDE
   MACD_MAIN_SIGNAL_CROSS=1   //MACD MAIN AND SIGNAL CROSS
};

input string Comment1="========================";     
const string IndicatorName="indicator";    

input string Comment2="========================";     //Indicator Parameters
input int MAPeriod=10;                                //Triangular Moving Average Period
int MAShift=0;                                  //Moving Average Shift
input ENUM_MA_METHOD MAMethod=MODE_SMA;               //Moving Average Method
input ENUM_APPLIED_PRICE MAAppliedPrice=PRICE_CLOSE;  //Moving Average Applied Price
input ENUM_ALERT_SIGNAL AlertSignal=MACD_MAIN_SWITCH_SIDE;       //Alert Signal When
input ENUM_CANDLE_TO_CHECK CandleToCheck=CURRENT_CANDLE;    //Candle To Use For Analysis
input int BarsToScan=500;                                   //Number Of Candles To Analyse

input string Comment_3="====================";     //Notification Options
extern bool EnableNotify=True;                    //Enable Notifications Feature
extern bool SendAlert=False;                        //Send Alert Notification
extern bool SendApp=True;                          //Send Notification to Mobile
extern bool SendEmail=False;                        //Send Notification via Email
input int WaitTimeNotify=5;                        //Wait time between notifications (Minutes)

input string Comment_4="====================";     //Drawing Options
input bool EnableDrawArrows=true;                  //Draw Signal Arrows
input int ArrowBuy=241;                            //Buy Arrow Code
input int ArrowSell=242;                           //Sell Arrow Code
input int ArrowSize=3;                             //Arrow Size (1-5)


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  
  double value = iCustom(Symbol(),Period(),
                        Comment1,
                        IndicatorName,
                        Comment2,
                        MAPeriod,
                        MAShift,
                        MAMethod,
                        MAAppliedPrice,
                        AlertSignal,
                        CandleToCheck,
                        BarsToScan,
                        Comment_3,
                        EnableNotify,
                        SendAlert,
                        SendApp,
                        SendEmail,
                        WaitTimeNotify,
                        Comment_4,
                        EnableDrawArrows,
                        ArrowBuy,
                        ArrowSell,
                        ArrowSize,
                        0,
                        1)
     
   return(INIT_SUCCEEDED);
   
  }
 
const string IndicatorName="indicator";   

Is the indicator called "indicator"

Don't get indicator values in OnInit, get them in OnTick.

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
Keith Watford:

Is the indicator called "indicator"

Don't get indicator values in OnInit, get them in OnTick.

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

Sorry about the mistake.

I first wrote it in OnTick but I read somewhere that tells try it on Oninit. indicator name is indicator, I renamed it. 

When I try to print or comment it, I can't even compile the file.

 
Your code
Documentation
double value = iCustom(
           Symbol(),
           Period(),
           Comment1,
           IndicatorName,
           Comment2,
           ⋮
double  iCustom(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
                                  
   string       name,             // path/name of the custom indicator compiled program
   ...                            // custom indicator input parameters (if necessary)

I doubt the name of your indicator is "========================"

 
William Roeder:
Your code
Documentation

I doubt the name of your indicator is "========================"

Thank you for you reply, I've solved my problem but new one came up :/ I'm working on the indicator which name is TMASLOPE, and it has 3 ways like 1(buy)-0(neutral)-(-1)(sell) but when i use iCustom, I get double value as 2147483647 and I couldn't understand why. I tried normalizedouble and doubletostring but result is the same.
Reason: