MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Update to MetaTrader 4 build 735 and Test the VPS for Free

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
 
Changing the External Parameters of MQL4 Programs without Restarting
The article describes a method of changing the external parameters of MQL4 programs on-the-fly, without restarting.
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