1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

Coding help : telegram EA notification

Discussion in 'Belajar MQL dari Nol' started by eddyG, 21 Jan 2018.

  1. eddyG

    eddyG New Member

    Equity
    Credit
    Ref Point
    Hi ,

    First , sorry for my english .

    I try to compiled this code to have otofication on telegram but i've got error and i don't find why .

    Code:
    //+------------------------------------------------------------------+
    //|                                        Telegram_Signal_EA_v1.mq4 |
    //|                        Copyright 2014, MetaQuotes Software Corp. |
    //|                                              https://www.mql5.com |
    //+------------------------------------------------------------------+
    #property copyright "Copyright 2014, MetaQuotes Software Corp."
    #property link      "https://www.mql5.com"
    #property version   "1.00"
    
    //+------------------------------------------------------------------+
    //|   Includes                                                       |
    //+------------------------------------------------------------------+
    #include <Telegram.mqh>
    
    //--- Input parameters
    input string InpChannelName="@Signaux Mt4";//Channel Name
    input string InpToken="529620876:AAHKz0xg-K9mxvLLIhrZ7dXJAQ_iURTMHuY";//Token
    
    //--- Global variables
    CCustomBot bot;
    int macd_handle;
    datetime time_signal=0;
    //+------------------------------------------------------------------+
    //| Expert initialization function                                   |
    //+------------------------------------------------------------------+
    int OnInit()
      {
       time_signal=0;
    
    //--- set token
       bot.Token(InpToken);
    
    //--- get an indicator handle
       macd_handle=iMACD(NULL,0,12,26,9,PRICE_CLOSE);
       if(macd_handle==INVALID_HANDLE)
          return(INIT_FAILED);
    
    //--- done
       return(INIT_SUCCEEDED);
      }
    //+------------------------------------------------------------------+
    //| Expert tick function                                             |
    //+------------------------------------------------------------------+
    void OnTick()
      {
    
    //--- get time
       datetime time[1];
       if(CopyTime(NULL,0,0,1,time)!=1)
          return;
    
    //--- check the signal on each bar
       if(time_signal!=time[0])
         {
          //--- first calc
          if(time_signal==0)
            {
             time_signal=time[0];
             return;
            }
    
          double macd[2]={0.0};
          double signal[2]={0.0};
    
          if(CopyBuffer(macd_handle,0,0,2,macd)!=2)
             return;
          if(CopyBuffer(macd_handle,1,0,2,signal)!=2)
             return;
    
          time_signal=time[0];
    
          //--- Send signal BUY
          if(macd[1]>signal[1] &&
             macd[0]<=signal[0])
            {
             string msg=StringFormat("Name: MACD Signal\nSymbol: %s\nTimeframe: %s\nType: Buy\nPrice: %s\nTime: %s",
                                     _Symbol,
                                     StringSubstr(EnumToString(_Period),7),
                                     DoubleToString(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits),
                                     TimeToString(time[0]));
             int res=bot.SendMessage(InpChannelName,msg);
             if(res!=0)
                Print("Error: ",GetErrorDescription(res));
            }
    
          //--- Send signal SELL
          if(macd[1]<signal[1] &&
             macd[0]>=signal[0])
            {
             string msg=StringFormat("Name: MACD Signal\nSymbol: %s\nTimeframe: %s\nType: Sell\nPrice: %s\nTime: %s",
                                     _Symbol,
                                     StringSubstr(EnumToString(_Period),7),
                                     DoubleToString(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits),
                                     TimeToString(time[0]));
             int res=bot.SendMessage(InpChannelName,msg);
             if(res!=0)
                Print("Error: ",GetErrorDescription(res));
            }
         }
      }
    //+------------------------------------------------------------------+
    Does anyone can help ?

    Thanks a lot .

    Best regards
     
  2. Joker Jack

    Joker Jack New Member

    Equity
    Credit
    Ref Point
    Hi
    I am not sure the exact problem but you can check the [HASHTAG]#include[/HASHTAG]<Telegram.mqh>.
     
  3. miguefx

    miguefx New Member

    Equity
    Credit
    Ref Point
    This is not error. But its for mql5 coding not mql4 coding. Load on mt5 to use this cidng
     
  4. MAS DIRAH

    MAS DIRAH Member Credit Hunter

    Equity
    Credit
    Ref Point
    • Like Like x 1
  5. ruri m kurniawan

    ruri m kurniawan New Member

    Equity
    Credit
    Ref Point
    5/5,
    This is my review for this thread:
    semoga cepet bisa segera mendapatkan jawaban
     
  6. dedy_iskandar

    dedy_iskandar New Member

    Equity
    Credit
    Ref Point
    hi, is that this issue already resolved?
     
  7. GGoutham

    GGoutham Member Credit Hunter

    Equity
    Credit
    Ref Point
    Hello can anybody help ? I have mql code for RMI indicator. I know little programming planning to build my own EA , I don't how to get the RMI indicator values in a variable, in RSI we use to store the values as "double RSIvalue = iRSI(...);"
    How to do it for RMI...?
     

Share This Page