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

 
Igor Makanu:

because you have to get used to it

You can also train yourself to always wear an umbrella, because it might rain. You can also get used to another one, but everyone hides it after every use.

 
Alexey Viktorov:

You can also accustom yourself to always walk with an umbrella, because it might rain. You can get used to another one as well, but everyone hides it after every use.

shall we talk about it?

just for starters, here it is:

c = a/b;

or

if(b!=0) c = a/b;

?

ZS: Unfortunately, I'm the only one in my family without an umbrella, I can't say anything about it, I'm always in a car, an umbrella is more of a hindrance than a help.

 
Igor Makanu:

shall we talk about it?

just for starters, here it is:

c = a/b;

or

if(b!=0) c = a/b;

?

ZS: unfortunately I'm the only one in my family without an umbrella, I can't say anything about it, I'm always in a car, an umbrella is more of a hindrance than a help

The answer was here.

Forum on trading, automated trading systems & strategy tester

Any MQL4 beginners questions, help and discussion on algorithms and codes

Andrey Sokolov, 2019.04.20 06:24

Not quite sure what to normalise here and why, when there are no mathematical operations?
What about the second example?
 
Alexey Viktorov:

The answer was here

What about the second example?

How to explain the problem... on another forum I had a similar conversation on the same topic, but there I was defending the opinion that the current price does not need to be normalized, and the opponent was making noise that even the Bid and Ask need to be normalized - I do not want to look, but the opinion of the developers was that the server prices are always correct

ok, do not normalize, it's up to you.

 
Igor Makanu:

how to explain the problem... on another forum I had a similar conversation on the same topic, but there I defended the opinion that the current price does not need to be normalized, and the opponent was making noise that even the Bid and Ask need to be normalized - I do not want to look, but the developers' opinion was that server prices are always correct

ok, don't normalise it, it's up to you

Noisy opponent is far from always right. In my opinion you should always be guided by logic and make your own decisions. And do not agitate for one or another of other people's opinions.

 
Alexey Viktorov:

A noisy opponent is not always right. In my opinion one must always be guided by logic and make his own decisions. And do not agitate for one or another of other people's opinions.

the logic - this is the developers' manual, a correct example is written, take it and usehttps://docs.mql4.com/ru/trading/ordersend

I have no information about the format in which data is sent to the server, maybe the prices are sent in text form?

i have an example in Help, so it's true - as they say in the army, luminescent means luminescent! )))

OrderSend - Торговые функции - Справочник MQL4
OrderSend - Торговые функции - Справочник MQL4
  • docs.mql4.com
[in]  Цвет открывающей стрелки на графике. Если параметр отсутствует или его значение равно CLR_NONE, то открывающая стрелка не отображается на графике. При открытии рыночного ордера (OP_SELL или OP_BUY) в качестве цены открытия могут использоваться только самые последние цены Bid (для продажи) или Ask (для покупки). Если операция проводится по...
 
Igor Makanu:

the logic - this is the developers' manual, a correct example is written, take it and usehttps://docs.mql4.com/ru/trading/ordersend

I have no information about the format in which data is sent to the server, maybe the prices are sent in text form?

i have an example in Help, so it's true - as they say in the army, luminescent means luminescent! )))

Igor, at least see an example before you start arguing.

void OnStart()
  {
//--- получим минимальное значение Stop level
   double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
   Print("Minimum Stop Level=",minstoplevel," points");
   double price=Ask;
//--- вычисленные значения цен SL и TP должны быть нормализованы
   double stoploss=NormalizeDouble(Bid-minstoplevel*Point,Digits);
   double takeprofit=NormalizeDouble(Bid+minstoplevel*Point,Digits);
//--- размещаем рыночный ордер на покупку 1 лота
   int ticket=OrderSend(Symbol(),OP_BUY,1,price,3,stoploss,takeprofit,"My order",16384,0,clrGreen);
   if(ticket<0)
     {
      Print("OrderSend завершилась с ошибкой #",GetLastError());
     }
   else
      Print("Функция OrderSend успешно выполнена");
//---
  }

After all, in the example from the documentation the price is not normalized without mathematical calculations. And in the army they also say "Hey you three, come here, both of you"... but you shouldn't imitate anyone.

 
Alexey Viktorov:

Igor, you could at least look at the example before arguing.

After all, in the example from the documentation, the price is not normalized without mathematical calculations. And in the army they also say 'Hey you three, come here, both of you'... but you shouldn't imitate anyone else.

I didn't normalize the price in my example:

ticket_sell=OrderSend(_Symbol, OP_SELL, 0.1, Bid,10,
                     NormalizeDouble(0.0,_Digits),NormalizeDouble(0.0,_Digits), "", 0, 0, clrRed);  

If you want to send a warrant as the author of the code, I won't bother you:

ticket_sell=OrderSend(NULL, OP_SELL, 0.1, Bid, 0, 0, 0, "", 0, 0, Red);  
 
Igor Makanu:

I did not normalise the price in my example :

If you want to send an order as the author of the code, I won't bother you:

Were there any examples that the broker didn't accept the correct numbers? I note that in video tutorials from reputable people they set integers in ordersend().


Perhaps the other thing is a little different in this case. I had a comparison function somehow refused to accept as equal a variable of double type and either OrderStoploss() or OrderTakeProfit() with the same values, until I normalized them both.

 
Andrey Sokolov:

Were there any examples of correct numbers not being accepted by the broker? I note that in the video tutorials from reputable people, the ordersend() is set to integers.

Perhaps the other thing is a little different in this case. I somehow had a comparison function not accept a variable of double type and either OrderStoploss() or OrderTakeProfit() with the same value, until I normalized them both.

We are probably talking about such an example:

 double x = 5/2;
 Print("x = ",x);

//ответ 
//х = 2.0
  

and it could be like this:

 double x = 5.0/2.0;
 Print("x = ",x);

//ответ
//x=2.5

I don't know if the server accepts integers, as well as authoritative people, I have long ago formed myself a library (correct in my opinion) for working with orders, here is my libraryhttps://www.mql5.com/ru/code/24829

In the file TradePanel_C#.mqh my library and the function for opening orders OrderSend_(), I write my codes in this way

TradePanel_Csharp
TradePanel_Csharp
  • www.mql5.com
Торговая панель, которая работает и в Визуализаторе Тестера.Таблица текущих ордеров/позиций.Таблица истории торгов (корректно работает на Хедж-счетах). Использование Ручная торговля в Тестере или вмешивание в работу советника (например, с целью проверки устойчивости ко внешним факторам).Ручная торговля в Терминале на демо/реальных...
Reason: