how can i do this , help me !

 

i want to open buylimit or sellimit orders but at specific time only .


example : set buy limit order 1.10001 from 6 am to 9 am only after that cancel the order .


please check the code and give me the right code or correct it , please .

if((D'6:00:00'<= Time[0]<=D'9:00:00') == true)
      {
         double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL); 
   Print("Minimum Stop Level=",minstoplevel," points"); 
   double price=Ask; 
//--- calculated SL and TP prices must be normalized 
   double stoploss=NormalizeDouble(Bid-minstoplevel*Point,Digits); 
   double takeprofit=NormalizeDouble(Bid+minstoplevel*Point,Digits); 
//--- place market order to buy 1 lot 
   int ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.1,h,3,stoploss,takeprofit,"My order",0,0,clrGreen);                     
         }
         else
            Comment("false");
 
  1. if((D'6:00:00'<= Time[0]<=D'9:00:00') == true)
    D'6:00:00 is six AM of the  day you compiled. Not 6 today. Either use StringToTime or:
              Find bar of the same time one day ago - Simple Trading Strategies - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. True = 1 and false = 0 so you get
    if( 3 < 2 < 1 )
    if( false < 1 )
    if(     0 < 1 )
    if(     true  )
    if( 3 > 2 > 1 )
    iftrue > 1 )
    if(     1 > 1 )
    if(     false )
    

  3. You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.

  4. double stoploss=NormalizeDouble(Bid-minstoplevel*Point,Digits);
    Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong

  5. double takeprofit=NormalizeDouble(Bid+minstoplevel*Point,Digits); 
    //--- place market order to buy 1 lot 
       int ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.1,h,3,
    Using Points means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
              How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum

  6. Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Reason: