Strategy testing MQL4 at specific times

Feb 15, 2023 at 22:13
614 개의 뷰
1 Replies
Jul 13, 2021 부터 멤버   게시물5
Feb 15, 2023 at 22:13
Hi guys when I test my martingale EA that I’ve created the strategy tester function seems to ignore my command of the EA only trading at certain hours. Any reason or solution to this would be much appreciated!
Sep 20, 2022 부터 멤버   게시물22
Feb 20, 2023 at 11:02
Can you post your function for checking the time?

Here's an example function that checks if can trade depending on the hours. Do you use days as well or just hours ?

void checkIfCanTrade() {

datetime time_now = TimeCurrent();
datetime startTime = StrToTime(inptV.start_hours);
datetime stopTime = StrToTime(inptV.stop_hours);

if (inptV.useTradingHours)
{
if (time_now >= startTime && time_now <= stopTime)
{
tickV.allowed_to_trade = true;
if (dbg) {
Print("Trading hours allowed");
}

}

else
{
if (dbg) {
Print("Trading hours NOT allowed");
}
tickV.allowed_to_trade = false;
}
}

else
{
tickV.allowed_to_trade = true;
}
}

start_hours and stop hours are declared like strings:

string start_hours = "00:00"; // Start
string stop_hours = "23:59"; // Stop

I hope this helps.
Empower your trading potential with RoboFxLearning - where knowledge meets success.
로그인 / 가입하기 to comment
You must be connected to Myfxbook in order to leave a comment
*상업적 사용 및 스팸은 허용되지 않으며 계정이 해지될 수 있습니다.
팁: 이미지/유튜브 URL을 게시하면 게시물에 자동으로 삽입됩니다!
팁: @기호를 입력하여 이 토론에 참여하는 사용자 이름을 자동으로 완성합니다.