How to make the Expert to trade only on a specific time?

 

Hello,
I want my expert to NOT trade between 12am till 10am. How can I do that?


Thanks

Damati

 
Mohammad Damati: How can I do that?
You code it to do that.
  1. MT4: Learn to code it.
    MT5: Learn to code. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  2. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
Get the current time, see if it is between 0 and 10*3600
          Find bar of the same time one day ago - Simple Trading Strategies - MQL4 programming forum
 
William Roeder:
You code it to do that.
  1. MT4: Learn to code it.
    MT5: Learn to code. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  2. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
Get the current time, see if it is between 0 and 10*3600
          Find bar of the same time one day ago - Simple Trading Strategies - MQL4 programming forum

I am talking about the code!! (MQL4). I have done my expert but still missing how to make it trade on a time frame.


Stop selling yourself. If you got an answer just say it. We all know that we can Hire a freelancer as I have done this before :) 

 
Mohammad Damati:

Hello,
I want my expert to NOT trade between 12am till 10am. How can I do that?


Thanks

Damati

hi
Try this code.
Files:
exampel_20.PNG  23 kb
 
Roozbeh Morad Nia:
hi
Try this code.

Your function will never return true.

Please use the code button or Alt + S and paste code instead of an image.

 
Keith Watford:

Your function will never return true.

Please use the code button or Alt + S and paste code instead of an image.

hi
This code is used to control the trading time.


void OnTick()
  {
   if(Hourfilter()== true)
   int tiketbuy=OrderSend(Symbol(),OP_BUY,lot,Ask,Slippage,Ask-(StopLoss*Point),0,"R1",1111,0,clrBlue);
   
  }
//+------------------------------------------------------------------+
bool Hourfilter()
{
   if(Hour()>=strattime && Hour()<=endtime)
   return(true);
   
   else
   return(false);
}

 
Roozbeh Morad Nia:

hi
This code is used to control the trading time.


//+------------------------------------------------------------------+
bool Hourfilter() 
{
   if(Hour()>=strattime && Hour()<=endtime) 
   return(true);
    
   else
   return(false);
}

Your code will fail with starttime 10, endtime 2 for example.

 
Enrique Dangeroux:

Your code will fail with starttime 10, endtime 2 for example.

I wrote a comprehensive code.
This code can be customized.
This code is used for simple ea models.
Set the start time to 2 and the end time to 10, or vice versa.

For example for the first question Mohammad Damati:
10 am till 12 am not trade.
This code can be written in hundreds of ways.
I use this model for my own code.
Friends If you have other models please write in this post for training

//+------------------------------------------------------------------+
bool Hourfilter() 
{
   if(Hour()>=12 && Hour()<=10) 
   return(true);
    
   else
   return(false);
}
 
Roozbeh Morad Nia:

I wrote a comprehensive code.
This code can be customized.
This code is used for simple ea models.
Set the start time to 2 and the end time to 10, or vice versa.

For example for the first question Mohammad Damati:
10 am till 12 am not trade.
This code can be written in hundreds of ways.
I use this model for my own code.
Friends If you have other models please write in this post for training

Thank you very much. The exact code is not working. BUT I have took the idea and the below code works well for me:


           (Hour()>=10)

   &&(Hour()<=23)


Without the bool and also it will continue the 'IF' once its >10 and <23


Thanks again and cheers

 
Roozbeh Morad Nia:

I wrote a comprehensive code.
This code can be customized.
This code is used for simple ea models.
Set the start time to 2 and the end time to 10, or vice versa.

For example for the first question Mohammad Damati:
10 am till 12 am not trade.
This code can be written in hundreds of ways.
I use this model for my own code.
Friends If you have other models please write in this post for training

You are not listening. Your logic is flawed.

if(Hour()>=12 && Hour()<=10) 
   return(true);

Please give me one value for Hour() where this will return true.

 
Keith Watford:

You are not listening. Your logic is flawed.

Please give me one value for Hour() where this will return true.

Hi
Sorry
I understand what you mean now.
hour () means local time.
Here the system checks if the time is right, trades.
This time model works only on ea that is unique to us.