fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Send screenshot to Telegram

    Questions & Answers
    4
    8
    7617
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • vish
      vish last edited by

      I wonder if we can send a screenshot to Telegram with the library provided here using fxdreema: https://www.mql5.com/en/articles/2355
      Some discussion on this library: https://www.mql5.com/en/forum/89826/page4

      I guess we can create a custom block that links to Telegram.mqh (As I learned when we include a file then we can download mql file only)

      1 Reply Last reply Reply Quote 0
      • Spuzy
        Spuzy last edited by Spuzy

        For this to work, you must have all of the telegrams include files in the include folder

        Custom Function:

        int SendScreenShot(const long _chat_id,
        			const string _symbol,
        			const ENUM_TIMEFRAMES _period,
        				int x_axis,
        				int y_axis,
        				bool current_chart,
        				string token)
        {
        CCustomBot bot;
        bot.Token(token);
        
        int result=0;
        long chart_id;
        if(!current_chart)
        chart_id=ChartOpen(_symbol,_period);
        else
        chart_id=ChartID();
        
        if(chart_id==0)
        return(ERR_CHART_NOT_FOUND);
        
        if(!current_chart)
        ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true);
        
        //--- updates chart
        int wait=60;
        while(--wait>0)
        {
        if(SeriesInfoInteger(_symbol,_period,SERIES_SYNCHRONIZED))
        	break;
        Sleep(500);
        }
        string filename;
        if(!current_chart)
        {
        ChartRedraw(chart_id);
        Sleep(500);
        ChartSetInteger(chart_id,CHART_SHOW_GRID,false);
        ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false);
        filename=StringFormat("%s%d.gif",_symbol,_period);
        }
        else
        {
        	filename=StringFormat("%s%d.gif",Symbol(),Period());
        }
        
        if(FileIsExist(filename))
        FileDelete(filename);
        
        if(!current_chart)
        ChartRedraw(chart_id);
        
        Sleep(100);
        
        if(ChartScreenShot(chart_id,filename,x_axis,y_axis,ALIGN_RIGHT))
        {
        Sleep(100);
        
        bot.SendChatAction(_chat_id,ACTION_UPLOAD_PHOTO);
        
        //--- waitng 30 sec for save screenshot
        wait=60;
        while(!FileIsExist(filename) && --wait>0)
        	Sleep(500);
        
        //---
        if(FileIsExist(filename))
        	{
        	string screen_id;
        	result=bot.SendPhoto(screen_id,_chat_id,filename,_symbol+"_"+StringSubstr(EnumToString(_period),7));
        	}
        
        }
        
        if(!current_chart)
        ChartClose(chart_id);
        
        return(result);
        }
        

        Block Code:

        if(current_chart)
        {
        	_symbol = Symbol();
        	_period = Period();
        }
        SendScreenShot(_chat_id,_symbol, _period,x_axis,y_axis,current_chart,token);
        

        Block Include:

        #include <Telegram.mqh>
        

        use the following images to make your parameters

        this is color code for telegram blue if you wanna get extra fancy ๐Ÿ˜„
        #0088CC

        https://imgur.com/a/11Fawvv

        if current chart is chosen then it will take a screenshot of the current chart together with all objects/indicators on the chart and your coloring of bars/background and such

        if you choose a symbol and timeframe it will open a new default looking chart for that symbol,timeframe and take a screenshot and close it afterwards.

        changing width changes how much of it is screenshotted

        to anyone knowledgable in coding don't laugh at how sloppy it is. it works ok.

        vish 1 Reply Last reply Reply Quote 1
        • vish
          vish @Spuzy last edited by

          @spuzy

          I am getting these errors (MT4): http://prntscr.com/nn7g66
          http://prntscr.com/nn7gf8

          Can you please help?

          1 Reply Last reply Reply Quote 0
          • vish
            vish last edited by vish

            Here is how to achieve this as @spuzy showed me (fully credit to @spuzy).

            First download telegram.zip file given at the bottom of this page: https://www.mql5.com/en/articles/2355

            Then place the .mqh files within the zipped folder into Include folder of your MT4 data folder.

            Then you need to make a custom block of code as follows:
            0_1557662570941_Screenshot_1.png

            This is the code of the big white area:

            if(current_chart)
            {
            _symbol = Symbol();
            _period = Period();
            }

            if(is_channel) { SendScreenShotChannel(channel_name,_symbol, _period,text,x_axis,y_axis,current_chart,token); }
            else { SendScreenShot(_chat_id,_symbol, _period,text,x_axis,y_axis,current_chart,token); }

            And include following line in the global variable area:
            #include <Telegram.mqh>

            Here are the two custom functions codes:
            1.SendScreenshot:

            int SendScreenShot(const long _chat_id,
            const string _symbol,
            const ENUM_TIMEFRAMES _period,
            string text,
            int x_axis,
            int y_axis,
            bool current_chart,
            string token)
            {
            CCustomBot bot;
            bot.Token(token);

            int result=0;
            long chart_id;
            if(!current_chart)
            chart_id=ChartOpen(_symbol,_period);
            else
            chart_id=ChartID();

            if(chart_id==0)
            return(ERR_CHART_NOT_FOUND);

            if(!current_chart)
            ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true);
            

            //--- updates chart
            int wait=60;
            while(--wait>0)
            {
            if(SeriesInfoInteger(_symbol,_period,SERIES_SYNCHRONIZED))
            break;
            Sleep(500);
            }
            string filename;
            if(!current_chart)
            {
            ChartRedraw(chart_id);
            Sleep(500);
            ChartSetInteger(chart_id,CHART_SHOW_GRID,false);
            ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false);
            filename=StringFormat("%s%d.gif",_symbol,_period);
            }
            else
            {
            filename=StringFormat("%s%d.gif",Symbol(),Period());
            }

            if(FileIsExist(filename))
            FileDelete(filename);

            if(!current_chart)
            ChartRedraw(chart_id);
            

            Sleep(100);

            if(ChartScreenShot(chart_id,filename,x_axis,y_axis,ALIGN_RIGHT))
            {
            Sleep(100);

              bot.SendChatAction(_chat_id,ACTION_UPLOAD_PHOTO);
            
              //--- waitng 30 sec for save screenshot
              wait=60;
              while(!FileIsExist(filename) && --wait>0)
                 Sleep(500);
            
              //---
              if(FileIsExist(filename))
                {
                 string screen_id;
                 result=bot.SendPhoto(screen_id,_chat_id,filename,text);
                }
            
             }
            
            if(!current_chart)
            ChartClose(chart_id);
            

            return(result);
            }

            1. SendScreenShotChannel

            int SendScreenShotChannel(const string _chat_id,
            const string _symbol,
            const ENUM_TIMEFRAMES _period,
            string text,
            int x_axis,
            int y_axis,
            bool current_chart,
            string token)
            {
            CCustomBot bot;
            bot.Token(token);

            int result=0;
            long chart_id;
            if(!current_chart)
            chart_id=ChartOpen(_symbol,_period);
            else
            chart_id=ChartID();

            if(chart_id==0)
            return(ERR_CHART_NOT_FOUND);

            if(!current_chart)
            ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true);
            

            //--- updates chart
            int wait=60;
            while(--wait>0)
            {
            if(SeriesInfoInteger(_symbol,_period,SERIES_SYNCHRONIZED))
            break;
            Sleep(500);
            }
            string filename;
            if(!current_chart)
            {
            ChartRedraw(chart_id);
            Sleep(500);
            ChartSetInteger(chart_id,CHART_SHOW_GRID,false);
            ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false);
            filename=StringFormat("%s%d.gif",_symbol,_period);
            }
            else
            {
            filename=StringFormat("%s%d.gif",Symbol(),Period());
            }
            ChartSetInteger(chart_id,CHART_SHOW_GRID,true);
            ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false);

            if(FileIsExist(filename))
            FileDelete(filename);

            if(!current_chart)
            ChartRedraw(chart_id);
            

            Sleep(100);

            if(ChartScreenShot(chart_id,filename,x_axis,y_axis,ALIGN_RIGHT))
            {
            Sleep(100);

              bot.SendChatAction(_chat_id,ACTION_UPLOAD_PHOTO);
            
              //--- waitng 30 sec for save screenshot
              wait=60;
              while(!FileIsExist(filename) && --wait>0)
                 Sleep(500);
            
              //---
              if(FileIsExist(filename))
                {
                 string screen_id;
                 result=bot.SendPhoto(screen_id,_chat_id,filename,text);
                }
            
             }
            
            if(!current_chart)
            ChartClose(chart_id);
            

            return(result);
            }

            And given below are each of the parameters:

            0_1557662967569_Screenshot_2.png

            0_1557662973080_Screenshot_3.png

            0_1557662984114_Screenshot_4.png

            0_1557662991403_Screenshot_5.png

            0_1557663000056_Screenshot_6.png

            0_1557663007349_Screenshot_7.png

            0_1557663013786_Screenshot_8.png

            0_1557663020301_Screenshot_9.png

            0_1557663035389_Screenshot_10.png

            0_1557663049216_Screenshot_11.png

            Then make the settings as follows:

            0_1557663103245_Screenshot_12.png

            Now you have got the custom block in fxdreema, which you can use in your EAs.
            0_1557663219892_Screenshot_13.png

            Here are the options which are self explanatory. You can post screenshots with custom text to Telegram channels and groups automatically.
            0_1557663336302_Screenshot_14.png

            Monaco 1 Reply Last reply Reply Quote 0
            • Monaco
              Monaco Banned @vish last edited by Monaco

              Impresive

              1 Reply Last reply Reply Quote 0
              • Spuzy
                Spuzy last edited by

                I've made a full easier tutorial on how to do this as some stuff was missing here. I've also modified the blocks a bit.
                check out this thread https://fxdreema.com/forum/topic/7483/custom-block-release-send-a-message-or-screenshot-to-telegram-blocks

                1 Reply Last reply Reply Quote 0
                • Monaco
                  Monaco Banned last edited by Monaco

                  Only i can tell IMPRESIVE ยก

                  1 Reply Last reply Reply Quote 0
                  • aman
                    aman last edited by

                    image.png

                    i write down this code, and i refresh the tab and the code disappears. so how to save this code?

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post

                    Online Users

                    S
                    K
                    A
                    K
                    M
                    R
                    D
                    S
                    B

                    15
                    Online

                    146.7k
                    Users

                    22.4k
                    Topics

                    122.6k
                    Posts

                    Powered by NodeBB Forums | Contributors