Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 496

 
Artyom Trishkin:
Stops and TPs should be set from the open price. Many traders do not set them at the open price. Hence the unequal ratio on the spread value.

I open like this

ticket=OrderSend(Symbol(),OP_BUYLIMIT,LotsByRisk(Symbol(),Risk,sl),High[2],2,0,0,magic,0)

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))


TP=NormalizeDouble(OrderOpenPrice()+tp*Point,Digits);

SL=NormalizeDouble(OrderOpenPrice()-sl*Point,Digits);

modify=OrderModify(ticket,OrderOpenPrice(),SL,TP,0);

 
Вадим Мотеюнас:

I open like this

ticket=OrderSend(Symbol(),OP_BUYLIMIT,LotsByRisk(Symbol(),Risk,sl),High[2],2,0,0,magic,0)

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))


TP=NormalizeDouble(OrderOpenPrice()+tp*Point,Digits);

SL=NormalizeDouble(OrderOpenPrice()-sl*Point,Digits);

modify=OrderModify(ticket,OrderOpenPrice(),SL,TP,0);

This is your case, you don't consider the Spread, i.e. market rules: open at Ask, close at Bid. Open at Bid, close at Ask

 

Alternatively, find a pair with a very large spread to get a quick understanding. Next, run the Expert Advisor in the Strategy Tester and activate the Ask line. See how and at what levels the stops and profits are triggered.

Hopefully you will quickly realise what the problem is.

 
Vitaly Muzichenko:

This is exactly your case, you do not take into account the Spread, i.e. market rules: open at Askk, close at Bid. Opening at Bid, closing at Ask

Well, this is clear, but it turns out I do not take it into account for stop and takeout, i.e. profit and loss should be directly proportional to the value of spread? but then why the difference in risk-reward I do not understand, with the same costs
 
Vitaly Muzichenko:

Alternatively, find a pair with a very large spread to get a quick understanding. Next, run the Expert Advisor in the Strategy Tester and activate the Ask line. See how and at what levels the stops and profits are triggered.

Hopefully you will quickly realise what the problem is.

When hovering over take and stop, if you try it on a demo, the stop and take calculation is correct in money
 
Hello. Maybe someone can tell me what the reason is. I have a portfolio of 20 Expert Advisors for 7 currency pairs with orders open on a new candlestick, but for some reason they do not make any trades, although in the strategy tester it seems that they do. Thank you.
 
ivanskyy:
Hello. Maybe someone can tell me what the reason is. I have a portfolio of 20 Expert Advisors running on 7 currency pairs and opening orders on a new candlestick, but for some reason trades are not executed, although in the strategy tester it looks like the trades are executed. Thank you.

Were the magazines looked at? Have you been allowed to trade? And what does it mean

the trades are kind of happening.

Do trades occur in the Strategy Tester or not? There is no third state.
 
Ihor Herasko:

Were the magazines looked at? Have you been allowed to trade? And what does it mean

So are trades being made in the tester or not? There is no third state.
Journal and everything else is set up, trades are made in the tester
 
ivanskyy:
The log and everything else is set up, the tester's making trades.
Excuse me, how did you get the log set up?
Where did you set it up? Tell me, it's interesting.
 
ivanskyy:
The log and everything else is set up, in the tester performed transactions

Run Expert and see what it says in the logs: "Experts" tab and "Logbook" tab. There will most likely be an answer to the question there. If you don't understand it yourself, post the contents of the logs here.

You've gone too far with the settings )).

Reason: