fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Spuzy
    3. Best
    • Profile
    • Following 0
    • Followers 10
    • Topics 5
    • Posts 81
    • Best 12
    • Controversial 0
    • Groups 0

    Best posts made by Spuzy

    • [Custom Block Release] Send a message or screenshot to Telegram Blocks

      Hello, I've made custom blocks to send a telegram message and or screenshot some time ago, but there had to be some modifications to the original files and such so I'll release a version that works with fxdreema and the code for the custom functions and blocks.

      https://www.mql5.com/en/articles/2355
      This are the includes we will be using, credits to for the code and possibility of using telegram api within metatrader go to ANDREY VOYTENKO from mql5 forums.

      go there and download telegram.zip at the bottom of the post.
      extract the include folder into your MQL4/5 folder and overwrite any files if asked to do so.
      0_1562983072106_cc4cdf9c-770d-4fb1-9f52-f7196828bcaf-image.png
      your numbers folder will be different depending on the broker you use, make sure you put it in the right folder or you can do it for every numbers folder so all your meta trader clients have the code necessary.

      the current jason.mqh has compatibility issues with fxdreema because fxdreema declares variables c and v on a global status which jason.mqh also uses hence errors. I have modified the jason.mqh to work with fxdreema and you can get the code here https://pastebin.com/525haAXi
      go at the bottom of the link and you will see a box with text inside, this is the raw text, click inside press ctrl+a to select all text inside and then copy that and paste it over jason.mqh which you can open with your metaeditor which is included with all metatraders(I think). and press compile to save it.
      (you must use this new edited file in every numbers folder otherwise you will get errors, I recommend first editing the file then placing it in every numbers folder if you have more than one)

      on fxdreema builder click on custom and then create custom blocks
      0_1562983398643_3b34b148-9c0d-4c5c-bc2d-ea6099840d0a-image.png

      in this editor you will need to create 2 blocks 0_1562983433154_9a8e4d7b-a11a-41f5-91aa-1a5f54079b52-image.png

      in the send screenshot block paste the code from this link https://pastebin.com/aegjAZyqand at the bottom under "Global variables,includes" paste this code
      #include <Telegram.mqh>

      so it looks like this 0_1562983589002_0e8f17ab-657c-4694-9165-96cc47920e66-image.png

      now you will need to make custom parameters that will be used within the block
      follow these screenshots exactly how I have made it https://imgur.com/a/2dtgq1S
      There are 2 notes. after you make all parameters open up is_channel parameters and click on the arrow next to the 2 options we made. under the "true" option choose channel_id and under the "false" option choose chat_id like shown in the screenshots.
      this is also true for current_chart parameter but choose _symbol and _period.
      if you follow it exactly like shown in the screenshots you will have no problems. so please make sure you follow it exactly.

      now in send message block put this code https://pastebin.com/ykGmW16r
      and again put #include <Telegram.mqh> under the global variables,includes box

      screenshots for parameters are here https://imgur.com/a/bKjHvRl

      now click on the New button in the bottom right corner under Custom Functions 0_1562983985066_30b0c577-4913-4d87-8141-1b31787f73ed-image.png
      delete the default code inside and paste this code and click save
      https://pastebin.com/y0zL8hSA

      if you want to make the block telegram blue color so they look nice click on settings and use #0088CC for color
      0_1562984072485_e1adab59-7bb9-4d4b-8f75-4e2842a47755-image.png
      0_1563242291691_f1e2adf1-a63b-4018-9bd9-c6bd48978c69-image.png

      now you will need to allow your metatrader client to access https://api.telegram.org
      go to tools-options 0_1562984144203_523c167f-143a-45ac-b4be-12190a7737ca-image.png

      go to Expert Advisors tab, enable "Allow WebRequests for listed URL:" option and paste the url above into the box
      0_1562984202058_b8248b40-ddd2-43de-b4d9-76e636a0169d-image.png

      Since we are using includes that are not hosted on fxdreema servers you must always download .mql4/5 file, not .ex file
      you must open it up in metaeditor and compile it yourself.

      Now to setup the actual bot and how to get Chat ID.
      On telegram search for BotFather and open up a chat with him
      0_1563109263266_c5e805d5-3654-4765-9ce1-acbc0259f584-image.png
      click start and type in /newbot and follow the instructions, once you are done you will get your bot's token
      0_1563109436752_61b484c2-0db6-4d39-8eca-773732097640-image.png
      copy and paste that token into the "token" part of the blocks.
      you can make a string variable with your token and use the variable in the blocks so you don't need to copy it always.
      Make sure to share the token with no one.

      if you want to send to a channel you need to make a public one and then copy it's adress into the channel name box
      0_1563110433900_162886c0-77be-4d03-8306-7ae7cbf35925-image.png

      if you want to send to a group make a new group and to it add IDBot and your bot
      0_1563110609913_6781b76f-a2d0-4783-9a64-54926fe7722a-image.png
      type /getgroupid to get your group's ID and then kick out IDBot and you can Pin his message so you have easy access to the ID if you'll need it again/often. Be sure to kick out IDBot.
      now take your ID and put it in the ID Box
      0_1563110798914_26be9a91-5944-464e-8d98-e4f3e67d4b73-image.png

      Channel name is a string value while Chat ID is int. so if you will be making variables for them for easier use in fxdreema make sure you give them the right type, string or int.

      That should be it, if there are any problems be sure to notify me as I haven't done a lot of testing.
      if my tutorial is missing something or is unclear please notify me I will edit it up to make this available to everyone.

      Edit 1. Added "_callback(1);" at the end of the blocks code so you can connect other blocks after the telegram blocks.
      unfortunately fxdreema custom blocks currently can't have 2 outputs (one yellow for if the block received error and didn't send a message) so any blocks connected after it will be activated even if the telegram block received some kind of error and didn't send the message.

      Edit 2. To send to a private channel follow these steps

      1. Login under your account at web version of Telegram : https://web.telegram.org
      2. Find your channel. See to your url, it should be like https://web.telegram.org/#/im?p=c1055587116_11052224402541910257
      3. Grab "1055587116" from it, and add "-100" as a prefix.*
        so your Chat ID would be -1001055587116

      don't use option send to channel but use Group and make it into an int variable, just like with groups

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • RE: [Custom Block Release] Send a message or screenshot to Telegram Blocks

      @ezzyxo updated the post 😄 check at the bottom

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • onTester()

      is it possible to add this to options of the project?

      for instance I always manually add

      double OnTester()
      {
      return(TesterStatistics(STAT_PROFIT)/TesterStatistics(STAT_EQUITY_DD));
      }

      is there already an option for this?

      if not is it possible to add it? let us write our own code that goes into return()?

      sorry if I posted in the wrong section didn't see a request section 😄

      love your work btw ❤

      posted in Questions & Answers
      Spuzy
      Spuzy
    • RE: [Custom Block Release] Send a message or screenshot to Telegram Blocks

      @realjoker I forgot to write a tutorial for setting up the actual bot, I will update my post now

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • RE: onTester()

      make it a choosable option in "Project Options" box and add a box in which we can type the code in and then place that text within return(); inside OnTester()

      and put OnTester anywhere inside the mq file, for instance just bellow OnInit()

      once you optimize a strategy you will have an additional thingy in Optimization Results which will be the value ontester returns. so if I get 8k different results and I can see it's profit, total trades, profit factor and such in the optimization results tab I will also be able to see number of profitable trades

      0_1549380636520_d032210f-eafa-4549-856a-54477397da40-image.png

      doesn't have to be a block and actually not sure if it can be a block. hope I explained it right

      posted in Questions & Answers
      Spuzy
      Spuzy
    • RE: [Custom Block Release] Send a message or screenshot to Telegram Blocks

      I see that the pastebin for tele screenshot was deleted for some reason, if you re-wrote it you must of forgot the comma there, make sure that all the parameters are exactly as on screenshot. and make sure you allow https://api.telegram.org for WebRequests in your meta trader. check the expert tab in meta trader once you try to send a screenshot for text that Printed, that should give you some info on the error, if this doesn't fix it screenshot the error message and post it here.

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • RE: Send email when trade is closed

      glad it helped somehow 😄
      this is what I meant tho
      0_1557490512159_22d5235f-8815-4e2d-b3a2-3ad9735a5866-image.png

      this way might be more efficient as that block won't be firing on every tick but only on a trade event.

      posted in Questions & Answers
      Spuzy
      Spuzy
    • RE: [Custom Block Release] Send a message or screenshot to Telegram Blocks

      0_1569506164668_7def6979-4120-484d-96ac-695291a0e101-image.png

      just format your message in the custom mql block however you want.
      DoubleToString will convert a double value into a string. the number 2 and the _Digits is how many decimal points you want.
      for instance _Digits will return a number of how many decimals there is in the current symbol, EURUSD has 5 for instance. so _Digits will return the number 5. so for open price you want the whole price to show, but not more. for lots since 0.01 is usually the minimum you don't need more than 2 decimals.

      if you're gonna use pips for sl and tp you are fine with 1. but if you're using price level then use _Digits so the whole price is displayed.

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • RE: Send screenshot to Telegram

      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.

      posted in Questions & Answers
      Spuzy
      Spuzy
    • RE: [Custom Block Release] Send a message or screenshot to Telegram Blocks

      the second messge doesn't seem to be formated correctly either, I don't know, you must have it connected badly. the blocks only sends 1 message based on the inputs and that's it

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • RE: [Custom Block Release] Send a message or screenshot to Telegram Blocks

      ah yes, you're right, this is my bad, I've out both functions inside one custom function, so if send screenshot function isn't called the telegram message one also won't be

      I will edit my main post to fix this.

      go to the low right corner and click to edit the telegramsendscreenshot function, scroll down to find the sendmessage function, cut it out and paste the code in a new function

      0_1570284621156_54606b06-8967-4be7-a7fe-461892fda2fb-image.png

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • RE: [Custom Block Release] Send a message or screenshot to Telegram Blocks

      check the experts tab for error, also try adding the block to oninit connected with a pass block, so when you add the EA to the chart it will immediately send a message, if that works that means your on trade block is wrong, if not then read the experts tab for errors and post them here

      posted in Tutorials by Users
      Spuzy
      Spuzy
    • 1 / 1