• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 11:15am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 11:15am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Multi timeframe multi chart 13 replies

Any Good Converter from MQ4 to MQ5? 0 replies

MQ4 to cAlgo Converter 5 replies

Looking for help with this periodcon indicator 3 replies

Backtest custom period? (period converter script) 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 73
Attachments: Improved multi-timeframe/offset/chart period converter, P4L PeriodCon.mq4
Exit Attachments
Tags: Improved multi-timeframe/offset/chart period converter, P4L PeriodCon.mq4
Cancel

Improved multi-timeframe/offset/chart period converter, P4L PeriodCon.mq4

  • Last Post
  •  
  • Page 1 23456 17
  • Page 1 234 17
  •  
  • Post #1
  • Quote
  • First Post: Edited Aug 11, 2014 12:28pm Nov 13, 2009 4:23am | Edited Aug 11, 2014 12:28pm
  •  pips4life
  • Joined Apr 2007 | Status: Member | 872 Posts
Last update: Feb 17, 2014, uploaded sample templates. (Build 600+ compatible).
Last "P4L PeriodCon.mq4" update: Feb 14, 2014, uploaded "P4L PeriodCon 509.ex4" (still v1.11)
Last "P4L getPeriodSymbolTimeshiftsecLib.mq4" update: Apr 01, 2011, posted first release v1_0

There have been several versions of period converter programs that were first created in late 2005 and then updated into early 2006, but since then, there have not been any updates (to my knowledge) or solutions to some of the limitations -- until now.

A new version (>= v1.6) is provided which I've renamed to "P4L PeriodCon.mq4". (It is a derivative of previous versions called: periodcon.mq4 (v1.5 and v1.4), Period_Converter_Opt.mq4 and Period_Converter.mq4 Previous authors (if known) are credited in the source, and their earlier contributions are graciously acknowledged).

New features:

* (Added in v1.11) Variable "InvertChart" was added. If set to "True", an inverted chart is output with an "i" as a prefix to the symbol name. (e.g. iEURUSD)
These external variables also apply:
InvertedOutputMultiplier = 1.0 The inverted prices are = InvertedOutputMultiplier/price.
InvertedOutputDigits = -1, where -1 is Automatic, or the user can manually set to >= 0
Example: Invert USDJPY to get iUSDJPY (same as JPYUSD). Set InvertedOutputMultiplier=1000.0, and set InvertedOutputDigits=3 (or 4). A price of 79.275 would normally invert to 0.012614 but with these overrides, inverted price would be 12.614

* Multi-chart live-updates work! The old versions could only live-update (tick-by-tick) a *single* offline chart with a given name. You could generate, e.g. an M20 (offline) chart and open it, but if you opened a 2nd-Nth window(s) of the same M20 (offline) chart, these did not get live-updates! With some hints from FF user rangebound (Thanks!), a new method was devised that finds and updates as many charts of a given name as you open. (FYI, if you only open ONE of each offline chart and if you want to save CPU, there is an external variable ("LiveUpdateMultipleCharts") you can change to "false". However in my experience CPU performance has not been a problem with the new multi-chart method).

* Full support for timeshifts (offsets) for any timeframe chart. Previous version v1.5 had the ability to generate a single Daily chart with one timeshift, but this new version can open many charts -- and of any timeframe, not just Daily -- where the user can specify any timeshift offset desired (plus or minus). HOWEVER: The timeshift *must* be an exact multiple of the source timeframe: 90min timeshift is legal on a source M30, M15, ... or less, but illegal on H1(60min) because it is not an exact multiple (i.e. 90/60 equals "1.5" which is not an exact multiple like 1,2,3, ...).

* Timeshifts are now specified either in #bars, or with the new number format, H.MM, ... or both can be used (as of >= v1.7).

Change the external variable "TimeShiftAdd_in_HptMM" from "0.0" to a number. Examples:
1.0 Timeshift 1hour forward (later). If your broker time says 22:45:00, then the timeshifted offline chart time will be 23:45:00
0.9 Timeshift 90 minutes forward.
1.3 Timeshift 90 minutes forward (as in 1 hour + 30 min = 90min total, same as 0.90 )
-0.20 Timeshift 20 minutes backward (earlier).
-5.0 Timeshift 5 hours backward (For a GMT broker time, the chart would then display NY local time)
(Reminder, the timeshift must be an exact multiple of the source timeframe (in minutes) ).

If you prefer specifying bars, use variable "TimeShiftAdd_in_Bars" (in >= v1.7). The timeshift (in minutes) is then the #bars * Period (of the source chart).

NOTE: These 2 variables for timeshifts are BOTH in effect and the values will combine (converted to minutes) if you use both variables.

The most obvious applications of timeshifts would be:
- Open a chart with a timeshift such that the X-axis displays your LOCAL times instead of the broker times.
- Using a single MT4 feed, create H4 and Daily charts where the daily 00:00:00 new bar time has been shifted by any number of hours, to see the same candles as are seen on other broker feeds that have a different native broker time (e.g. GMT vs. GMT+2 vs. GMT-17 etc.) You can decide if you want new Daily candles to occur at London open, NY open, NY close, etc.
- Create M45 candles but shift the bar start time as desired, to align with a time such as NY open (8AM ET) or NYSE open (9:30AM ET).
- Get a 1minute headstart on a bar close by shifting it 0.01. (How? Use an M1 chart to generate a higher TF chart timeshifted by +1M)
- Generate a Daily chart with 5-bars-per-week instead of the common 6-bars-per-week! Example: Suppose your broker time is 00:00:00 the same time as GMT. NewYork is GMT-5 which is 19:00:00. Your broker closes on Friday < 17:00:00 NY and reopens on Sunday >= 17:00:00 NY. Your Daily chart has a 2-hour Sunday bar, which is undesired. SO, you can generate an offline xxxxxx+2H,Daily chart which will *eliminate* the Sunday bar! If your broker has exactly 24*5=120 (or less) bars-per-week, and if you currently have a short Sunday (or Saturday) Daily bar on your chart, then you can pick an appropriate timeshift to eliminate your extra (short) Daily bar!
- Traders who look for candlestick patterns can try different timeshifts to see if a pattern is more (or less) successful for timeshifted vs. normal broker time.

* As before, one can still add multiple instances of this indicator to a single source chart to generate the data for multiple, different timeframe-or-timeshifted offline charts.

* An unobtrusive number of popup Alerts were added to notify the user of the offline chart name, and whether there were any problems with generating the desired chart. These occur when you add the indicator to the source chart, or when you restart MT4 with a session that has a chart with this indicator attached.

* A lot of people like to use indicators like CandleTime.mq4 to display the time remaining for the bar. However, for timeshifted data, some indicators (like these) don't work unless modified appropriately. A new version v1_2 of my "P4L CandleTime.mq4" indicator has been posted which is compatible with the timeshifted offline charts. Please download it from this thread: "New very cool CandleTime and session time Clock indicators"
(Note, a new v1_3 (not released yet) will be required to support charts > 1 Month period).

How to use:
* Copy this indicator to C:/Program Files/__your_MT4_broker__/experts/indicators/
Review the source with MetaEditor, Save+Compile any changes to defaults. Quit and restart MT4.

