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
  #281 (permalink)  
Old 07-15-2007, 10:16 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
I think ejoi made a slight mistake with the stringifying part; the code should have been like:

PHP Code:
double price iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0);

if (
price=>1.0000 && price1.0050
{
sell order here

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #282 (permalink)  
Old 07-16-2007, 03:28 AM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
thanks

thanks that worked great!!!

Last edited by islandrock; 07-16-2007 at 03:46 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #283 (permalink)  
Old 07-16-2007, 03:59 AM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
it seems that i also have this problem if anyone can help. i'm trying to limit the time that trades can be opened.


PHP Code:
total=OrdersTotal();
  if (
total<1
   {
      
      
      if (
TimeHour(CurTime())<StartHour) {return(0);}
      if (
TimeMinute(CurTime())<StartMinute) {return(0);}
      
      
      if (
TimeHour(CurTime())>EndHour) {return(0);}
      if (
TimeMinute(CurTime())>EndMinute) {return(0);}
   } 
it seems right that no trades are executed whenever i use it
my extern is as follows
PHP Code:
extern int StartHour=0;
extern int StartMinute=30;
extern int EndHour=22;
extern int EndMinute=30
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #284 (permalink)  
Old 07-16-2007, 04:14 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
You might add the following function
PHP Code:
bool isTradableTime()
{
    
datetime time TimeCurrent();
    
int now TimeHourtime ) * 60 TimeMinutetime );
    
int begin StartHour 60 StartMinute;
    
int end EndHour 60 EndMinute;

    return ( 
begin <= now && now end );

and then use it like the following in your start() function
PHP Code:
if ( ! isTradableTime() )
    return( 
); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #285 (permalink)  
Old 07-16-2007, 04:17 AM
Senior Member
 
Join Date: Feb 2006
Posts: 525
Michel is on a distinguished road
If the trading period does not include midnight:
PHP Code:
total=OrdersTotal();
  if (
total<1
   {
      
      if(
Hour()<StartHour) return(0);
      if(
Hour()==StartHour && Minute()<StartMinute) return(0);
      if(
Hour()>EndHour) return(0);
      if(
Hour==EndHour && Minute()>EndMinute) return(0);

   } 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #286 (permalink)  
Old 07-16-2007, 04:57 AM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
Quote:
Originally Posted by Michel View Post
If the trading period does not include midnight:
PHP Code:
total=OrdersTotal();
  if (
total<1
   {
      
      if(
Hour()<StartHour) return(0);
      if(
Hour()==StartHour && Minute()<StartMinute) return(0);
      if(
Hour()>EndHour) return(0);
      if(
Hour==EndHour && Minute()>EndMinute) return(0);

   } 
thank you both...i went with this one becuase i liked the simplicity of it and it works great....

thank you again
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #287 (permalink)  
Old 07-17-2007, 12:10 AM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
new question

does any one know how to code into an EA if a trade exsist already do not open a second one unless it's 10 pips apart?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #288 (permalink)  
Old 07-22-2007, 04:04 PM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,000
fxbs is on a distinguished road
Dear Expert Advisors! pl. advise on refreshing buffers code

Dear Experts Advisors! Please give me advise on refreshing buffers (just good advise)


there is code (patch, fix, upgrade) by Raff 4 multitimeframe (MTF) indicators, working pretty good;
what could be similar code you can add to regular (not mtf) indicators?

If possible, please, give example,
thank you


//---- Refresh buffers +++++++++++++++++++++ upgrade by Raff
if (TimeFrame>Period()) {
int PerINT=TimeFrame/Period()+1;
datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period( ));
for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
/************************************************** ***
Refresh buffers: buffer[i] = buffer[0];
************************************************** ****/

Buffer1[i]= Buffer1[0];
Buffer2[i]= Buffer2[0];
Buffer3[i]= Buffer3[0];

//----
} } }
//+++++++++++++++++++++++++++++++++++++++++ Raff ++++++
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #289 (permalink)  
Old 07-30-2007, 05:08 AM
iscuba11's Avatar
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 400
iscuba11 is on a distinguished road
Smile Code to Pause between actions in an EA Needed

What is the proper way to put a pause statement in an EA? Would it be the same for an indicator??

Dave
<><<<
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #290 (permalink)  
Old 07-30-2007, 05:21 AM
Member
 
Join Date: Feb 2006
Posts: 35
flexie is on a distinguished road
sleep(1000);

1000 is 1000 milliseconds, or 1 second.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
CHinGsMAroonCLK, I_XO_A_H

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 06: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 04:22 PM


All times are GMT. The time now is 03:05 PM.



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