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
  #211 (permalink)  
Old 03-18-2007, 09:30 PM
xxDavidxSxx's Avatar
Senior Member
 
Join Date: Jul 2006
Posts: 745
xxDavidxSxx is on a distinguished road
Try this....


{
string expire_date = "2007.10.22";
datetime expirevar = StrToTime(expire_date);

if ( CurTime() >= expirevar )
{
Alert ("Version Expired");
return(0);
}
// code
return(0);
}


Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #212 (permalink)  
Old 03-18-2007, 09:39 PM
Junior Member
 
Join Date: Apr 2006
Posts: 28
Mis B. Havin' is on a distinguished road
Quote:
Originally Posted by islandrock
I cant seame to place a time limit on my EA
code line is as follows:
OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0, Ask+TakeProfit*Point,"timetest",16384,0,Green)
I've tried changing that ZERO to a 1 or to a 12 and i can't get it to stop the trade ... i would like to have the trade expire in 12 hours how can i do this?
i'm useing a backtesting. to nake sure it works.. the expire function does work with that right?

check ther error channel;

Quote:

Applying of pending order expiration time can be disabled in some trade servers. In this case, when a non-zero value is specified in the expiration parameter, the error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated.
the parameter is a 'datetime' variable I dont beleive that 12 will fall within that variable declaration.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #213 (permalink)  
Old 03-18-2007, 09:41 PM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by islandrock
I cant seame to place a time limit on my EA
code line is as follows:
OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0, Ask+TakeProfit*Point,"timetest",16384,0,Green)
I've tried changing that ZERO to a 1 or to a 12 and i can't get it to stop the trade ... i would like to have the trade expire in 12 hours how can i do this?
i'm useing a backtesting. to nake sure it works.. the expire function does work with that right?
Hi. Expiration timeouts work fine with MT, the only caveat being that some brokers don't allow them - FXDD is one. The expiration time needs to be in datetime format for it to work - ie.

Code:
datetime ExpirationTime = StrToTime(TimeYear(Time[0]) + "." + TimeMonth(Time[0])+ "." + TimeDay(Time[0])+" "+23+":"+55);
OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,Ask+TakeProfit*Point,"timetest",16384,ExpirationTime,Green);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #214 (permalink)  
Old 03-18-2007, 10:44 PM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
Question i've been trying this.

extern int TradeLifeHour=12;
extern int TradeLifeMin=00;

datetime expirationtime; (did'nt know what goes here)

then within start()

expirationtime = CurTime()+TradeLifeHour*60*60+TradeLifeMin*60;
and use expirationtime in the 0 area.

i the last code but i dont know how to config it to expire the trade in 12 hours

Last edited by islandrock; 03-18-2007 at 10:50 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #215 (permalink)  
Old 03-18-2007, 10:56 PM
xxDavidxSxx's Avatar
Senior Member
 
Join Date: Jul 2006
Posts: 745
xxDavidxSxx is on a distinguished road
Quote:
Originally Posted by xxDavidxSxx
Try this....


{
string expire_date = "2007.10.22";
datetime expirevar = StrToTime(expire_date);

if ( CurTime() >= expirevar )
{
Alert ("Version Expired");
return(0);
}
// code
return(0);
}


Dave
I just used the code I gave you. I changed the date to 2006 and slapped it in a random place inside Bipoler on a real money FXDD account, and it worked like a charm.

Or mabe mines too simple? I dunno

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #216 (permalink)  
Old 03-18-2007, 11:21 PM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
Exclamation ??

that code does not make each trade my EA opens expire 12 hours from the time it opens...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #217 (permalink)  
Old 03-19-2007, 10:07 AM
Wackena's Avatar
Senior Member
 
Join Date: May 2006
Posts: 216
Wackena is on a distinguished road
Quote:
Originally Posted by islandrock
that code does not make each trade my EA opens expire 12 hours from the time it opens...
Order expiration time works on pending orders only. If OrderSend() is OP_BUY or OP_SELL, you need to time your order within the code. Here is one simple example.

Code:
int OrderTime;

OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask+TakeProfit*Point,"timetest",16384,0,Green)
OrderTime=TimeCurrent();


int total = OrdersTotal();
for(int cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if((OrderType() <= OP_SELL) && (OrderSymbol() == Symbol()) )
{
if(OrderType()==OP_BUY && TimeCurrent()-OrderTime>(12*60)*60)
{
OrderClose(OrderTicket(),LotsOptimized(),Bid,3,Violet);
}
}
}
Wackena

Last edited by Wackena; 03-19-2007 at 10:10 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #218 (permalink)  
Old 03-21-2007, 01:24 PM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
code not function right

I used this to email the status of my account every hour to me. however after i compile and loaded it. it sent that email perfectly the next hour at minute# 59 as it's supposed to then it never sent another one again. what i'm i doing wrong? it looks perfect ?
i dont need it at min #59 i just need it every hour!!




bool mail;
int start()


{
if (Minute()>=59 && !mail){
SendMail("Account Status", "Account Balance is="+DoubleToStr(AccountBalance(),2)+"_Account Equity is="+DoubleToStr(AccountEquity(),2)+
"_Account Profit is="+DoubleToStr(AccountProfit(),2)+"_Account Margin is="+DoubleToStr(AccountMargin(),2)+
"_Account Free Margin is="+DoubleToStr(AccountFreeMargin(),2));
mail=true;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #219 (permalink)  
Old 03-21-2007, 01:32 PM
jlpi's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 293
jlpi is an unknown quantity at this point
maybe you just need to put mail = false at some point or just remove this test on mail variable because of course the current code will send only 1 mail.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #220 (permalink)  
Old 03-21-2007, 01:41 PM
islandrock's Avatar
Member
 
Join Date: Jan 2007
Posts: 87
islandrock is on a distinguished road
what test on mail variable ?.. i do not under stand please explain..
how about right after mail=true i put

if (minute()<=58 && !mail)
mail= false;

think that might work?...
i think it's coded wrong
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 06:03 AM.



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