* Open a source chart of a lower-timeframe that is a multiple of whatever chart you want to generate. If you want a Daily chart with different hourly offsets than your existing normal Daily chart, then you could open an H1 chart or lower. (Note, you can choose any source TF but you will only generate data for only as much data as is in your source chart. If your M5 has 4 months of data, if you want to generate Daily charts, you would probably prefer to use H1 as source since it would likely have many more months/years of data. If you want to use a timeshift, the value (in minutes) must be an exact multiple of your source chart timeframe (in minutes) (e.g. 90min/M30 is legal but 90min/H1 is not).

* Add this indicator to the source chart. NOTE: On the Common tab, you must check the box to "Allow DLL imports".

* As desired, change the values for the variables PeriodMultiplier and/or TimeShiftAdd_in_HptMM (or TimeShiftAdd_in_Bars), and any other external variable. Example: Open an EURUSD,H1 chart, add this indicator and set PeriodMultipler=24 and a timeshift = -2.0. It will generate the data for a "EURUSD-2H,Daily" chart.

* Next, use the menu command: File -> Open offline -> (go down the list to find the exact chart name generated, i.e "EURUSD-2H,Daily"). Select it and click "Open".

* FYI, if you want to output the generated chart data into a CSV file, change OutputCSVFile from "0" (HST only) to either "1" (CSV+HST) or "2"(CSV Only). The csv file will be output into the folder <your_MT4>/experts/files/

Limitations:
* If your generated chart has changed the "Symbol()" name (which includes all TimeShifted charts!), you will NOT be able to use that chart with EA's or other indicators that require the original "Symbol()" name in order to work. Neither will you see live trades displayed on that chart. Why? Your broker only knows about the official Symbol names (e.g. "EURUSD"). An EA can place a trade of that Symbol, and MT4 can display the Buy/Sell/SL/TP lines for live trades on all charts with that same Symbol name. But if you have a TimeShifted chart, the Symbol name will have changed, for example, to "EURUSD+7H". Your broker doesn't know anything about that new Symbol name, so you can't trade it directly, and MT4 won't display live trades on TimeShifted charts. Assuming you have access to the MQ4 source file, your code can probably be modified to place trades if it knows the original "Symbol()" name. File "P4L getPeriodSymbolTimeshiftsecLib.mq4" below is provided for this purpose, but it's up to you to modify your MQ4 source code.

* Due to a MT4 limitation, in order to open any offline chart with a bar period of greater than 1 Month (30 days), MT4 must be fooled by telling it the period is <= 1Month. To tell the user what the actual period is, EITHER the symbol name is changed, or the period is changed (FYI, the period is always wrong for charts > 1 Month; this is a consequence of the MT4 limitations). For the following discussion, keep in mind that a chartname is always "symbol,period".

In >= v1.8, variable "Over_1MN_alters_Symbol_name" is "true" by default. This method is much easier to determine at a glance what is the actual chart period, but it is less compatible with some indicators (especially MTF, a.k.a. multi-time-frame) that require the original "Symbol()" name to be unmodified.

If "Over_1MN_alters_Symbol_name = true" :
An "_x#" is added to the Symbol name, where # is the PeriodMultiplier. Example:
EURUSD_x12,Monthly (This is 12 months, i.e. a Yearly chart!)
Due to an MT4 limit of 11-characters for the symbol name, if the user specifies also a timeshift and/or a large PeriodMultiplier, the symbol name is hacked in various creative ways to shorten it so MT4 can handle it. For example, a Monthly chart with PeriodMultiplier =12 and TimeShiftAdd_in_bars = 1 would be:
EURUSD+1Nx12,Monthly (ILLEGAL 12 character name!)
EU+1N_x12,Monthly (shortened symbol name). (Note "+1N" is +1 month shift!)

If "Over_1MN_alters_Symbol_name = false" :
Instead of changing the "Symbol()" name, the "Period()" is modified instead by the formula "Period() - PeriodMultiplier". The "Period()" in this case is the *source* chart period, which in common practice when generating charts over 1-month (30 days) is likely to be either PERIOD_MN1 (43200), or PERIOD_W1 (10080) or PERIOD_D1(1440). Examples:
A monthly source chart with PeriodMultiplier=2 will generate: EURUSD,M43198
A weekly source chart with PeriodMultiplier=5 will generate: EURUSD,M10075

Note: 4 hour charts are PERIOD_H4(240) but would require a multiplier of at least 180 to exceed 1-month bars. Perhaps it will work but it probably will be more confusing to even try. (FYI, regardless of timeframe, if "Period() - PeriodMultiplier" is negative, an arbitrary value of "101" is used instead).

Note2: Regardless of the setting for "Over_1MN_alters_Symbol_name", in the generated chart, the value for "Period()" is a lie! If you try to use indicators that require an accurate value for "Period()", it's going to be wrong and your indicator source must be changed to correct this. If the variable is "true", the true period is found by decoding the "Symbol()" name, finding the "#" after "x", and multiplying it times the "Period()" value. If instead the variable is "false", the true period is found by noting that it is slightly less than one of PERIOD_MN1, PERIOD_W1 or PERIOD_D1, calculating the difference, then multiplying the difference times the nearby PERIOD_* value. This is complicated... sometime in the future, I intend to post a routine to do this conversion which you can incorporate into your indicators. (UPDATE: See release of "P4L getPeriodSymbolTimeshiftsecLib.mq4" below!)

* As before, you cannot generate a chart that has the same period as an already existing normal timeframe: M1, M5, M15, M30, H1, H4, Daily, Weekly, Monthly (and on some brokers like Oanda, M10). However, as it already exists, there is no point in doing so. HOWEVER, if you want one of these standard charts but timeshifted by some amount, no problem.

* Some indicators aren't compatible with these generated charts. Any timeshifted chart tells the user how much the shift is by changing the "Symbol()" name. If your source chart is "EURUSD" and you timeshift by +15 minutes, the offline (new) Symbol() name is "EURUSD+15M". Most indicators and scripts don't care about what the symbol name is exactly, but some of them do. (ALL EA's that take trades DO care, and are not compatible unless modified!) Therefore, offline charts may not be compatible with some programs unless they have been properly modified to account for this Symbol() name change (AND also, if necessary, account for the fact that the bars have been timeshifted relative to the broker time). Also note that any indicator that has hardcoded the standard timeframe values may need modifications to work with non-standard timeframes like M10, M45, H2, etc. (UPDATE: See release of "P4L getPeriodSymbolTimeshiftsecLib.mq4" below!)

* In MT4 when you open an offline chart, it does not use your "Default" chart template (if you have one), but you can just manually load any desired template. (UPDATE: Solved! Save a template named "Offline", then future offline charts will open with that default. A WARNING, however: In your "offline" saved-template, you MUST check the F8->Common->Offline_chart checkbox or else you will get blank charts that say "Waiting for Update").

* Version 1.8 created so-called Yearly charts, but the starting month was arbitrary (and therefore somewhat useless). Version 1.9 addressed some of these problems with higher-TF charts.

Thinking ahead:
Please note that this indicator is written for MT4. The new MT5 version (released in 2010) can already generate charts with just about any timeframe (i.e. M2, M10, M20, M1234, H2, H8, etc. NOT sure about > Monthly(?) ). I have no idea if MT5 already supports an ability to timeshift data or not. Please comment if you know the answer. (So far, the answer has been "no").

UPDATES:
2009-11-13: First release of "P4L PeriodCon.mq4" v1.6 (Was downloaded 68 times).

2009-12-07: Released v1.7 update of "P4L PeriodCon.mq4" (Was downloaded 16 times).
Thanks to circlesquare, a method to create charts > 1 Month was found. MT4 can be fooled by (falsely) marking a chart as "Monthly" or less even though the data is > 1 Month-per-bar. However, to visually tell the user what is the actual period, the symbol name is modified to add "_x#" (e.g. "EURUSD_x12,Monthly" is actually a Yearly chart! Also added back in the "TimeShiftAdd_in_Bars" variable which is easier for higher timeframes.

2009-12-10: Released v1.8 update of "P4L PeriodCon.mq4" (Was downloaded 1407 times).
Added new variable "Over_1MN_alters_Symbol_name" ("true" by default). This is the more readable format used in v1.7, but setting it to "false" will modify the "Period()" value: Source-Period() - PeriodMultiplier. This later method leaves the Symbol() name unchanged (so long as timeshifts are zero!!) which makes generated charts somewhat more compatible with indicators. (Note, for charts > 1-month, the "Period()" is always a lie -- this was necessary to get around an MT4 limitation).

2011-03-23: Released v1.9 update of "P4L PeriodCon.mq4"(Was downloaded 3828 times).

Changes:
* Fixed some of the problems with higher timeframe charts (e.g. weekly) that caused the start-of-the-bar to be irregular (i.e. a weekly should start the beginning of the week, either Sunday or Monday, not a Thursday for example). Some higher timeframe charts that involve timeshifts may or may not work, because the method to "slice" up the source bars and allocate them is not perfect. This version, however, is better than v1.8


2011-04-01: First Release v1_0 of "P4L getPeriodSymbolTimeshiftsecLib.mq4"

New:
* This libary file can be included in your MQ4 indicator/script/EA source files to interpret the "Symbol()" and "Period()" values as modified by the "P4L PeriodCon.mq4" indicator. The library routine returns the period, symbol, and timeshiftsec values. It is up to the user to properly incorporate the values into your code.
* Two use models are described in the code, either to call the routine in a separate library file, or to include the 3 necessary routines in your source code.
* Note: This is brand new code and was tested for some commonly generated charts. It hasn't been fully tested for every obscure possible chart multiplier/timeshift combination. Report any problems found by posting to the thread.


2012-10-18: Released v1.11 update of "P4L PeriodCon.mq4"

Changes:
* Variable "InvertChart" added. If set to "True", an inverted chart is output with an "i" as a prefix to the symbol name. (e.g. iEURUSD,H1)
* New external variables:
InvertedOutputMultiplier = 1.0 The inverted prices are = InvertedOutputMultiplier/price.
InvertedOutputDigits = -1, where -1 is Automatic, or the user can manually set to >= 0
Example: Invert USDJPY to get iUSDJPY (same as JPYUSD). Set InvertedOutputMultiplier=1000.0, and set InvertedOutputDigits=3 (or 4). A price of 79.275 would normally invert to 0.012614 but with these overrides, inverted price would be 12.614
* Changed the primary initial popup message to
"P4L PeriodCon: Do File->Open_Offline of chart: EURUSD,H12 (offline) (Time shifted 0min) and KEEP this Source H1 OPEN!"

2014-02-14: Uploaded "P4L PeriodCon 509.ex4" (still v1.11)

Changes: None. (It's the same source as is already posted). It was simply compiled using build 509, and it appears to be compatible with the new builds >=600.
Fyi, the posted v1.11 .mq4 (source) file is NOT compatible with the new builds. The source file will require code changes for the new build. (I've no immediate plans to do so). Should you need to make custom edits, you can use your own (old) copy of 509, or find the 509 MetaEditor posted elsewhere that you can use to edit and re-compile to make your own .ex4 file.

2014-02-17: Uploaded sample 509 templates (Build 600+ compatible)

Changes:
Two sample templates are available below. They are identical, except with respect to what indicator name is used.
One assumes use of "P4L PeriodCon 509.ex4". The other assumes use of "P4L PeriodCon.ex4". (Both based on v1.11).
I don't care which name you use for the base indicator. Your choice.

Use the appropriate template with any H1 chart. It will generate two offline charts: base+7H,H4 and base+7H,Daily

The generated H4 and Daily charts are timeshifted by +7H. Why? These are intended for use with GMT-5 broker feeds (i.e. those who match NewYork U.S. Eastern Time). If you have such a GMT-5 broker, you can use this template to generate GMT+2 charts. Fyi, GMT+2 Daily charts normally have 5-Daily-bars-per-week, and 30-H4-bars-per-week. GMT-5 charts (and most every other time feed) have 6-Daily-bars-per-week, and 31-H4-bars-per-week. I like to compare the two, because the broker feed affects, for example, the slopes of trendlines, pitchforks, etc.

New users: Regardless of your broker GMT+??, use these templates to get started, just to prove you can generate and open offline charts. Then customize the settings and create your own desired template(s) that suit your own needs. If you want M10 or H2 charts... then customize. If your broker has a different GMT offset, then use a different timeshift value to customize as desired.

Screenshots:
The white charts are native timeframes, the black ones are generated "offline" charts. (FYI, you can change the colors of "offline" charts just like any other chart).
Note the non-standard timeframes generated (M10, M45, H2, H8).
Note the time-shifted Daily charts with +2H and -1H. A regular Daily chart is between them. See how the new "P4L CandleTime.mq4" indicator displays different numbers of hours for each Daily chart before the bar closes for each of those charts. The +2H has 17:29:21 remaining, regular has 19:29:21, and -1H has 20:29:21 remaining.

-----------------------------------------------
FYI, see also: Collection of programs by pips4life
-----------------------------------------------

These and other programs I've posted are *free*, but donations are welcome! PayPal to pips4life_at_yahoo_dt_com
Attached Image(s) (click to enlarge)
Click to Enlarge

Name: M5 M10 M45 GY charts.jpg
Size: 193 KB
Click to Enlarge

Name: H1 H2 H8 Daily plus Offsets GY charts.jpg
Size: 155 KB
Attached File(s)
File Type: mq4 P4L getPeriodSymbolTimeshiftsecLib.mq4   21 KB | 10,282 downloads | Uploaded Apr 1, 2011 7:33pm
File Type: mq4 P4L PeriodCon.mq4   60 KB | 12,879 downloads | Uploaded Oct 18, 2012 6:08pm
File Type: ex4 P4L PeriodCon 509.ex4   23 KB | 10,387 downloads | Uploaded Feb 14, 2014 3:28pm
File Type: tpl percon509 for h1 to make h4+7h d1+7h.tpl   4 KB | 3,480 downloads | Uploaded Feb 17, 2014 3:52pm
File Type: tpl percon for h1 to make h4+7h d1+7h.tpl   4 KB | 3,181 downloads | Uploaded Feb 17, 2014 3:52pm
  • Post #2
  • Quote
  • Nov 13, 2009 1:07pm Nov 13, 2009 1:07pm
  •  hanover
  • Joined Sep 2006 | Status: ... | 8,092 Posts
Brilliant! Congrats, and many thanks for sharing. This will be very useful to me, and no doubt to many others, also.
 
 
  • Post #3
  • Quote
  • Edited Nov 14, 2009 8:22am Nov 13, 2009 1:27pm | Edited Nov 14, 2009 8:22am
  •  walb99
  • | Joined Nov 2007 | Status: Member | 1,142 Posts
This indicator is perfect. A big help. Brilliant.
Thank you!!!!
/ ... clarifying decisions ... /
 
 
  • Post #4
  • Quote
  • Nov 14, 2009 1:59am Nov 14, 2009 1:59am
  •  aquaart
  • | Joined Nov 2008 | Status: Tech Analyst- Right 50% of the time | 528 Posts
Thanks pips4life for this "P4L PeriodCon.mq4" and the fantastic run down on the abilities of the indicator.

It looks like it will be brilliant.
 
 
  • Post #5
  • Quote
  • Nov 15, 2009 4:23pm Nov 15, 2009 4:23pm
  •  pips4life
  • Joined Apr 2007 | Status: Member | 872 Posts
Hey hanover, walb99, aquaart,

Thanks for the high praise. Once you get more experience with the "P4L PeriodCon.mq4" indicator, be sure to post an update with any issues you may find, but hopefully it will work as expected. Thanks.
 
 
  • Post #6
  • Quote
  • Edited 6:42am Nov 16, 2009 4:11am | Edited 6:42am
  •  aquaart
  • | Joined Nov 2008 | Status: Tech Analyst- Right 50% of the time | 528 Posts
Quoting pips4life
Disliked
I have no idea if MT5 already supports an ability to timeshift data or not. Please comment if you know the answer.
Ignored
Not 100% sure, But had a pretty decent look at MT5 and couldn't find anything to do with shifting time frame. Many more timeframes (all the possibly useful ones by the looks of it to me), but without timezone adjustment.


Love the P4L_PeriodCon..

And the candle time clock in P4L_Candletime is excellent too.

Is it possible to make the chart auto start a new candle?
What I mean is, is it possible to make P4L_PeriodCon tell it to update at the close of the shifted candle and/or open of the new shifted candle?
 
 
  • Post #7
  • Quote
  • Nov 16, 2009 8:32am Nov 16, 2009 8:32am
  •  pips4life
  • Joined Apr 2007 | Status: Member | 872 Posts
Quoting aquaart
Disliked
Is it possible to make the chart auto start a new candle?
What I mean is, is it possible to make P4L_PeriodCon tell it to update at the close of the shifted candle and/or open of the new shifted candle?
Ignored

In MT4, indicators can only run when triggered by a new tick. There is no provision to schedule an automatic tick (EA's and scripts can loop and/or "sleep" a specified time period but not indicators). A user can manually force a tick using menu Charts -> Refresh (or sequential keystrokes: Alt c r). However, one cannot force a new actual bar because there is not even an "Open" price yet, within the specific time period -- and there may never be, if the market has very long gaps between ticks.

For example, suppose your source chart is an M1 chart and you generate M2. If there is a 3-minute long gap between ticks, then your M1 chart will be missing the middle 2 bars of the gap, and the M2 chart will be missing 1 bar.

I know there are some threads on FF that talk about "gap free charts" which will create the missing bars (where the last Close price becomes the price for the OHLC of these newly added bars). I have not looked into that topic very much.

I attached some pictures here showing a source M1 chart and a generated offline M2. With every incoming tick, both charts "Refresh". However, on the picture where the right M2 "P4L CandleTime" shows "WAIT4BAR:-00:19", in that window I used a "Refresh" to manually force a tick. There is no new actual bar until a real tick comes in (see 2nd picture). Also note in the first picture that the left M1 chart says "00:27" (27 seconds to go for that bar) but the M2 chart says "WAIT4BAR:-00:19" (19 seconds past the top of the minute and no new bar yet). Hey wait, shouldn't the M1 chart also say "WAIT4BAR:-00:19" you ask? Well it would but my "Refresh" was only forced on the right M2 chart, not the left M1.

The 3rd picture attached shows a picture where I forced "Refresh" in both windows very quickly. Oh, by the way... in the 3rd picture, what are those colored circles on my M1 chart? That is from the very cool new "Recent News.mq4" indicator by hanover. It gives me a visual indicator of the news events that are about to happen in just a few minutes.
Attached Image(s) (click to enlarge)
Click to Enlarge

Name: M1 M2 WAIT4BAR.jpg
Size: 93 KB
Click to Enlarge

Name: M1 M2 Next Tick.jpg
Size: 96 KB
Click to Enlarge

Name: M1 M2 both WAIT4BAR.jpg
Size: 99 KB
 
 
  • Post #8
  • Quote
  • Nov 16, 2009 5:59pm Nov 16, 2009 5:59pm
  •  hanover
  • Joined Sep 2006 | Status: ... | 8,092 Posts
Quoting pips4life
Disliked
That is from the very cool new "Recent News.mq4" indicator by hanover.
Ignored
Your referral fee paycheck is on its way, LOL.
 
 
  • Post #9
  • Quote
  • Nov 17, 2009 5:54am Nov 17, 2009 5:54am
  •  aquaart
  • | Joined Nov 2008 | Status: Tech Analyst- Right 50% of the time | 528 Posts
Quoting pips4life
Disliked
In MT4, indicators can only run when triggered by a new tick. There is no provision to schedule an automatic tick (EA's and scripts can loop and/or "sleep" a specified time period but not indicators). A user can manually force a tick using menu Charts -> Refresh (or sequential keystrokes: Alt c r). However, one cannot force a new actual bar because there is not even an "Open" price yet, within the specific time period -- and there may never be, if the market has very long gaps between ticks.
Ignored
Thanks for the answer....

I am not used to using offline charts.... ....and actually changed the source chart just before the TF change over and then switched platforms NOT registering the TF change affected the offline charts updating. So it was my lack of common sense (common platform operation sense) that was the stuff up, and not the indicator not updating.


Fantastic indicator though and shows how a TF that starts at different points, like a 4 hour timeframe starting on 1st 2nd or 3rd hour, can really affect some indicators, like MAs, MACD etc...

Thank you,
And I am off to check Hanover's newest indicators. About 5 weeks ago, I actually looked for Hanover's recent / best indicators because I found the ones he had previously completed to be so useful. This link is a very good link.
 
 
  • Post #10
  • Quote
  • Dec 2, 2009 9:49pm Dec 2, 2009 9:49pm
  •  MJ12
  • | Joined Sep 2009 | Status: Member | 244 Posts
Hi, great indicator. i think i may be doing something wrong though. when i load up a chart, eg. a 2 hour chart converted from a 1 hour chart and load the chart in offline mode - that chart does not update live. Am i right in thinking that it should update like normal despite the fact it was loaded in offline mode? I'm pretty sure have followed instructions to the letter. Maybe i have got the wrong idea!
 
 
  • Post #11
  • Quote
  • Dec 2, 2009 10:34pm Dec 2, 2009 10:34pm
  •  pips4life
  • Joined Apr 2007 | Status: Member | 872 Posts
Quoting Majestic12
Disliked
Hi, great indicator. i think i may be doing something wrong though. when i load up a chart, eg. a 2 hour chart converted from a 1 hour chart and load the chart in offline mode - that chart does not update live. Am i right in thinking that it should update like normal despite the fact it was loaded in offline mode? I'm pretty sure have followed instructions to the letter. Maybe i have got the wrong idea!
Ignored
It's working fine for me, and yes, the generated "offline" chart should update live, as long as the source chart is live and remains open in your session. (If you close the source chart, the live updates will stop).


You first open a normal H1 chart. (Do not change your normal source chart "offline" property -- leave it unchecked or else nothing will update).

Add "P4L PeriodCon.mq4". Use "PeriodMultiplier = 2".
When you do so, you should get a Popup Alert similar to the bottom of my attached picture that says:
"Looking for one or more charts named: EURUSD,H2 (offline) (Time shifted by 0min )"

Then, click on the File menu, and select "Open offline". You will get a list similar to the top of my picture. Find the desired chartname and click "Open".

The H2 offline chart should come up, and it should update with every tick, just like my attached picture is in sync (and still is).


If it's not working for you following these steps, then... did you edit the code in some way? Change any defaults? Maybe it's corrupted and you could try downloading it again. If still not working, then I have no idea what could be the problem. Please provide more details such as the Broker name, demo vs. live, MT4 build number (mine is 225), your computer O/S, ... anything else you can think of.

Perhaps restarting MT4 ??
Attached Image (click to enlarge)
Click to Enlarge

Name: P4L PeriodCon H2.jpg
Size: 161 KB
 
 
  • Post #12
  • Quote
  • Dec 3, 2009 1:23pm Dec 3, 2009 1:23pm
  •  hanover
  • Joined Sep 2006 | Status: ... | 8,092 Posts
Quoting Majestic12
Disliked
Hi, great indicator. i think i may be doing something wrong though. when i load up a chart, eg. a 2 hour chart converted from a 1 hour chart and load the chart in offline mode - that chart does not update live. Am i right in thinking that it should update like normal despite the fact it was loaded in offline mode? I'm pretty sure have followed instructions to the letter. Maybe i have got the wrong idea!
Ignored
When you attach the P4LPeriodCon indy, you need to check Allow DLL imports parameter on the Common tab to ON. You should have got an Alert message telling you to do this.

That is the only other thing that I can think of. It updates fine for me.
 
 
  • Post #13
  • Quote
  • Dec 5, 2009 8:38am Dec 5, 2009 8:38am
  •  circlesquare
  • | Joined Dec 2009 | Status: Member | 8 Posts
Getting tf's above monthly was something I tried to get working over a year ago I believe. Tried seemingly everything, and gave up after all my futile attempts. But today, after I seen your new update to periodcon, I decided to look at it again with fresh eyes. I think I finally got something.

As you know, there's a limitation. But we simply need to trick metatrader to think our chart is below monthly, when really we're showing any tf we want. And luckily, we only need to change a few lines of code to do that.

I haven't tested it in a live market unfortunately, but I know it has a good chance of working because the chart actually loads.


changes I made can be found on lines: 311, 366, 454, and 552
Attached File(s)
File Type: mq4 P4L PeriodCon-1.mq4   39 KB | 3,100 downloads
 
 
  • Post #14
  • Quote
  • Dec 6, 2009 6:45pm Dec 6, 2009 6:45pm
  •  circlesquare
  • | Joined Dec 2009 | Status: Member | 8 Posts
It works live as I hoped. One change I would make on line 369 is,

instead of:
else NewPeriod = Period()-PeriodMultiplier;

change it to:
else NewPeriod = PERIOD_MN1-PeriodMultiplier;

Thats in case you build tf's above monthly using something as low as even h4 as the base tf, depending on the Multiplier you apply, it might result in a negative result.

Or come up with your own unused( below Monthly) custom tf to hold the data like:

else NewPeriod = 64;

That would place the > monthly data in a chart named M64.

Don't forget to label your chart manually to avoid getting confused what your looking at!
 
 
  • Post #15
  • Quote
  • Dec 7, 2009 4:40pm Dec 7, 2009 4:40pm
  •  pips4life
  • Joined Apr 2007 | Status: Member | 872 Posts
Quoting circlesquare
Disliked
Getting tf's above monthly was something I tried to get working over a year ago I believe. Tried seemingly everything, and gave up after all my futile attempts. But today, after I seen your new update to periodcon, I decided to look at it again with fresh eyes. I think I finally got something.
Ignored
Hey circlesquare,

Nice job coming up with a solution. There were some minor problems with the changes you made that weren't compatible with timeshifted charts, but I fixed those. More comments in my next post...
 
 
  • Post #16
  • Quote
  • Dec 7, 2009 5:28pm Dec 7, 2009 5:28pm
  •  pips4life
  • Joined Apr 2007 | Status: Member | 872 Posts
A new version v1.7 "P4L PeriodCon.mq4" was released in Post #1.

Variable "TimeShiftAdd_in_Bars" was added back to the code because the #bars is easier to use for the higher timeframes. The "TimeShiftAdd_in_HptMM" variable AND this new variable are combined to determine the total timeshift (in minutes).

Charts > 1 Month are supported (thanks to a tip from circlesquare). MT4 must be fooled into thinking it's a "Monthly" chart (or less). To visually tell the user what the actual period is, the symbol name is changed by adding "_x#" where "#" is the Period Multiplier.

EURUSD_x12,Monthly (This is actually a Yearly chart, or 12 months-per-bar)

There is another unfortunate MT4 limitation which forced some creative "hacking" around to get it to work. The maximum symbol name in MT4 is only 11 characters. The syntax I use for timeshifts PLUS the new syntax for > 1 Month ends up being too long, so, by hacking the name as much as needed, eventually a legal symbol name can usually found in order to create the data and allow the user to successfully open it as an offline chart.

Example: Open a Monthly EURUSD chart, add the indicator and specify PeriodMultiplier = 12 and TimeShiftAdd_in_Bars = 1.

One might prefer the chartname: "EURUSD+1MN_x12,Monthly (offline)" ... but the symbol portion is too long at 14 characters!

I shortened the symbol name as follows:

The "_" before "x" is optionally removed whenever a timeshift is specified, but only if it helps to keep within the character limit.

The "MN" is now always just "N". The "M" is used only for Minutes.

Even with these changes, this example is still 12 characters, so, last but not least, "EUR" is shortened to "E" and "USD" is shorted to "U". The result is:

EU+1N_x12,Monthly

This final name works in MT4. Other major currency names are similarly shortened (but CAD->CA and CHF->CH to keep them distinct).

If you use some obscure pair or other symbol name, and if the timeshift plus the "x#" syntax is still too long, then the symbol name AND period are changed as follows:
A Monthly SEKRUB chart is opened, then PeriodMultiplier=12 and TimeShiftAdd_in_Bars = 1:
SEKRUB+1Nx,M43188

The "+1N" means 1-month timeshift (using "N" rather than old "MN").
Since "x12" exceeds the character limit, just "x" is used.
The reported period is the source chart "Period() - PeriodMultiplier". In this example, Monthly (43200) - 12 = "43188"


Of course, if you use other indicators that require a specific symbol name, this new hacked-name will need to be unconverted to get back the original "Symbol()" name, the true "Period()", and the timeshift value. I will get around to writing the routine and posting it here and in the thread for my "P4L CandleTime.mq4" indicator. It will be done in v1_3... (no promise as to when it will be completed).

Please try out the new v1.7 and let me know how it works for you...

Kent
 
 
  • Post #17
  • Quote
  • Dec 7, 2009 8:47pm Dec 7, 2009 8:47pm
  •  circlesquare
  • | Joined Dec 2009 | Status: Member | 8 Posts
I'm glad you liked the update. The naming idea is great and solves the problem of identifying the chart easily.

But, I believe I encountered a bug due to the naming. The Time Series functions like iTime, iHigh etc. are affected. Even when using Symbol() or NULL as the symbol name.

The bug is when we try to access any normal lower tf like 240 or 60 using the time series function, we get 0 returned. so iTime(Symbol(),240,1) will return 0.
Yet, strangely, accessing current tf like: iTime(Symbol(),0,1) will work.

This means that the new chart symbol names are incompatible somewhere internally even though Symbol() returns the normal name.

So, maybe consider a compatibility option that lets user decide prettier chart names or more compatibility. I'll leave that up to you though.
 
 
  • Post #18
  • Quote
  • Dec 7, 2009 9:55pm Dec 7, 2009 9:55pm
  •  pips4life
  • Joined Apr 2007 | Status: Member | 872 Posts
Quoting circlesquare
Disliked
I'm glad you liked the update. The naming idea is great and solves the problem of identifying the chart easily.

But, I believe I encountered a bug due to the naming. The Time Series functions like iTime, iHigh etc. are affected. Even when using Symbol() or NULL as the symbol name.

The bug is when we try to access any normal lower tf like 240 or 60 using the time series function, we get...
Ignored

Hi circlesquare,

If I understand your point, there is no "bug" with "P4L PeriodCon.mq4" generating any chart you want, of any timeframe, and any offset. Rather, there are limitations with using those generated charts with other indicators. If those indicators rely upon specific values for "Symbol()" or "Period()", or if they don't account for a chart timeshift, then they will not work (unless modified appropriately). This is not something which changed with v1.7. The same issues arise with v1.6 as well and I believe this was discussed in Post #1. The thing that is unique to v1.7 is you can now generate TF's > Monthly... BUT, only for these big TF's, the Symbol() name will have changed even if there is no timeshift.

With the iTime(Symbol(),0,1) (accessing the current symbol and timeframe), I'm not surprised at all that it works, regardless of the "Symbol()" name. The data exists for THAT symbol, and by definition the current timeframe is what you're looking at, so, ... the data is found.

But if you try using this with a multi-timeframe indicator, then yes, either the "Symbol()" name must be unchanged on the main chart, or, you must generate whatever TF data is being requested using the same Symbol() name.


Leaving out timeshifts for a moment, consider that you generate a "W2" chart for EURUSD. The offline chart is "EURUSD,W2 (offline)". The "Symbol()" on said chart will return "EURUSD" and Period() will return "20160". If your indicator wants to access iTime("EURUSD",PERIOD_W1,0), then... no problem. That data is a normal timeframe and symbol. Same with PERIOD_H4, etc.

Now suppose you want to access an "H2 (offline) timeframe: iTime("EURUSD",120,0). Even THAT will work so long as your session somewhere is generating that custom timeframe.

What will NOT work is if you have a timeframe > Monthly and you expect to access lower-TF's of the same "Symbol()" name. As you already pointed out, we have to fool MT4 and make it think the "Period()" is <= PERIOD_MN1. I decided to modify the "Symbol()" name. You are right to point out that other indicators (especially MTF) will not find lower-level data because the "Symbol()" name is now unique (e.g. "EURUSD_x2").

It CAN be done, but your other indicators will need to be modified. I mentioned that I'll get around to writing the routines that convert the customized Symbol() name and give you the true names for symbol, period, and timeshift. Just haven't got to it yet...


Regarding timeshifted charts, then... the "Symbol()" name is always customized in some way. Suppose you open an H1 EURUSD chart. With PeriodMultiplier=24 and TimeShiftAdd_in_Bars=1, you generate a Daily chart timeshifted by "+1H". The Symbol will be "EURUSD+1H", Period = 1440. In order for iTime(Symbol(),240,0) to work, all you need to do is generate another offline chart with PeriodMultiplier=4 and the same H1 timeshift, and then it should work. If you are expecting lower timeframes to be accessed WITHOUT timeshifting, it's not going to work.

While iTime does have a "shift" argument, as in "iTime(symbo,TF,shift)", you should not try to use "shift" to synchronize with a timeshifted chart. You would already be customizing your code to do so but this would not be the right way to go. Furthermore, "shift" is only backwards in time, whereas the timeshift can be either way.



My post is a bit long and complicated, I know. Tell me this: Does your version, "P4L PeriodCon-1.mq4" work for your needs for TF's > 1 Month, but my v1.7 does not? If yours does work, then your other indicators must not care about whatever the local "Period()" value is, but they probably do care about whether the "Symbol()" name changed. If this is the case, then perhaps I can put in an option to force the use of changing the Period() to "Period() - PeridMultiplier" and leave the Symbol() name completely unchanged. Let me know...

Kent
 
 
  • Post #19
  • Quote
  • Edited 10:24pm Dec 7, 2009 10:12pm | Edited 10:24pm
  •  circlesquare
  • | Joined Dec 2009 | Status: Member | 8 Posts
Edit: I see your point now. for some reason my test was faulty. I think I used my test code on the wrong chart. duh
Sorry about that.

It is technically a bug with using timfreames above monthly with the newer naming scheme.

Try the following code in a chart > monthly built with the version I uploaded, then again with your last update.

Print(Symbol());
Print("60 tf previous bar open time=",iTime(Symbol(),60,1));
Print("240 tf previous bar open time=",iTime(Symbol(),240,1));
Print("current tf previous bar open time=",iTime(Symbol(),0,1));

Print("60 tf previous bar high=",iHigh(Symbol(),60,1));
Print("240 tf previous bar high =",iHigh(Symbol(),240,1));
Print("current tf previous bar high =",iHigh(Symbol(),0,1));
 
 
  • Post #20
  • Quote
  • Dec 7, 2009 10:20pm Dec 7, 2009 10:20pm
  •  circlesquare
  • | Joined Dec 2009 | Status: Member | 8 Posts
I follow you about Symbol() now. For some reason, I thought Symbol printed the real name for me in my test. Strange.
 
 
  • Platform Tech
  • /
  • Improved multi-timeframe/offset/chart period converter, P4L PeriodCon.mq4
  • Reply to Thread
    • Page 1 23456 17
    • Page 1 234 17
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023