NexusFi: Find Your Edge


Home Menu

 





MT4 SuperBars - Overlay bars with ETH/RTH session support


Discussion in Platforms and Indicators

Updated
    1. trending_up 3,681 views
    2. thumb_up 7 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 13 attachments




 
Search this Thread

MT4 SuperBars - Overlay bars with ETH/RTH session support

  #1 (permalink)
 rosasurfer 
Sofia Bulgaria
 
Experience: Intermediate
Platform: MetaTrader, MultiCharts
Trading: Forex, ES, GC, strange synthetic creatures
Posts: 40 since Nov 2014
Thanks Given: 41
Thanks Received: 34

Greetings programs

In the thread "MetaTrader 5 now available for trading futures"
a question came up about timezone support in MT5 (of course there is none) and I mentioned that in MT4 timezone support can be implemented manually. I posted a few screenshots and got requests whether or not I would be willing to share the code. I agreed and here we are now.

Some background: The code is an extract of my general MT4 framework which is published here: https://github.com/rosasurfer/
All projects starting with mt4 are part of the framework and belong together. As you can see I don't use a standard setup which makes sharing code not exactly easy. :-)

So, what is this indicator about? It overlays a regular chart with bars of higher timeframes. Those super-timeframes reach from 1 hour to 1 quarter (3 months). One can easily display daily, weekly, monthly ranges and support lines without switching the actual chart. The daily super-timeframe can be split in ETH and RTH session. Essentially you have a way to look into a big bar and see the inside bar movement.
The indicator is controled by hotkeys to easily switch between super-timeframes and to see highs, lows, support etc.

Look at the screenshot:


SP500 monthly


The crux of the indicator is it's built-in timezone support which includes accurate DST transitions (not only a timezone offset) and it's flexible configuration. Timezones can be configured per trade server and ETH/RTH support can be configured per symbol without having to adjust indicator settings all the time.
The configuration is multi-layered (one config for all installed terminals, one for a single terminal, one for a single broker account). For the purpose of this thread we will focus just on one level, that's the global config.

Attached is a ZIP archive with sources and a ready-made compiled version (you will not be able to compile the sources straight away as it needs the full framework).
  • Extract the archive to a directory of your choice.
  • Open your terminal and click "Main Menu" -> "Open Data Folder" to open your setup's data folder.


  • Copy the one file from "<zip-archive>\bin\mql4\indicators" to "<mt4-data-folder>\mql4\indicators".


  • Copy the three files from "<zip-archive>\bin\mql4\libraries" to "<mt4-data-folder>\mql4\libraries".
  • Copy the three files from "<zip-archive>\bin\mql4\scripts" to "<mt4-data-folder>\mql4\scripts".
  • Create a directory "sounds" in your terminal's data folder: "<mt4-data-folder>\sounds". If your terminal runs in "portable" mode the data folder matches the terminal installation folder and the directory "sounds" already exists.
  • Copy the one file from "<zip-archive>\bin\sounds" to "<mt4-data-folder>\sounds".


[LIST]Restart your terminal.[[LIST]LIST]
  • Click "Main Menu" -> "View" -> "Navigator" to open the navigator window.
  • Select the "Common" tab and right-click on "Indicators -> Refresh" and on "Scripts -> Refresh".


  • In the "Navigator" window open the "Scripts" folder tree.
  • Locate the three scripts you just copied, that's "Config.Terminal", "SuperBars.TimeframeDown" and "SuperBars.TimeframeUp".
  • Right-click each one of them and hit "Add to Favorites" in the context menu.
  • Switch to the "Navigator"'s "Favorites" tab.


  • Drag the script "Config.Terminal" into any of your open charts.
  • If you get an error message about missing DLL support enable this feature exactly as the message explains, and repeat the last step.
  • The scripts loads your terminal configuration into any text editor installed on your system.
  • You will now have two open files: "global-config.ini" and "local-config.ini". We will only care about the "global-config.ini" and ignore the other one (you may close "local-config.ini").
  • The ZIP-Archive contains in the root folder an example configuration "global-config.example.ini". Copy and paste the full content of that example file into the empty "global-config.ini" opened by the "Config.Terminal" script. Save the file but leave it open for now.



As we are almost done, let's have a break and take a look around on what we'v got so far:
  • We installed the main indicator "SuperBars". If you load the input dialog of the indicator you can see that ETH symbols and colors can be configured directly or via config file in a central place. For now cancel the input dialog (don't yet load the indicator).


  • We installed two supporting scripts to control the indicator. We should assign hotkeys to these scripts so we may forget the scripts and only remember the keys to control the indicator. While one may use "Ctrl-U" and "Ctrl-D" I personally prefer two keys next to each other, even if they don't match the script names (I use "Ctrl-K" for upward and "Ctrl-L" for downward). Do as you like.
  • We installed a script to easily load the terminal configuration into a text editor. Again we should assign a hotkey, I use "Alt-C".
  • We installed a sound file. It will make a nice "plop" if the indicator tries to catch our attention. Nothing more. Serious.





Back to the heavy stuff. The new config file starts at the top with:


If you wish so remove the leading semicolon (it's a comment marker) and enter the full path to your preferred text editor. The next time the config script will automatically launch your favorite editor with the config files.

The last thing we have to configure is the timezone of your MT4 trade server (or servers if you have accounts with multiple brokers). I guess this is the point where the interactive part starts as I expect a lot of questions regarding the correct timezone identifier.



Read this section carefully. First, if you are unsure what to enter ask your broker for the server timezone. As mentioned a list with all possible timzone ids is here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones (atm only the most regular ones are supported by the framework).

Another very good resource for finding your broker timezone id is: https://www.timeanddate.com/

Most commonly your timezone will be one of "America/New_York", "GMT", "Europe/London", "Europe/Kiev" or "FXT". This few zones cover about 95% of all MetaTrader servers. Out of pure lazyness I only implemented a few (that's about 10) as I have more things to do then wasting my time with timezones as "America/Bahia_Banderas" or "Africa/Lubumbashi". I would never be "in" but only "out" of time. So please hit me with names and timezones of brokers I'v never heard of before carefully, and I might "find" time for every single one of them.

After your timezone is configured you can load the indicator as usual and start playing with the up/down scripts (or the hotkeys you assigned). If you got this far you will easily understand that you can configure bar and session colors directly in the indicator or again, in the config file. That way you can simply load the indicator with default settings on whatever server you are and don't need to adjust things all the time.


PS: If you think that your displayed superbars are wrong because of a mis-configured timezone id please post the name of your trade server and a link to your broker where I can open a demo account. Most probably your error message will be something like "Unsupported or invalid timezone id". Don't play with timezone offsets. They are not needed and at the moment only very few are supported. Let me check your server and I'll get back to you. The second post of this thread will keep track of confirmed ids.


PSS: I tested a lot but neither do I have the equipment nor the means to test on all possible platforms, especially the DLL part coded in C++. Under Windows 7 with a user account belonging to the admin group everything should work fine. I can't say anything about Windows 10 (recently I heard very ugly things...). So please be patient when you post errors. I'll try to fix them.


Have fun


History:
2018.09.29 - initial nexusfi.com version ( #8608797
2018.09.30 - (1) improved timezone handling ( #bdd9a06)
2018.09.30 - (2) support color name "None" for transparent bars, ignore case of configured ETH symbols ( #d16ba61)

Attached Files
Elite Membership required to download: SuperBars v2018.09.30-2.zip
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
Futures True Range Report
The Elite Circle
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
20 thanks
GFIs1 1 DAX trade per day journal
19 thanks
  #3 (permalink)
 rosasurfer 
Sofia Bulgaria
 
Experience: Intermediate
Platform: MetaTrader, MultiCharts
Trading: Forex, ES, GC, strange synthetic creatures
Posts: 40 since Nov 2014
Thanks Given: 41
Thanks Received: 34


What else did I forgot to mention?
  • The session split always occures at Chicago Open (and moves with Chicago DST transitions).
  • A gray bar means the bar range is neither bullish nor bearish but "nearly unchanged". Atm the value which defines "nearly" is hard-coded to 0.05% price change (@see SuperBars.mq4#L393). On request I can make it configurable per symbol.
  • The timezone id "FXT" is not a standard name and just short for "America/New_York+0700". Don't expect your broker to know that term.

Started this thread Reply With Quote
  #4 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018


MT4Survivor View Post
What else did I forgot to mention?
...

Thanks for sharing your work. I was wondering, do you know if we can draw the bars outside of the RTH session transparent? Also, still looking for an indicator that would plot the initial balance (1st hour of trading) with its extentions (50%, 100%, 200% above and below the intial balance.

Reply With Quote
Thanked by:
  #5 (permalink)
 rosasurfer 
Sofia Bulgaria
 
Experience: Intermediate
Platform: MetaTrader, MultiCharts
Trading: Forex, ES, GC, strange synthetic creatures
Posts: 40 since Nov 2014
Thanks Given: 41
Thanks Received: 34


trendisyourfriend View Post
Thanks for sharing your work. I was wondering, do you know if we can draw the bars outside of the RTH session transparent? Also, still looking for an indicator that would plot the initial balance (1st hour of trading) with its extentions (50%, 100%, 200% above and below the intial balance.

Drawing the ETH superbars transparent is not an issue. But I guess you also want to hide the regular bars in the ETH session, and display only the remaining 8 hours. Is that correct?

Unfortunately I don't have an indicator to draw a single hour from 08:30 to 09:30.

As for the range extentions I would look-up the first hour range by hand and simply use the existing Fibonacci tool. You have to configure the levels only once and draw the ranges with the tool. That's very quick and still exact. Like this for the gray superbar:


Started this thread Reply With Quote
Thanked by:
  #6 (permalink)
 rosasurfer 
Sofia Bulgaria
 
Experience: Intermediate
Platform: MetaTrader, MultiCharts
Trading: Forex, ES, GC, strange synthetic creatures
Posts: 40 since Nov 2014
Thanks Given: 41
Thanks Received: 34


trendisyourfriend View Post
...do you know if we can draw the bars outside of the RTH session transparent...

I uploaded a new version to the first post with support for transparent colors. Also case of the configured symbols is ignored now.

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018


MT4Survivor View Post
Drawing the ETH superbars transparent is not an issue. But I guess you also want to hide the regular bars in the ETH session, and display only the remaining 8 hours. Is that correct?

Unfortunately I don't have an indicator to draw a single hour from 08:30 to 09:30.

As for the range extentions I would look-up the first hour range by hand and simply use the existing Fibonacci tool. You have to configure the levels only once and draw the ranges with the tool. That's very quick and still exact. Like this for the gray superbar:


The problem with the fib tool is that we can't define multiple templates so that if i define say the 1 hour with extentions as you did and i need to use the standard fibonacci retracement configuration or something else, i need to redefine them manually each time. Do you know if it would be possible to add buttons on the screen that would be used to reconfigure the fib tool to different settings? say 1 button to define the initial balance with extentions, another button for the standard fib ratios, another one to configure the fib tool to some other ratios. Of course a drop down menu would be ideal to select which settings we want.

Reply With Quote
Thanked by:
  #8 (permalink)
 rosasurfer 
Sofia Bulgaria
 
Experience: Intermediate
Platform: MetaTrader, MultiCharts
Trading: Forex, ES, GC, strange synthetic creatures
Posts: 40 since Nov 2014
Thanks Given: 41
Thanks Received: 34


trendisyourfriend View Post
...Do you know if it would be possible to add buttons on the screen that would be used to reconfigure the fib tool to different settings?...

Never tried but this should be possible. Let's see if I can make something up...

Started this thread Reply With Quote
Thanked by:




Last Updated on September 30, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts