Enter at limit/stop order issue. Placing stop loss/ take profit issue on mt 5 [VAW-TVLOD-440]

dev v 1 127

Just added this problem here. As i understand it was not fixed or there is a still problem.

All files and description you could find in email.
Ticket [VAW-TVLOD-440]

Attachments
No attachments
  • Votes 0
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

VO
#1

GRoundofInferno

23.04.2020 07:07

Task created

TB
#2

Tomas Brynda

23.04.2020 10:31

Status changed from New to Waiting for information

Hi GroundInferno,

have you sent us the right strategy? In this task you are writing about a limit strategy, but the Strategy 06242 - Optimized 03023.sqx provided uses market orders.


Best regards,

Tomas




VO
#3

GRoundofInferno

23.04.2020 10:44

Attachment Strategy 0160.mq5 added

Attachment Strategy 02443.mq5 added

0.160 does not work as it uses limit orders.

0.2443 use market orders 

TB
#4

Tomas Brynda

23.04.2020 10:52

Attachment Strategy 0160_modified.mq5 added

Attachment Strategy 02443_modified.mq5 added

Thank you.


On another symbol it seems to be working fine. Maybe this problem is symbol-related.

Please try these modified EA's I am attaching, it may solve the problem.

VO
#5

GRoundofInferno

23.04.2020 11:12
Did not help, unfortunately.

I have added log file 

https://www.dropbox.com/s/8sow9iurmt6ompi/20200423.log?dl=0

TB
#6

Tomas Brynda

23.04.2020 11:40

Status changed from Waiting for information to In progress

Thank you, I will analyze it further
TB
#7

Tomas Brynda

23.05.2020 16:17

Status changed from In progress to Waiting for information

Hi GRoundofInferno,

could you create a demo account of your broker for me?


I was trying to create it myself so I could make tests directly on the SBER symbol, but the broker has refused my request, because they don't support clients from EU.


Thank you


Best regards,

Tomas

VO
#8

GRoundofInferno

23.05.2020 16:26
Sure. I will come back on Monday morning with a solution for you. 
VO
#9

GRoundofInferno

25.05.2020 12:51
It is very weird.  

I have just generated a strategy for Brent futures which has quite the same setting as Sber stocks. And it works correctly. However, the same strategy does not work on Sber. Something particular wrong with symbol or share. 

Unfortunately, Demo account has only futures and not stocks. We can arrange TeamViewer session, so you can check a problem on my non-demo account.

Please let me know what the option will be best for you.


VO
#10

GRoundofInferno

25.05.2020 13:25
just double-checked. It works with futures and indices. And does not work with stocks.
TB
#11

Tomas Brynda

25.05.2020 14:11

Attachment Strategy 02443_modified2.mq5 added

Hi,

thank you very much for your willingness. I was going through another metatrader forum posts and I found another possible solution.

Could you try one more version of the original strategy? It is attached. 


If it doesn't help neither, then we can set up some TeamViewer session tomorrow and I will try directly on your account.


Best regards,

Tomas

VO
#12

GRoundofInferno

25.05.2020 14:37
I am delighted to share that it backtested and placed stop-loss and take-profit correctly on live account. The only doubt is how this strategy enters the trade. It opened position as market as soon as I added without waiting enter at stop or enter at limit. As I previously remember there where less issues with strategies used market enters then stop or limit enters.

We need to double-check that the bag with entering at stop or at limit is fixed. 

TB
#13

Tomas Brynda

25.05.2020 15:01

Status changed from Waiting for information to Fixed

I'm glad to hear that it trades finally :)


This one is a market stategy, it doesn't use pending orders. 


I will add a new parameter ExpirationTime into MQL code so that expiration (which was the problem in this case) can be set for stock symbols.

It will be in minutes and set to 0 by default as trading on most of the symbols will be working fine without it.

If trading SBER, you would need to set this parameter to some value higher than zero in the EA.

The change will be present in the upcoming release of build 129.


Thank you very much for your cooperation.


VO
#14

GRoundofInferno

25.05.2020 15:13

Attachment Strategy 01313.mq5 added

Could you please fix this strategy with pending orders so we will be sure that everything is right.

Also how to determine the correct expiration time ?

TB
#15

Tomas Brynda

25.05.2020 15:35

Attachment Strategy 01313_modified.mq5 added

Ok, here it is.


You can try to set expiration time to 1440 (one day)

VO
#16

GRoundofInferno

25.05.2020 15:46
Tomas, I am afraid that we did not fight this problem. As I thought I have a straight line in the tester with pending orders strategy. 
TB
#17

Tomas Brynda

25.05.2020 15:54

Status changed from Fixed to In progress

Can you send me a log file from your terminal?
VO
#18

GRoundofInferno

25.05.2020 16:03
sent to the support email
TB
#19

Tomas Brynda

25.05.2020 16:16

Attachment screen.png added

Ok from the logs I can see that you didn't set up the Order expiration time.

Please set it to 1440 in Expert input parameters and let me know if it helped.

VO
#20

GRoundofInferno

25.05.2020 16:38

Attachment exptime.png added

I have changed in the code. Recompile. But it is still 0 in the logs and 1440 in code and in input parameters in MetaTrader.  Does not work yet. Maybe you could add 1440 by yourself.
TB
#21

Tomas Brynda

25.05.2020 16:49

Attachment screen.png added

You probably have a zero set in your EA's input parameters.

The MQL code variable value gets overwritten by EA settings during backtest.


Please check the attached screenshot.

VO
#22

GRoundofInferno

25.05.2020 17:08

Attachment 20200525.log added

Attachment exptime2.png added

found. doesn't work. Here is new logs and screenshot 
TB
#23

Tomas Brynda

26.05.2020 09:04

Thank you for the attached log. Can we make the TeamViewer session so I could test it directly on your broker?


If so please send your TV ID to support email and let me know what time is good for you. 

VO
#24

GRoundofInferno

26.05.2020 13:13
unfortunately, my broker said that it wouldn't help. everything works from their side and no restrictions for pending orders for me. Suggested to write to the strategy developers. 
TB
#25

Tomas Brynda

18.06.2020 11:13

Status changed from In progress to Fixed

Ok, the strategy backtests are working both with market and stop orders, but the correct expiration type must be used.

One of the strategies that did not work contains a weird source code, so that's probably the problem.


We could add some kind of automatic expiration type detection into the MQL code, I created a new feature task for this - https://roadmap.strategyquant.com/tasks/sq4_6530


For market orders, it is enough to set ExpirationTime to 60 in EA parameters. (Available from B129)

For stop/limit orders you must manually modify the EA's code to make it work on problematic symbols. You must do these changes in the MQL code:

  • Open up the MQL code of the strategy and replace these two lines:

const ENUM_ORDER_TYPE_FILLING preferredFillingType = ORDER_FILLING_FOK;         //preferred filling type - will be applied if available const bool forceFillingType = false;                                            //if set to true, it will force using preferredFillingType when opening orders

with this:


const ENUM_ORDER_TYPE_FILLING preferredFillingType = ORDER_FILLING_RETURN;         //preferred filling type - will be applied if available const bool forceFillingType = true;  

  • Go to the openPosition method (press CTRL+F, type in "ulong openPosition" and press Enter). The replace this code inside openPosition method:

if(expiration > 0){       mrequest.type_time = ORDER_TIME_SPECIFIED;       mrequest.expiration = TimeCurrent() + expiration * 60;      }    else {       mrequest.expiration = 0;    }

with this:


mrequest.type_time= ORDER_TIME_DAY; mrequest.expiration = TimeCurrent()+PERIOD_M30*60; 



Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please