Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


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 (1) Thread Tools Display Modes
  #1051 (permalink)  
Old 06-30-2008, 02:28 AM
Member
 
Join Date: Sep 2007
Posts: 68
Ronald Raygun is on a distinguished road
Quote:
Originally Posted by Big Be View Post
I want to grab the highest and lowest values of an indicator over an entire chart. A while ago I tried what I thought should have worked, from within an EA, but it didn't.
(Sorry I don't have that attempt now to show you.)

Any ideas?

Big Be
using the iHighest function:

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

set the count to "Bars" so.

iHighest(NULL, 0, 3, Bars, 0);

At least that what I think would work. Just check in your chart settings how many bars you keep in history. Default I think is 52,000 bars.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1052 (permalink)  
Old 06-30-2008, 06:28 AM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
That works for price. He's wanting to find the highest and lowest of an idicator.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1053 (permalink)  
Old 06-30-2008, 07:05 AM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 345
Devil2000 is on a distinguished road
Hello,

You can try this :

Code:
....

int highest=0, lowest=0, bar=WindowBarsPerChart();

for(int shift=0;shift<bar;shift++)
 {
    double indie=iCustom(.........,shift);

    if(highest<indie) highest=indie;

    if(lowest==0) lowest=indie;
    if(lowest>indie) lowest=indie;
 } 

.....
note: this code calculating the current open candle too, if you want to calculate the closed candle only, use shift=1.

Hope this helps,
Ardie
__________________
Need a professional MQL4 programmer? PM me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1054 (permalink)  
Old 06-30-2008, 10:31 AM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 569
Blog Entries: 1
IN10TION is on a distinguished road
:: iBarShift will find for you the bar that start on that day/hour... or also the end bar for that day:hour... (depends what timeframe or chart you want to start to find your high/low).

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)

next...

:: use those bar positions to find the results of iHighest and iLowest

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)


:: results & done , don't use any loops in this!
__________________
..4.Nov.08.. IN10TION newsReader v09.85 Lite - the best news reader on your chart
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1055 (permalink)  
Old 06-30-2008, 02:35 PM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 345
Devil2000 is on a distinguished road
Programmaticaly refresh the repaint indicator

Hello,

I'm looking to find a way to refresh a repaint indicator for every x minutes.
The only way to refresh it currently, is to click in the indicator on the chart and then click "ok". Can we automate it with MQL4 code?
I found something on codersguru's site, Programmatically Refresh your charts | www.metatrader.info, but it seems not working for me. Or is there anybody has try it and get different result (working)?

Thank you
__________________
Need a professional MQL4 programmer? PM me

Last edited by Devil2000; 06-30-2008 at 02:40 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1056 (permalink)  
Old 07-02-2008, 12:28 AM
Junior Member
 
Join Date: Jul 2008
Posts: 14
IngvarDagmar is on a distinguished road
Sorry for my Englsih.

I want count number times condition is true only once per bar. Computer add up many times per bar. What wrong I do?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1057 (permalink)  
Old 07-02-2008, 01:25 AM
Senior Member
 
Join Date: Nov 2006
Posts: 215
luxinterior is on a distinguished road
Quote:
Originally Posted by IngvarDagmar View Post
Sorry for my Englsih.

I want count number times condition is true only once per bar. Computer add up many times per bar. What wrong I do?
Use a function like this...

PHP Code:
bool NewBar() {

    static 
datetime LastTime 0;

    if (
Time[0] != LastTime) {
        
LastTime Time[0];        
        return (
true);
    } else
        return (
false);

Then put an if statement round your main code, like...

PHP Code:
if(NewBar() == true){
// do the main processing here

Hope that helps.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1058 (permalink)  
Old 07-02-2008, 01:40 AM
TheRumpledOne's Avatar
Banned
 
Join Date: Nov 2006
Posts: 802
TheRumpledOne is an unknown quantity at this point
That was nice of you, Lux.

I found this:

Only process each bar once - MQL4 forum

Automated 2008.01.15 18:54 You could execute your code at the very first tick of a new bar ( i.e. right after the previous bar has closed ).
Here's a function that will return TRUE if a new bar has just formed:
// This function returns TRUE at the very first tick a bar i.e. after the previous bar has just closed
bool NewBar()
{
if(PreviousBarTime<Time[0])
{
PreviousBarTime = Time[0];
return(true);
}

return(false); // in case if - else statement is not executed
} you need to declare datetime PreviousBarTime at the beginning of your EA...
then in your code you could just use
if ( NewBar() )
{
...... code you need to be executed after a bar has closed here ....
} thank you
automatedfx@gmail.com


---------------------------------------------------

I noticed you used STATIC... I looked it up... what's the advantage of using STATIC vs a global variable?

Last edited by TheRumpledOne; 07-02-2008 at 01:55 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1059 (permalink)  
Old 07-02-2008, 06:32 PM
Junior Member
 
Join Date: Sep 2007
Posts: 1
cresp is on a distinguished road
multiple entry ea

please help. i would like to find or need help creating an ea with the following input parameters. four separate trade entries each having no. of lots, stop loss, trailing stop, break even, and profit target. trades will open upon clicking on expert advisor button.

thank you

Last edited by cresp; 07-03-2008 at 02:13 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1060 (permalink)  
Old 07-03-2008, 01:52 PM
Junior Member
 
Join Date: May 2008
Posts: 17
mancai is on a distinguished road
Need help on trailing stop option

I found this EA at MQL4 forum, quite an interesting EA.

could somebody help to add a trailing stop option which can set trailing stop only activate after the hit profit value that I set?

TheMasterMind2.mq4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading

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 Off
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 07:24 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 05:22 PM


All times are GMT. The time now is 09:10 AM.



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