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

 
Mihail Matkovskij #:

You still don't get it, do you? I tried to explain why your condition is always true and the order closes.

Got it, got it, further reasoning was personal. It slipped out.

 
Alexander Avksentyev #:

Got it, got it, the reasoning was personal. It's gone.

Calculate profit in pips (it's easy) and set x value in pips too. As a result, everything will be in pips. Set x less than the spread (for your example more). Then everything will work correctly.

 
Alexander Avksentyev #:

You could do it that way, and you could do a virtual sl. But I haven't done that yet.

The main thing is to get a signal to close the order when it reaches -x

Post the close function and what "-x" is
 

Порт-моне тв #:

a) code to create a button on the graph; this also includes the scoreboard as a background object;

b) code for entering values into this scoreboard (pips, seconds) special fields for this;

a1)

а2)

б)

 

hello

found a function that keeps track of the current price value

bool  SymbolInfoTick(
   string    symbol,     // символ
   MqlTick&  tick        // ссылка на структуру
   );

question:

how to specify the current symbol ?

it is not clear what isMqlTick&?

The handbook states that it is a structure for storing the latest prices for a symbol. It is intended to quickly obtain the most requested information on current prices.

But in the usage example it is stated:

void OnTick()
  {
   MqlTick last_tick;
//---
   if(SymbolInfoTick(Symbol(),last_tick))
     {
      Print(last_tick.time,": Bid = ",last_tick.bid,
            " Ask = ",last_tick.ask,"  Volume = ",last_tick.volume);
     }
   else Print("SymbolInfoTick() failed, error = ",GetLastError());
//---
  }

That is, the function that refers to the MqlTick structure is itself inside the structure.

How can this be?

 
законопослушный гражданин current prices.

But in the usage example it states:

That is, the function that refers to the MqlTick structure is itself inside the structure.

How can this be?

It is a structure

MqlTick last_tick;

and this is a reference to it by a certain symbol

if(SymbolInfoTick(Symbol(),last_tick))
 
Tretyakov Rostyslav #:

It is a structure

and this is a reference to it by a specific symbol

... and then there is no example of reading the structure. Judging from the first question, the person will not understand it either.

 
Tretyakov Rostyslav #:
Post the closing function and what "-x" is

There is nothing else. And x is a negative profit value on an open order.

 
Tretyakov Rostyslav #:
Post the closing function and what "-x" is

The close function is at which condition should an order be closed?

Is x a condition?

Then what did I show?

Or if you don't mind, write in more detail what is needed.

In any case, thank you!

 
законопослушный гражданин current prices.

But in the usage example it is stated:

That is, the function that refers to the MqlTick structure is itself inside the structure.

How can it be?

The SymbolInfoTick function writes tick data into a specialMqlTick structure, from the fields of which they can be obtained.

struct MqlTick
  {
   datetime     time;          // Время последнего обновления цен
   double       bid;           // Текущая цена Bid
   double       ask;           // Текущая цена Ask
   double       last;          // Текущая цена последней сделки (Last)
   ulong        volume;        // Объем для текущей цены Last
   long         time_msc;      // Время последнего обновления цен в миллисекундах
   uint         flags;         // Флаги тиков
   double       volume_real;   // Объем для текущей цены Last c повышенной точностью
  };
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура для получения текущих цен
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура для получения текущих цен
  • www.mql5.com
Структура для получения текущих цен - Структуры данных - Константы, перечисления и структуры - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5