OK... I'll try this again. I've posted the wrong code a couple times now.
Here's the deal... I'll post the code to the ea I'm playing with, but there is no code about limiting orders to time, except, I have it only look for trading opportunities at the start of each new bar.
Which is where I think I need to add code to eliminate trading opportunities around specified times... ie when there is relevant news releases.... but I know nothing about how to code that.
//+------------------------------------------------------------------+ //| Daily BBand Scalping.mq4 | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ extern double TakeProfit1 = 35; extern double TakeProfit2 = 17; extern double StopLoss = 0; extern int maxorders = 2; extern double TrailingStop = 45; extern double Lotsfactor = 0.01; extern double MagicNumber = 3866584573; extern int BBPeriod = 20; // Bollinger Bands Period extern int Deviation = 2; // Deviation extern double shift = 0; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int ticket, ticketH, total; total=OrdersTotal(); // Calculate Lot size by available trading capital double acnteqlots=AccountEquity( ) ;//* Lots.factor; int Lotsi=acnteqlots * Lotsfactor; double Lots=Lotsi * 0.01; // double iBands( string symbol, int chart timeframe, int period, int deviation, int bands_shift, int applied_price, int mode, int shift) double upperbband = iBands(NULL, PERIOD_D1, BBPeriod, Deviation, 0, 1, MODE_UPPER, shift) ; double lowerbband = iBands(NULL, PERIOD_D1, BBPeriod, Deviation, 0, 1, MODE_LOWER, shift) ; double movabband = iMA (NULL, PERIOD_D1, BBPeriod, 0, 1, MODE_LOWER, shift) ; Comment ("\n Version = 101.00a ", "\n spread = ",DoubleToStr(Ask-Bid,5), "\n open orders = ",total, "\n Max allowagle orders = ",maxorders, "\n Next order size = ",Lots, "\n ", "\n " ); // end of displayed comments // Check for new orders ONLY on new BAR static datetime tmp; if (tmp!= Time[0]) { tmp = Time[0]; //do ur code here if(total > maxorders-1) {return(0);} // dont bother if you already have Max Orders open orders // check for long position (BUY) possibility ------------------------------------------------------------------------ if(Ask < lowerbband) {ticket =OrderSend(Symbol(),OP_BUY ,Lots,Ask,3,StopLoss,Ask+(TakeProfit1*2) *Point,"Daily Scalp Buy" ,MagicNumber,0,Green); return(0); } // check for short position (SELL) possibility --------------------------------------------------------------------- if(Bid > upperbband) {ticket =OrderSend(Symbol(),OP_SELL,Lots,Bid,3,StopLoss,Bid-(TakeProfit1*2) *Point,"Daily Scalp Sell",MagicNumber,0,Red ); return(0); } // check for long position (BUY) possibility ------------------------------------------------------------------------ if(Ask < movabband) {ticket =OrderSend(Symbol(),OP_BUY ,Lots,Ask,3,StopLoss,Ask+TakeProfit1 *Point,"Daily Scalp Buy",MagicNumber,0,Green); ticketH=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,StopLoss,Bid-TakeProfit2 *Point,"Daily Scalp Hdg",MagicNumber,0,Red ); return(0); } // check for short position (SELL) possibility --------------------------------------------------------------------- if(Bid > movabband) {ticket =OrderSend(Symbol(),OP_SELL,Lots,Bid,3,StopLoss,Bid-TakeProfit1 *Point,"Daily Scalp Sell",MagicNumber,0,Red ); ticketH=OrderSend(Symbol(),OP_BUY ,Lots,Ask,3,StopLoss,Ask+TakeProfit2 *Point,"Daily Scalp Hdg" ,MagicNumber,0,Green); return(0); } return(0); } } // ---------------- end of start ------------------------------------ // ---------------- end of program ------------------------------------ // if(total > 0) check.order(); /* //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void check.order() { int cnt, ticket, ticketa, total; // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { if(OrderType()==OP_BUY) // long position is opened { // check for trailing stop if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); return(0)(0); } } } } else // go to short position { if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0)(0); } } } } } } return(0)(0); } */ // ---------------- end of program ------------------------------------
I don't think you can expect someone will code it for you if you are not a programmer.
I suggest you to use the Jobs section.
I don't think you can expect someone will code it for you if you are not a programmer.
I suggest you to use the Jobs section.
I'm learning to code. Can someone point me to something I can read and learn from?
I certainly don't want someone to code it for me...
I'm learning to code. Can someone point me to something I can read and learn from?
I certainly don't want someone to code it for me...
There is a lot of resource to read and learn, maybe a good start is the Book. However there may be some obsolete information since the new mql4 was released.
See also Articles section.
I'm learning to code. Can someone point me to something I can read and learn from?
I certainly don't want someone to code it for me...

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How do I write a code to prevent a trade between a certain time span?
Example:
I want to enter the time of a certain news announcement. (Daily Fx lists announcement times in GMT... I think)
My broker is GMT + 2 hours.
And I am in Mountain Time Zone in USA.
So, I would like to input the date of the announcement March 4, 2014 1445 gmt.
then I want my ea to not place and order 15 min before that, and 30 minutes after. (or whatever times I choose)
Can someone help me with the code?
Thanks