MQL4 and MQL 2
  #1 (permalink)  
Old 05-01-2006, 06:38 PM
Freshman
 
Join Date: May 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
karan is on a distinguished road
Question MQL4 and MQL 2

I wrote a custom indicator in MQL4 and need to write this in MQL2. Why, you might ask... I am using mtapi.dll from C# and I want to see this indicator on the MetaTrader 3 platform (FXDD account).

I want to be able to get the last day's close, low and high. On the surface you can do this using Close[1], Low[1], High[1]. But when you change the time frame to say 5 minutes, the Close[1] returns (as expected), the close of the previous 5 minute interval.

IN MQL4 you can do:

double prevLow = iLow(NULL, PERIOD_D1, 1);
double prevHigh = iHigh(NULL, PERIOD_D1, 1) ;

double open = iOpen(NULL, PERIOD_D1, 0);


Does anyone know how to do this in MQL2. This type of functionality seems to be missing where you can lock in a timeframe for getting Low[1], etc.


Thanks for all your help. I am new to this forum but quite impressed with the previous posts on this forum.
Reply With Quote
  #2 (permalink)  
Old 05-02-2006, 08:03 AM
scorpion's Avatar
Administrator
 
Join Date: Aug 2004
Posts: 1,982
Thanks: 122
Thanked 383 Times in 152 Posts
scorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to behold
Send a message via MSN to scorpion Send a message via Yahoo to scorpion
Default

You can use High[] and Highest() to emulate the iHigh() function. And Low[] and Lowest() to emulate iLow().

Syntax: Highest(type,beginbar,periods)
Description: Returns the shift of the maximum value over a specific number of periods depending on type.

Says, you want to emulate iHigh(NULL, PERIOD_D1, 1) on 1H chart at 23 o'clock. You can use High[Highest(MODE_HIGH,47,24)]. Be sure to calculate the beginbar correctly.


For iOpen() and iClose(), you can use Open[] and Close[] to do the job. Simply you just calculate the correct bar. E.g. Open[47] on 1H chart at 23 o'clock simply gets the Open Price of yesterday.

Hope this helps
__________________
Make easy pips with the Advanced Economic Calendar for Forex Trading.
Reply With Quote
  #3 (permalink)  
Old 05-02-2006, 09:02 AM
scorpion's Avatar
Administrator
 
Join Date: Aug 2004
Posts: 1,982
Thanks: 122
Thanked 383 Times in 152 Posts
scorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to beholdscorpion is a splendid one to behold
Send a message via MSN to scorpion Send a message via Yahoo to scorpion
Default

And...

Congratulations! You are the 1000th member! You are a milestone, Karan!

You must be an elite programmer from India, right?
__________________
Make easy pips with the Advanced Economic Calendar for Forex Trading.
Reply With Quote
  #4 (permalink)  
Old 05-06-2006, 09:14 PM
Freshman
 
Join Date: May 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
karan is on a distinguished road
Default

Quote:
Originally Posted by scorpion
And...

Congratulations! You are the 1000th member! You are a milestone, Karan!

You must be an elite programmer from India, right?
What a coincidence... 1000th member!

I was born in India. But I have settled in the USA for many years.
And thanks for all your help.
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:33 PM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0

Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now

Main Menu

Economic Forecast