Is it possible to create a new symbol in MT4
For example, I want to create JPY index by some formula. I dont want it to be displayed in subwindow, but in the main chart window. Is this possible?
Call this function on every tick with the current value of the index. If you want to create multiple timeframes then just call it once per timeframe (with a different period parameter for each timeframe).
symbol is the name for your offline chart. It can be up to 12 characters long, this is a limitation of the file format.
period accepts the period in minutes (just use metatrader's PERIOD_* constants for it)
digits is the number of digits and volume can be set to 0 if you dont have volume.
if you enable "allow dll" for your code then it will also update the offline chart window on every tick via the PostMessage() trick.
I see it is old thread , but I hope to get an answer.
I downloaded you library , and write very small EA to call updateOfflineChart() with the necessary 5 parameters.
I was sure that the call is completed with the correct parameters, but nothing happened , offline chart is not opened automatically.
I manually open an offline chat and tried to make a call for the already opened offline chart , also nothing happened.
can you give detailed step how to do that ? or what mistake may be i was doing ?
thanx in advance
The library provided by 7bit doesn't really do what the thread opener asked for, i.e. it doesn't create new MT4 symbols. It can create custom price histories, in this case a history of your equity curve. The resulting artefact is the price history of a single timeframe which then can be opened as an offline chart. This price history (and the chart) will have a symbol, but that's not a regular MT4 symbol.
There are ways to create real custom symbols in MT4 (what the thread opener asked for) but my gut tells me that's not what you want. So, give more information please.
Thank you emmzett for your reply.
I am trying to create a custom symbol for the dollar index like the one in liteforex platform or the custom symbol that can be created in mt5.
it seems the same request as of the thread opener.
after reading the 7bit reply and reading details how to call updateOfflineChart(), I expected to have offline chart , that can be updated by a call with dollar index value and the offline chart will be updated accordingly , as update will by using EA on every tick.
please tell if my understanding to 7bit reply is correct or give another way how to create custom symbl in mt4, or any other helpful information about this topic.
Thanks and regards,
A better and less complex approach would be to create one real custom symbol with one real chart (not offline) capable of switching timeframes (which is not possible with offline charts). Something like this recorded by this
Both images are copied from here: https://github.com/rosasurfer/mt4-expander/issues/2 (the issue is only slightly related).
Formulas for the indexes can be found here: https://github.com/rosasurfer/mt4-to.../lib/synthetic
For an updatable custom MT4 symbol you need to follow these steps:
If all this doesn't sound to complicated I would go in more detail (you will need some programming knowledge in MQL). The result would be two running terminals, one recording (the second screenshot), the other charting (the first screenshot). Be aware that you will never be able to trade a custom symbol from such a chart, neither in MT4 nor in MT5.
I really appreciate every letter you typed on your keyboard to help me.
I don't see things complicated. also I have very good to excellent knowledge in MQL Programming , more than 100 EAs were written by me ( all lose money ) hahaha
but I can write code.
If you don't mind , I will follow your instruction one by one until I finish this job , in case I face some problems , I'll come back and ask for details. just please follow up with me.
but as strart I have one question.
when I open new chat , chart automatically take default symbol from the platform , how can I use other symbol not available in the platform like ( usdidx ) for example ?
sure I prefere this option
"A better and less complex approach would be to create one real custom symbol with one real chart (not offline) capable of switching timeframes (which is not possible with offline charts). Something like this "
give me please the start point
OK, I'm going to start a new thread for it to have a main post which I'm allowed to update constantly.
OK , please send the link after opening the new thread
To the main question: How to create a custom symbol in MT4?
All known terminal symbols are stored in
Teaser: Here is a terminal's "Symbols" dialog with only custom groups and symbols.
Once the terminal is disconnected we can edit/update the above as we wish. The format of "symbols.raw" is documented here: Symbol.h, the format of the group file is documented here: SymbolGroup.h. There are two ways to edit/modify the files, programatically or manually. I will explain both, and the way to go depends on how often one wants to create a new symbol.
The manual way:
If you want to create just a symbol for a synthetic index (a one-time task) it's overkill to implement an automated solution. Manual creation takes just a few minutes. You need a hex editor and the above format description. I recommend WinHex because it understands scriptable form templates.
A template for a basic symbol editor is here: Symbol Form
A template for a simple group editor is here: Symbol Group Form
You can edit and create your own groups and symbols as long as you stick to the format and know what you do. If I manually edit symbols I first split "symbols.raw" in single raw files per symbol, then I edit the single symbols, finally I copy the pieces together to the final file. Splitting/merging is done on the command line with standard shell tools. Today we use Git everywhere, so every developer is familiar with Bash. Even Microsoft gave in and ships Windows TeT (Windows for Teletubbies) with a Linux shell.
Of course you can remove whatever symbol you want and create a final file - let's say - with just one or two symbols. To simplify the process further I have templates for the most common symbol types (Forex, indexes) here: Raw Example Symbols. With those raw symbol templates I just need to change the actual symbol and the symbol description. There are some rules to follow with sorting and ids and I will extend on that if there is interest.
The automated way:
In all my EAs I have an input parameter to enable recording of the tester's equity curve (the chart generated by the tester is as useless as it can get). For this feature I use the automated way to create custom groups and symbols, directly as part of the test. Looks like that:
For this I have a MQL library which is capable of managing custom symbols, custom symbol groups, single history files and complete history sets. The library header is here: include/rsfHistory.mqh, the implementation here: libraries/rsfHistory.mq4. Finally CreateSymbol() is used here: include/core/expert.mqh (line 609).
I guess that's plenty of material to digest for the moment. Only oddity for many will be that it's written in MQL version 4 (up to build 509) but that's the language I prefer. It's easy to convert.
So far for custom symbol creation. Recording history of a custom symbol may be the topic of another day (and you already know most of it), turning it into a seemless self-updating "online" chart is material for another one.
interesting , I just read the details , I like the way you implement this solution. but I didn't give it a try .
I will give it a try , as it need some time , and will give you my feedback.
big thanks to you , appreciate your help.
For the 2nd part "...if the broker is willing". "Willing" in this context means the broker has to officially offer the symbol to all customers, something which most probably will not happen. If your real question is whether custom created symbols and broker offered symbols can coexist in MT4 then it's a "no". It's for that reason that a disconnected terminal is required.
Is this a show stopper? No. Once you did it a few times you realize that the advantages outweigth the disadvantages. A real custom symbol you will create only rarely, a few indexes maybe. But the real advantage is in testing where it opens countless ways to create and analyze test results. You can literrally chart everything you want: real equity curves, drawdown, regression analysis for preventing curve fitting during optimization etc. Options are limitless.
ps: Internally MetaTrader uses a FIX dialect when communicating with the trade server. After a successful connection the first thing it does is requesting the list of currently supported symbols. After receiving that list the terminal stores the received symbols in "symbols.raw", always overwriting the former state. The "MarketWatch" window is merely a list of symbols you are - in FIX terms - subscribed to. Again that list is stored on terminal shutdown in "symbols.sel", format here: SymbolsSelected.h
Looking forward to your reply.
ps: I don't yet know..."C5 from the basket trading thread" :-)
If the broker is willing to offer such a basket symbol he needs to setup the price feed for it. Means he has to calculate the basket and publish prices. If the basket is not constantly rebalanced it would be a static formula and the broker shouldn't have problems. If the broker offers such a symbol nothing needs to be done on the client-side in regard to "custom symbols". If the basket needs constant rebalancing the broker will most probably reject from the idea.
If you want to setup your own price feed for C5 (without broker support) you have to calculate the basket by yourself, and feed your custom symbol by yourself. That would be the use case of the second screenshot in this link where I calculate and update custom indexes on the fly. I didn't yet go deeper into the "custom price feed" details as there was not yet interest for it in this thread.
© Forex Factory