Thread: Ask!
View Single Post
  #435 (permalink)  
Old 11-21-2006, 02:32 PM
derekc derekc is offline
Junior Member
 
Join Date: Sep 2006
Posts: 22
derekc is on a distinguished road
Place order during certain hours

I am having trouble getting my EA to place a trades when the trading hour conditions which I have set are met.

If the EA is activated during the 14th hour ie before the conditions are met it does not place the order when the time rolls over to the 15 hour.
If the EA is activated when the conditions have already been met then it opens orders fine.

It works fine if I test it with TimeMinute() instead of TimeHour() I have also tried using Hour() but no success.

Strangely enough if I use the same conditions to delete pending orders if the condition is NOT true it deletes orders when it rolls over to the next hour.

I have tried so many things now I am desperate and any help will be much appreciated.

The EA is attached to a M1 graph

PHP Code:
//+------------------------------------------------------------------+
//|    CHECK FOR BUY CONDITIONS                                                   |
//+------------------------------------------------------------------+

if( (TimeHour(CurTime())>=15 && TimeHour(CurTime())<=16))
  {     
 if(
BuyStopOrder==&& longconditions == true)
 {
    if ( 
OrderSend Symbol(), OP_BUYSTOPLotslongprice+spread
         
3longprice-(StopLoss*Point), longprice+(TakeProfit*Point), ""
         
_MagicNumber,expiration,Green ) < )
    {
        
Alert"OrderSend Error #"GetLastError() );
        return(-
1);
    }
 }   
//+------------------------------------------------------------------+
//|    CHECK FOR SHORT CONDITIONS                                              |
//+------------------------------------------------------------------+  
 
if(SellStopOrder==&& shortconditions == true)
 { 
 
    if ( 
OrderSend Symbol(), OP_SELLSTOPLotsshortprice,
         
3shortprice+spread+(StopLoss*Point),shortprice+spread-(TakeProfit*Point), "",
          
_MagicNumber,expiration,Green ) < )
    {
        
Alert"OrderSend Error #"GetLastError() );
        return(-
1);
    }
 }
    return(
0);
   } 
Reply With Quote