Restarting MT5 fires CloseOnFriday

I have to restart my MT5 terminal and all trades closed with Exit On Friday message after MT5 terminal  started.




Attachments
  • Votes +2
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

d
#1

DalFX

23.09.2022 04:20

Task created

d
#2

DalFX

23.09.2022 04:27

Attachment 20220923.log added

20220923.log
(65.42 KiB)
There is a log.
E
#3

Emmanuel

23.09.2022 07:41
Voted for this task.
b
#4

bentra

23.09.2022 13:30
Voted for this task.
d
#5

DalFX

23.09.2022 13:39
I did not mention, but ExitOnFriday is enabled for Friday 20:40 time.
TT
#6

Tamas

30.09.2022 10:32
Please attach the sqx file to reproduce the bug
TT
#7

Tamas

30.09.2022 10:32

Status changed from New to Waiting for information

d
#8

DalFX

01.10.2022 02:35

Attachment EURJPY_Strategy 21958_1H.sqx added

Attachment EURJPY_Strategy 21958_1H.mq5 added

EURJPY_Strategy 21958_1H.mq5
(240.98 KiB)
EURJPY_Strategy 21958_1H.sqx
(34.47 KiB)
g
#9

Lee Guan Chuan

04.10.2022 07:11

Status changed from Waiting for information to Fixed

It was caused by the thisFridayExitTime hasn't initialized when checking for exit.
d
#10

DalFX

04.10.2022 11:53
Is there way to fix that in existing EAs.?
g
#11

Lee Guan Chuan

04.10.2022 12:58
Hi DalFX,


There are 2 ways to solve this.

  1. You can wait for our next dev release, load the strategy into SQX and generate the code again.
  2. You modify your existing MQL5 code follow these steps.


Steps to solve it

First, open your MQL5 file

Second, search "class CExitOnFriday : public CTradingOption" and scroll down a little until you see

private:       datetime thisFridayExitTime;       datetime thisSundayBeginTime;       datetime EOFDayTime;          bool closedThisWeek;

and modify to

private:       datetime thisFridayExitTime;       datetime thisSundayBeginTime;       datetime thisDefaultTime;         datetime EOFDayTime;          bool closedThisWeek;


Third, scroll down a little until you see 

CExitOnFriday() {          thisFridayExitTime = D'1970.01.01';          thisSundayBeginTime = D'1970.01.01';          closedThisWeek = false;       }

and modify to

CExitOnFriday() {          thisDefaultTime = D'1970.01.01';          thisFridayExitTime = D'1970.01.01';          thisSundayBeginTime = D'1970.01.01';          closedThisWeek = false;       }


Fourth, scroll down a little bit until you see

if(!closedThisWeek && currentTime >= thisFridayExitTime) {

and modify to

if(!closedThisWeek && currentTime >= thisFridayExitTime && thisDefaultTime != thisFridayExitTime) {



Thank you.


Votes: +2

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please