From MetaTraderProgrammer WIKI
Jump to: navigation, search

Microtimeframe is a trading tool that can be used to generate custom charts such as Renko charts, Range bar charts, and non-standard timeframe charts.

How to get the software?

Microtimeframe can be purchased on the following link: Microtimeframe

The software will be sent to your mailbox in a zip file immediately after paying.


The installation is explained in the Software_Installation_Manual.pdf.

There is also an online version available for the Installation Manual


Microtimeframe is capable of generating 5 different types of charts:

  • Microtimeframe Charts (chart_t1)
  • Tick Charts (chart_t2)
  • Range Bar Charts (chart_t3)
  • Point and Figure Charts (chart_t4)
  • Renko Charts (chart_t5)

The type of chart to be generated by microtimeframe can be changed through the external parameter chart_type. For example, when generating Renko charts, chart_type should be set to 5.

The generation of these charts involve different settings. As shown above, each chart has its own designation. All other parameters containing the prefix of the chart type designation are used, while those parameters belonging to other chart types are ignored by the EA. Using the same example, with the chart_type set to 5 (Renko), the external parameters chart_t4_5_reversal and chart_t4_5_reversal would also need to be configured. The same parameters are also used by chart_type = 4 (P&F chart). chart_t4_5 simply means chart_t4 or chart_t5. With this setting, other parameters such as chart_t2_tick_max will be ignored by the EA, since it belongs to another chart type (chart_t2 or tick charts).

Setting up Microtimeframe for Chart Generation

  1. Go to Navigator window (if it's not on your screen, press Ctrl+N).
  2. Select Expert Advisors / microtimeframe_v12, drag and drop to chart you want to use.
  3. You will see the name of the EA on the chart in the up-left corner. If you see smiling face or sad face, the microtimeframe is running (if you see das face trading is not allowed, but microtimeframe will not do anything but making offline chart). If you see X, Click on the "Expert Advisors" button on the toolbar, or check the settings again described in the 0.2 Step 2. especially the "Enable Expert Advisors".
  4. On the comment line you will see a counter. It will run fast or slow based on your settings in run_frequency_ms. It will run as long as running Expert Advisors are enabled. You can enable/disable expert advisors by the "Expert Advisors" button on the toolbar.
  5. Go to File/Open Offline, and search for the offline chart the microtimeframe makes. The currency is the same as the chart you attached the microtimeframe, the timeframe is set in the chart1_timeframe_name, chart2_timeframe_name and chart3_timeframe_name parameters (number of minutes).

Running Scripts

Running scripts native to the microtimeframe EA can be done in two ways: (1) double-click/drag-and-drop and (2) using a hotkey.

Method 1

  1. Make sure that the chart running microtimeframe is the active chart
  2. Go to the Navigator window (if it's not on your screen, press Ctrl+N)
  3. Run the script
    1. Select and double-click on the script you want to run, or
    2. Drag and Drop the script to the chart

Method 2

This method can be used if you have assigned a hotkey on the script.

  1. Ensure that the target chart is selected
  2. Press the hotkey linked with the script

Instructions for Specific Functions

Setting Continuous Operation

  1. Open the Expert Properties window (F7)
  2. Change the run_frequency_ms to something larger than 10 ms. It will set the sleep between every running. Microtimeframe is optimized for speed. However, the less number you set, the faster will be the reaction of your charts. Try to keep the value to a minimum. It is recommended to use a setting of 50 (ms).

Single Chart Generation

  1. Stop Expert Advisors if you use Continuous Running option.
  2. Open Expert Properties (F7).
  3. Set the following parameters:
    1. chart_type: 1
    2. chart_t1_timeframe_seconds: seconds of chart you want to make, like 20 secdons.
    3. connect_open_close: true, if you don't want gaps between candles
    4. chart_timeframe_name: a chart timeframe other than usual timeframes. DON'T set it to any of these: 1, 5, 15, 30, 60, 240, 1440. Those numbers are assigned for the standard timeframe. You can set it anything other than these. It is recommended to use smaller numbers so they can be easily remembered.
  4. . Set the run_frequency_ms to the desired amount (check previous chapter). If you use timeframe seconds larger than 20 sec, and the currency is 5 digits, you can set the variable to zero.

Description of All Parameters

Parameter Unit Description Sample Values
chart_type - type of chart 1 - microtimeframe; 2 - tick; 3 - range; 4 - point&figure; 5 - renko
chart_t1_timeframe_seconds seconds periodicity of the chart to generate 5, 30, 1440
chart_t2_tick_max number of ticks maximum number of ticks per candle for tick chart (2) 50, 100, 200
chart_t3_range_max pips maximum candle range for a range bar chart (3) 5, 10
chart_t4_5_boxsize pips box size for P&F and Renko charts (4 & 5) 5, 10
chart_t4_5_reversal multiple of box size reversal in multiple of chart_t4_5_boxsize for P&F and Renko charts (4 & 5) 1, 2, 5
chart_timeframe_name - Timeframe of offline chart in minutes (storage purposes only) Any whole number greater than zero, EXCEPT those used for standard timeframes {1, 5, 15, 30, 60, 240, 1440}
connect_open_close - If true, there will be no gaps between candles true or false
price_to_use - the price to use for generating the custom chart PRICE_BID - 1, PRICE_ASK - 2, PRICE_MID - 3
historytimeback seconds maximum time to go back when the script microtimeframe_regenerate_charts is used. 86400 (1 day), 2,628,000 (1 month)
historygenerate_tf chart period standard chart timeframe to use when the script microtimeframe_regenerate_charts is used. 1 (uses M1), 5 (uses M5)
update_chart_frequency seconds minimum frequency to update the offline chart - set higher only if you have performance issues. 0 (every tick), 5 (every 5 seconds)
append_to_file - If false, it will not append to the offline chart, but will start over true or false
run_frequency_ms milliseconds frequency of running the EA on the chart 0 (every tick), 500 (every 0.5 seconds)
check_newprice_ms milliseconds frequency of checking for price changes on a chart 0 (every tick), 500 (every 0.5 seconds)

For chart_timeframe_name You can use anything expect these: 1, 5, 15, 30, 60, 240, 1440. Also avoid any timeframe that are also used by other offline chart generators (like timeframe converter). It is recommended to use smaller values.

run_frequency_ms can also be used when the tick volume is low. For example, if the currency pair or instrument you want to make a custom chart with is fast, and the price is slow, it will not be able to draw the candles which has no movement, causing shift in time, so it will show false data if you use any time-critical tool, like trendlines, moving averages, or any indicator that use more than one candle. You have the choice to make microtimeframe run tasks in a given intervals, like 500 ms, so you will not have problems because price is too slow.

check_newprice_ms will check if there is a new price movement in a given interval. It is recommended to us 50ms.

Programming EAs working with MicroTimeframe

The microtimeframe sends the faketick event with code 222 to the offline chart, so the EA can watch this event. This is needed because the old method of using internal message for generating fake tick is not working any more.

You can use this code to make MicroTimeframe working with your EA:

#define EVENT_FAKETICK 222 

void OnChartEvent(const int id,         // Event ID
                  const long& lparam,   // Parameter of type long event
                  const double& dparam, // Parameter of type double event
                  const string& sparam  // Parameter of type string events

The above code will watch the event with code 222, and will call the start() function accordingly.

Important Note 1: You may need to replace start() with OnStart() if the EA is using the newer syntax.

Important Note 2: If your EA already have the OnChartEvent function added – with the same parameters as above –, you mustn't add the same function again, just add the line as shown.