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

 
Vladimir Pastushak:


This is wrong and so are the other examples.

If you put a stop at 1.2356 and on the new tick you put a stop at 1.2356 again, you will get error 1

This is from the first block. I changed it, but the error remained. This condition with a stop has been implemented for the EA not to make unnecessary passes. And on a new tick, the EA will not set the same stop again - because after this condition I will check other conditions, for example, if the stop is equal to the value I want to set.

 
Alexandr Sokolov:

This is from the first block. I changed it, but the error remains. I made this condition with a stop to prevent the EA from making unnecessary passes. And on a new tick the EA does not place the same stop again - because after this condition is checked the other ones, for example, if the stop is equal to the value to be set

OrderStopLoss()

All Order...... () must be normalized

 
Vladimir Pastushak:

All Order...... () needs to be normalised.

I did that - and it didn't help either. At the same time, as before I don't have this error in the tester, and MQL somehow finds it

 
Where should the text file be saved so that it can be read from another terminal?
 
yiduwi:
What path should be used to save a text file so that it can be read from another terminal?

ENUM_TERMINAL_INFO_STRING

Identifier

Description

Property type

TERMINAL_LANGUAGE

Terminal language

string

TERMINAL_COMPANY

Company name

string

TERMINAL_NAME

Terminal name

string

TERMINAL_PATH

The folder the terminal is running from

string

TERMINAL_DATA_PATH

Folder where terminal data is stored

string

TERMINAL_COMMONDATA_PATH

Shared folder of all client terminals installed on the computer

string


Документация по MQL5: Проверка состояния / TerminalInfoString
Документация по MQL5: Проверка состояния / TerminalInfoString
  • www.mql5.com
Проверка состояния / TerminalInfoString - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
 
Artyom Trishkin:

Thank you.

 

do a one to one example from the articlehttps://www.mql5.com/ru/articles/18

the codes from the article work 100% in mt4, i checked it in January of this year

Alternatively, you have compiled a project for a 64 bit dll, MT4 terminal is 32 bit, you need to configure and compile a project for a 32 bit .dll

Как за 10 минут написать DLL библиотеку для MQL5 и обмениваться данными?
Как за 10 минут написать DLL библиотеку для MQL5 и обмениваться данными?
  • www.mql5.com
Так уж сложилось, что сейчас мало кто из разработчиков помнит, как написать простую DLL библиотеку и в чем особенности связывания разнородных систем. Я постараюсь за 10 минут на примерах показать весь процесс создания простых DLL библиотек и раскрою некоторые технические детали нашей реализации связывания. Демонстрация будет на примере Visual...
 

Hello, dear forum users.

Can you please explain in which case the code is written correctly and in which not correctly and why (see below)?

for (z=OrdersTotal()-1; z>=0; z --)
    {
      OrderSelect (z, SELECT_BY_POS);
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderMagicNumber()!=MAGIC) continue;
      if(OrderType()==OP_BUY)  CloseBUY();
    }
for(int i=OrdersTotal()-1;i>=0;i--)
            {
            if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
            {
             if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
             {
             if(OrderType()==OP_BUY)  CloseBUY();
             }
            }
            }

If possible, in more detail. Thank you.

 
novichok2018:

Hello, dear forum users.

Can you please explain in which case the code is written correctly and in which not correctly and why (see below)?

If possible, in more detail. Thank you.

Even the compiler will highlight to you in the first case"the result of OrderSelect must be checked" ;-)

If you change for the first one if (!OrderSelect(...)) continue; then the options are identical.

In the first one the code is visually linear, in the second one it looks like a staircase. I prefer the first variant, it's easier to read and in general, occurrence of deep logical tabs {{{{ }}}} hints that it's time to change something :-)

Reason: