MQL4 - automated forex trading   /  

Forum

Read Financial Magazines in MetaTrader 4 and MetaTrader 5!

One Order Per Day

Back to topics list To post a new topic, please log in or register
avatar
322
wackena 2006.10.11 02:52
 
Can someone help me with code that will only place one order between 0 to 24 hours? I want to code an MT4 EA to place one order per each 24 hour day. Whenever an order is triggered by EA during the day, EA can not place another order until after 24:00 Midnight.

Wackena
 
How to Use Crashlogs to Debug Your Own DLLs

How to Use Crashlogs to Debug Your Own DLLs

25 to 30% of all crashlogs received from users appear due to errors occurring when functions imported from custom dlls are executed.

avatar
97
Zonker 2006.10.13 12:44 #
 

int tradeDay=0;

int start()
{ if(tradeDay != TimeDay(curTime())) tradeDay=0;

..

if(tradeDay==0)
{ if(BuyInCondition())
{ OrderSend(..);
tradeDay = TimeDay(curTime());
}
}
}

 
avatar
322
wackena 2006.10.13 15:09 #
 
Zonker wrote:

int tradeDay=0;

int start()
{ if(tradeDay != TimeDay(curTime())) tradeDay=0;

..

if(tradeDay==0)
{ if(BuyInCondition())
{ OrderSend(..);
tradeDay = TimeDay(curTime());
}
}
}



Zonker, thanks again. You have help me before and you have done it again.

BR,
Wackena
avatar
39
cyberpasta 2007.11.28 12:46 #
 
I have a similar code and works fine, but know I want a one sell and one buy per day, I don't how code this, I've tried this, but dosen't work because this code makes only one order per day. This is only an example, I'm learning.
if(TimeDayOfYear(TimeCurrent())!=DayOfLastBuyTrade && Ask==buystart && Ask>iBands(NULL,0,20,1,0,PRICE_CLOSE,MODE_UPPER,0)){
         OrderSend(Symbol(),OP_BUY,getLotSize(),Ask,2,buystart-sl,buystart+tp,"Comment",MagicNumber,0,CLR_NONE);     
        DayOfLastBuyTrade=TimeDayOfYear(TimeCurrent());
      }
     
      
      else if(TimeDayOfYear(TimeCurrent())!=DayOfLastSellTrade && Bid==sellstart && Bid<iBands(NULL,0,20,1,0,PRICE_CLOSE,MODE_LOWER,0)){
         OrderSend(Symbol(),OP_SELL,getLotSize(),Bid,2,sellstart+sl,sellstart-tp,"CABLEBOT_v1.2",MagicNumber,0,CLR_NONE);
         DayOfLastSellTrade=TimeDayOfYear(TimeCurrent());
      }

 
Back to topics list  

To add comments, please log in or register