Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


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 05-16-2006, 08:37 PM
smoisb smoisb is offline
Junior Member
 
Join Date: Apr 2006
Posts: 1
smoisb is on a distinguished road
Unhappy problem with sleep() function

I’m trying to get my expert to sleep after a loss trade,
For some reason it doesn't work.

I’ve already checked that the proper order was selected.

The script looks like this:

int i=HistoryTotal();
OrderSelect(i,SELECT_BY_TICKET);
if(OrderProfit()<0)
{
Sleep(900000);
}
If any one has experience with this function and has an idea what the problem is I’d appreciate your kind help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-19-2006, 11:22 AM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
Sleep doesn't seem to work

Hi
I am also having problems with sleep (lol).
I find it doesn't work - definetly not when using stratergy tester to test an ea, so I set a variable to the time I want my expert to sleep and then check that variable

Code:
if (CurTime()< time1)
   {
     return(0);
   }
else
  {
   Sell1();
   Print("SELL order opened : ",OrderOpenPrice());
  time1 = CurTime()+2*60*Period();  
  }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-20-2006, 04:10 AM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
that doesn't even work

But I am finding even that does not work
Weird
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-20-2006, 04:40 AM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
working

Found that you can't initilize time in the init() section

So go like this

Code:
static double time1=0;

...
void init()
{
return(0)
}

int start()
{

 if (CurTime()<= time1)
  {
  //Print(" Cur: ",TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS)," time1:  ",TimeToStr(time1,TIME_DATE|TIME_SECONDS));
    
    return(0);
  }

   SellOrdOpen();
   time1 = CurTime()+360;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sleep function in EA between orders icek Metatrader 4 2 06-11-2007 04:10 PM
Programming question - sleep after a loss trade. aleksd Expert Advisors - Metatrader 4 12 08-12-2006 03:42 AM
function request Alex.Piech.FinGeR Metatrader 4 10 01-06-2006 06:08 PM


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