Difficulties of translation :) - page 4

 
Alexey Volchanskiy:

You're welcome. But I wrote that I'm a lazy kitty))

That's the reason I don't pull the devil by the balls every time, but keep the order data in class.

Purely on a question: presumably you wanted to review positions, not warrants? М... I would have done things differently, but the live feed is something like this

I have 40 of these functions in my template for all occasions. I have them separately for orders, and separately for positions. They are very fast to work with; we use those that we need in our EA and in addition, we can extend or modify the algorithm of the EA in a couple of minutes. That is why I use the functions within one file and do not need to connect anything additionally.

Yes, I would like to review the positions and, if possible, the orders as well, that would be great)

Aleksey, if you have time and desire after the night walk please write it, I will look how it should look like and I will rewrite everything by analogy.

Thanks!

//==================

P.S. while writing, you gave an answer)

(c) why do you have to put all sorts of shit afterinserting code!!!!

It's to know what function, like a comment, there are a lot of them

Thanks for the answer, I'll keep digging ))))

 
Alexey Volchanskiy:

You're welcome. But I wrote that I'm a lazy kitty))

That's the reason I don't pull the devil by the balls every time, but keep the order data in class.

Purely on a question: presumably you wanted to review positions, not warrants? М... I would have done things differently, but the live feed is like this

Stupid site crashed it again, I'll go to reddit, it's all clear there.

****************** stupid website !!!!!!!!!!!!!!

why do you have to put shit after you put in code!!!!

No Alexey, that's not quite right. PositionSelect(Symbol()) will select the same position. That's fine for netting.

Here's a piece with unpaired brackets too, everyone here understands

    for(i = 0; i < PositionsTotal(); i++)
     {
      if(PositionGetTicket(i) > 0 && PositionGetString(POSITION_SYMBOL) == Symbol() && PositionGetInteger(POSITION_MAGIC) == magic)
       {
        if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY || PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
         {
 
Vitaly Muzichenko:

Yes, wanted to take a look at the positions and if you can, the orders too, that would be super)


For pending orders it would be almost the same

    for(i = 0; i < Orders Total(); i++)
     {
      if(OrderGetTicket(i) > 0 && Order GetString(POSITION_SYMBOL) == Symbol() && Order GetInteger(POSITION_MAGIC) == magic)
       {
        if(Order GetInteger(POSITION_TYPE) == POSITION_TYPE_BUY_STOP || Order GetInteger(POSITION_TYPE) == POSITION_TYPE_SELL_STOP) // или другие типы
         {
 
Alexey Viktorov:

It is almost the same for pending orders

Huge thanks to the five-writers) for all their help!
 
Vitaly Muzichenko:

Alexei, a question for you:

How long and difficult is it to translate projects that are written in procedural style? Why procedural? - used to do it this way, have one template for all occasions, write 3-5 lines in it for conditions, and any owl is ready in half an hour with all the debugging

Next:

Is it possible to rewrite the position opening function to apply it in the same way as in quad, just got used to their names and usage over the years, and don't need to plug in any libraries.

Well, and a block of conditions for opening and creating graphics:

Lots more graphics, wrote once on five, so there's something done through .opa time and price of selecting the first point and the second. In the fourth, ObjectSetInteger(0,nm,OBJPROP_TIME1, t1) and ObjectSetInteger(0,nm,OBJPROP_TIME2, t2), but in the fifth, such a construction does not work(

Thank you in advance for the answer!

I rewrote one more project yesterday, it is quite a large Expert Advisor. My client has been optimizing it for weeks, it has a heavy code and a lot of parameters. I have encouraged him to switch to 5 with hedge, I said that he could optimize it in cloud. Today he writes that he is pissing his pants with such speed, it took him a couple of hours to optimize everything, which used to take him weeks. Obviously, there are usually a few thousand free agents in the cloud.

Now to your question, I've gained some experience, there are some answers.

Let them keep procedural style, no one is forcing you to use OOP.

2. Here is a good article on functions in MQL4 and 5. There is a table there . https://www.mql5.com/ru/articles/81.

Here is a library on combined use of 4 and 5 trading functions. I haven't tried it, but it's interesting. https://www.mql5.com/ru/code/16006

Переход с MQL4 на MQL5
Переход с MQL4 на MQL5
  • 2010.05.11
  • Sergey Pavlov
  • www.mql5.com
Данная статья, построенная в форме справочника по функциям MQL4, призвана помочь переходу с MQL4 на MQL5. Для каждой функции языка MQL4 приведено описание и представлен способ ее реализации на MQL5, что позволит вам значительно ускорить перевод своих программ с MQL4 на MQL5. Для удобства функции разбиты на группы, как в документации по MQL4.
 

Forum on trading, automated trading systems and testing trading strategies

Translation difficulties :)

Vitaly Muzichenko, 2016.08.15 21:00

I agree )

Alexey, then as a game) please translate this feature to fives:

//===============================================================================================
//------------------------------- Возвращает количество позиций --------------------------------+
//===============================================================================================
int NumberOfPositions(string symb="0", int type=-1, int mg=-1) {
 int kp=0;
  if(symb=="0") { symb=Symbol();}
  for(int i=0; i<OrdersTotal(); i++) {
   if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
    if((OrderSymbol()==symb||symb=="")&&(type<0||OrderType()==type)&&(mg<0||OrderMagicNumber()==mg)) {
     if(OrderType()==OP_BUY || OrderType()==OP_SELL) {
      kp++;
 }}}}
  return(kp);
 }

How to use it in four - you know.

Thank you!


I have a slightly different view on translation. No "replacements" in VS. Just adding a single line. The working code of the mentioned function for MT5-Hedge

// https://www.mql5.com/ru/code/16006
#include <MT4Orders.mqh>

//===============================================================================================
//------------------------------- Возвращает количество позиций --------------------------------+
//===============================================================================================
int NumberOfPositions(string symb="0", int type=-1, int mg=-1) {
 int kp=0;
  if(symb=="0") { symb=Symbol();}
  for(int i=0; i<OrdersTotal(); i++) {
   if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
    if((OrderSymbol()==symb||symb=="")&&(type<0||OrderType()==type)&&(mg<0||OrderMagicNumber()==mg)) {
     if(OrderType()==OP_BUY || OrderType()==OP_SELL) {
      kp++;
 }}}}
  return(kp);
 }

Code became crossplatform immediately.

Similarly running someone else's MT4 Expert Advisor in MT5-tester - example.

 
fxsaber:

I have a slightly different view of translation. No "replacements" in VS. Just adding a single line. Working code of mentioned function for MT5-Hedge

The code became cross-platform at once.

Similarly running someone else's MT4 Expert Advisor in MT5-tester - example.

Cool! I used CTrade yesterday for translation speed, haven't looked at the library yet. But I will definitely have a look at it.
 
Alexey Volchanskiy:
Cool! I used CTrade yesterday for translation speed, haven't looked at the library yet. But I'll definitely have a look.

My MT4Orders.mqh didn't work for me - it conflicts with the standard library I already use. Probably should only be on a clean sheet.

'::' - unexpected token Trade.mqh       126     22
'::' - unexpected token Trade.mqh       1477    14
'MqlTradeResult' - identifier already used      Trade.mqh       1477    55
see previous declaration of '           0       0
'&' - semicolon expected        Trade.mqh       1477    70
'if' - expressions are not allowed on a global scope    Trade.mqh       1483    4
'else' - expressions are not allowed on a global scope  Trade.mqh       1485    4
'if' - expressions are not allowed on a global scope    Trade.mqh       1488    4
'else' - expressions are not allowed on a global scope  Trade.mqh       1493    4
'return' - expressions are not allowed on a global scope        Trade.mqh       1499    4
')' - expressions are not allowed on a global scope     Trade.mqh       1500    3
declaration of 'action' hides global declaration in file 'Trade.mqh' at line 1480       DealInfo.mqh    244     55

**

 
Alexey Volchanskiy:

My MT4Orders.mqh didn't work for me - it conflicts with the standard library I already use. Probably should only be on a clean sheet.

**

#include <MT4Orders.mqh> // если есть #include <Trade/Trade.mqh>, вставить эту строчку ПОСЛЕ
 

Question - how do I know the commission of a position in MQL5?

I did it in MQL4 like this

double oProfit = OrderProfit() + OrderSwap() + OrderCommission(); // MQL4

There is no commission in MQL5.

double oProfit = PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP);

I looked in the order properties, and there is no commission as well. What should I do?

Reason: