Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-17-2006, 05:29 AM
ycomp's Avatar
Member
 
Join Date: Jan 2006
Posts: 93
ycomp is on a distinguished road
MT4 gurus: How do I access an indicator of a different time frame?

Hi,

I came across this problem before and gave up.

Now I've encountered it again while trying to code another indicator. It is a common problem so I'm sure someone must know the answer.

The question is, using iCustom or built in iIndicator functions, how do I access data from another time frame? I know that there is a time frame parameter, and I use it but the problem is that the shift is still from the current chart.

I tried dividing shift by the ratio of the time frames (e.g. 4 for accessing H1 from M15) but that didn't seem to work for me.

example:

CoolIndicator1 is running on M15. It wants to read the value of RSI for current time frame... no problem call iRSI with timeframe of 0 or PERIOD_M15.

But how do I get the value of RSI for this point in time for M30? or H1?

I tried using iBarShift( ) but that didn't work out for me. Sounds like it is the right thing to use though.

So if anyone has any code that could be of use or simply any comments that could point me in the right direction, please post.

thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-17-2006, 06:40 AM
FloFri's Avatar
Junior Member
 
Join Date: Sep 2005
Posts: 21
FloFri is on a distinguished road
Smile

I had the same problem with some indicator's that wouldn't let me read data with iCustom.
There's a way to access all data from anywhere, that is if you are able to locate the variable(s) in the indicator that provide the data. I've been using this method for several months now, and I never missed any data with it. It sounds like a cludge and of course it is, but at least for testing purposes it works. By then you could decide if it's worth while to code a more robust solution.
Simply write te value of the indicator to a file. Then read it with the other indicator or expert. There's an example of this in the standard samples. Name the file with a combination of the indicators name with the timeframe and the symbol to keep them apart.
Maybe this helps (a bit).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-17-2006, 07:22 AM
ycomp's Avatar
Member
 
Join Date: Jan 2006
Posts: 93
ycomp is on a distinguished road
thanks... that should come in handy for something in the future, I'm sure.

I think I found the answer to my Q. just now.

http://www.metaquotes.net/forum/1290/

I tried this earlier but my mind was tied up in a knot and I realize now the mistake I made. I was using Open[shift] instead of Time[shift] for the open time parameter in iBarShift.

My brain was kind of on autopilot and in a nosedive :-)

So I'll read the article, try it again and hopefully should work.

Last edited by ycomp; 02-17-2006 at 07:23 AM. Reason: sp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-17-2006, 07:23 AM
keris2112's Avatar
Senior Member
 
Join Date: Dec 2005
Location: California, US
Posts: 129
keris2112 is on a distinguished road
Take a look at the code in the Price Channel Stop indicator that Igorad made. It should help you with what you are trying to accomplish.

http://www.forex-tsd.com/suggestions...p_v1-help.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-17-2006, 09:36 AM
Administrator
 
Join Date: Sep 2005
Posts: 15,986
Blog Entries: 70
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by ycomp
Hi,

I came across this problem before and gave up.

Now I've encountered it again while trying to code another indicator. It is a common problem so I'm sure someone must know the answer.

The question is, using iCustom or built in iIndicator functions, how do I access data from another time frame? I know that there is a time frame parameter, and I use it but the problem is that the shift is still from the current chart.

I tried dividing shift by the ratio of the time frames (e.g. 4 for accessing H1 from M15) but that didn't seem to work for me.

example:

CoolIndicator1 is running on M15. It wants to read the value of RSI for current time frame... no problem call iRSI with timeframe of 0 or PERIOD_M15.

But how do I get the value of RSI for this point in time for M30? or H1?

I tried using iBarShift( ) but that didn't work out for me. Sounds like it is the right thing to use though.

So if anyone has any code that could be of use or simply any comments that could point me in the right direction, please post.

thanks!
Just create an other indicator with this iRSI((NULL,period, ...) and in the beginning of the indicator (or EA) wrote like this;
extern int period = PERIOD_H1;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-17-2006, 02:49 PM
ycomp's Avatar
Member
 
Join Date: Jan 2006
Posts: 93
ycomp is on a distinguished road
Hi newdigital,

thanks but that won't work for me... I think that metaquotes link I posted holds the key, I'll find out when I get back to working on this indicator.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternative Time Frame in MT4 -Please ! highway3000 Indicators - Metatrader 4 3 09-05-2007 07:03 AM
Best Time Frame zamans98 Brain Systems 3 12-15-2006 06:05 PM
How to get an indicator value for another time frame ? yaniv_av Expert Advisors - Metatrader 4 2 10-31-2006 06:05 PM
Multiple Time frame Indicator rbowles Metatrader 4 9 06-22-2006 03:09 AM
2 EA in Same Pair at different time frame?? Could it possible? surya4trade General Discussion 5 06-15-2006 10:26 AM


All times are GMT. The time now is 10:38 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.