Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1582

 
MrBrooklin #:

What is highlighted in yellow is that we first declared the price variable and assigned the Ask price value to it, and literally after the line where the order type is checked, the Bid value is assigned accordingly.

Question - why can't we assign Bid at the stage of declaring the price variable at once, or is there some sacred meaning here?

If you assign Bid at once, you will still have to check the order type and assign Ask :-)

The price variable should be assigned one of two values depending on the order type. The initial one is Ask, and if the type does not fit, it is changed to Bid.

it's just that code authors don't like the triple operator : double price=(orderType==ORDER_TYPE_SELL?Bid:Ask) ; // so shorter and clearer in my opinion.

 
Maxim Kuznetsov #:

If you assign Bid at once, you will still have to check the order type and assign Ask :-)

The price variable should be assigned one of two values depending on the order type. The initial one is Ask, if the type does not fit, change it to Bid.

it's just that code authors don't like the triple operator : double price=(orderType==ORDER_TYPE_SELL?Bid:Ask) ; // so shorter and clearer in my opinion.

Thank you, Maxim, for your help! Now everything is clear and logical. It turned out like this:

//--- получим цену открытия
   MqlTick mqltick;
   SymbolInfoTick(symb, mqltick);
   double price = (type == ORDER_TYPE_SELL ? mqltick.bid : mqltick.ask);

Two lines less, but more understandable. ))

Regards, Vladimir.

 
Vitaly Muzichenko #:

And if EA is set on more than one pair?

OrderCheck() is more reliable.

I don't understand, is the second line a statement or what?

Well, what difference does it make how many pairs the EA is installed on? Each code is executed separately. Let even on one symbol, on different charts, with different mags will be installed... No problem....

 
MrBrooklin #:

Hi Alexey, I understand your option, Vitaly's hint is also reasonable.

But still! That code is taken from an article written by MetaQuotes specialists, and I have no reason not to trust them. I just had a question that I would like to get an answer to. ))

Regards, Vladimir.

MQ specialists are people too and it is also natural for them to get tired and make some "mistakes" which do not affect the code performance.

 
Alexey Viktorov #:

MQ specialists are people too and they also tend to get tired and make some "mistakes" that do not affect the code's performance.

So in fact there is no error, it's just that the code is written in such a way that I didn't "get into" its essence at once and that's why I tried to understand it. )) Maxim explained everything clearly. In short, a big THANK YOU to everyone!!!

Regards, Vladimir.

 
please help me to understand why the template is not working
 
Good afternoon!

Please help me understand the problem of lack of repeatability in the strategy tester on a ruble netting account with a deposit of 800,000 rubles.

I run the robot on the M1 timeframe on monthly quotes and get a profit of 318,139.

Without changing anything, I run it again and get a profit of 73,246.

Without changing anything, I run the robot again and get a profit of 73 246.

Without changing anything, I rerun and make a profit of 73 246. (this is always repeated when I rerun).


I switch the timeframe in the tester to M4 and run. Profit 287,513.
I switch the timeframe to M1 and run. Profit again 318 139.

Without changing anything, I run again and again get a profit of 73 246.

And so it repeats.


Instead of switching to M4, recompiling the robot also helps.


Why is there no repeatability at a direct re-run?

But on the dollar account there is no such problem, the result is always repeated.

Regards, Alexander
 
Help ! Order window ! Tick chart together does not open!
Good evening ! Actually everything is in the title of the topic .What is wrong ? At the beginning of the opening everything was normal .Where did I uncheck? I open a new order only the order window and the tick chart does not open.
Помогите ! Окно ордера ! Тиковый график совместно не открывается!
Помогите ! Окно ордера ! Тиковый график совместно не открывается!
  • 2025.04.15
  • Heik
  • www.mql5.com
Добрый вечер ! Собственно все в названии темы .Что не так то ? В начале открывался все нормально .Где я какую галочку убрал...
 
Heik #:
Help ! Order window ! Tick chart together does not open!
Good evening ! Actually everything is in the title of the topic .What is wrong ? At the beginning of the opening everything was normal .Where did I uncheck? I open a new order only the order window and the tick chart does not open.

Double-click in an empty space of the order window to enable/disable the display of ticks in the order window.

Actually, this double-click can be done anywhere in the order window, as long as it is not on the "sell/buy by market" buttons ;-)

 

Please help me, stop points do not work when debugging. No matter which stop point I set, the whole programme is executed after debugging is started. How to make stop points work?