RSI EA trading between certain times each day

 

Hi forum,

As per the title of the thread, if I have a standard RSI EA running that I'd like to run only between a certain period of the day, is there a nice easy way of doing this? What about if I only want new positions to be limited to a time-frame but closing orders may still work?

What about if I want variations of the bot for a bunch of different currency pairs? For example, the exact same bot mechanically, I want it to run between 8am and 4pm on GBP/USD but between 2am and 10am on the JPY/NZD?

Thank you for taking the time to look at this,

CPerry.

 

You can do it in easy way. Just add EA start_hour & end_hour in your EA opening condition. Also you can specify same for specific pairs.

input int               start_hour = 8;
input int               end_hour  = 16; // 24 hour format

int OnInit(){
        
        // Set different time hour for different symbols

        if(_Symbol=="GBPUSD"){
                start_hour = 8; 
                end_hour  = 16;
        }

        if(_Symbol=="JPYNZD"){
                start_hour = 2; 
                end_hour  = 10;
        }

}

// Convert TimeCurrent() to struct

// Trade Open conditions
if(condition01 && condition02 && timecurrent.hour>=start_hour && timecurrent.hour<=end_hour){

        // Codes .......

}
 
Mahadi Hasan Razu #:

You can do it in easy way. Just add EA start_hour & end_hour in your EA opening condition. Also you can specify same for specific pairs.

Thank you very much for the reply @Mahadi Hasan Razu!

I'll add this to my code and give it a try. I'm currently building my first bot so wont be able to tell if I have it working for a few days but I just wanted to say thank you first.

CPerry.

 

@William Roeder

Thank you for the recommended reading! I'll check that out today.

CPerry.