MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Find Out Why Virtual Hosting is Better than VPS

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
 
A Pause between Trades
The article deals with the problem of how to arrange pauses between trade operations when a number of experts work on one МТ 4 Client Terminal. It is intended for users who have basic skills in both working with the terminal and programming in MQL 4.
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