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

 
ilnur17021992:

there is a variable

int Level = 0;

While the program is running, it is constantly changing. Help me write a condition: if Level has NOT changed, then do nothing. If Level has changed (no matter if it has changed up or down), then do some action { operator }

enter another variable

int Level1 = 0;

int Level = 0;

if (Level !=Level1)

{};

and then Level1 =Level

but I really don't understand why we need to pull an array on every tick if we can do it after any trade operation

 
trader781:

enter another variable

int Level1 = 0;

int Level = 0;

if (Level !=Level1)

{};

and then Level1 =Level

I don't really understand why I need to pull an array at every tick, if I can do it after any trade operation

      if(SELL_Lvl>0)
      {
         ObjectCreate("Sell no loss level", OBJ_HLINE, 0, 0, SELL_NoLossLevel);
      }          

Further, I need it to happen when SELL_Lvl increases:

         ObjectDelete( "Sell no loss level");

But, since theSELL_Lvl>0 condition is fulfilled, the line is redrawn again, but by a new value ofSELL_NoLossLevel. Is there an easier and more obvious way to redraw the line, depending onSELL_Lvl?

 
ilnur17021992:
      if(SELL_Lvl>0)
      {
         ObjectCreate("Sell no loss level", OBJ_HLINE, 0, 0, SELL_NoLossLevel);
      }          

Then I need to increase SELL_Lvl to be redrawn:

         ObjectDelete( "Sell no loss level");

But since theSELL_L_Lvl>0 condition is fulfilled, the line should be redrawn again, but at a new value ofSELL_NoLossLevel. Is there an easier and more obvious way to redraw the line, depending on the value ofSELL_Lvl?

Transfer the object to the new value without deleting it or re-creating it:

ObjectSetDouble(chart_ID, "Sell no loss level", OBJPROP_PRICE1, NewPrice);
 
Vitaly Muzichenko:

Transfer the object to the new value without deleting it or re-creating it:

ObjectSetDouble(chart_ID, "Sell no loss level", OBJPROP_PRICE1, NewPrice);

This is certainly an option, but I would like the line to be redrawn by value ofSELL_NoLossLevel depending on whetherSELL_Lvlhas changed

like this if(ObjectGet("Sell no loss level", 1) !=SELL_NoLossLevel{ObjectDelete("Sell no loss level");}

The line is redrawn at every tick while I need it to be redrawn only ifSELL_Lvl changes

 
ilnur17021992:

Of course it is a variant, but I would like the line to be redrawn bySELL_NoLossLevel depending on ifSELL_Lvl has changed

like this if(ObjectGet("Sell no loss level", 1) !=SELL_NoLossLevel{ObjectDelete("Sell no loss level");}

The line is redrawn on every tick, while I need it to be redrawn only ifSELL_Lvl changes

Explain the condition of line redrawing clearly, with real price values.

For the highlighted line: how much did it change? What indicates the fact that SELL_Lvl has changed?

 
guys advise function for closing pending orders in mcl5 there are five buy limit orders to close the lowest one
 
TYRBO:
i want to know what function to use to close a pending order in mcl5.

It is better to loop through, determine the right one and by documentation

Delete Pending Order

Trade order to delete a pending order. Requires 2 fields to be specified:

  • action
  • order
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура торгового запроса
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура торгового запроса
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура торгового запроса - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Viktorov:

Better to cycle through, identify the right one and follow the documentation

I know how to find the price of the bottom order. I would appreciate it if you could tell me how to find a bottom order ticket.
 
Alexey Viktorov:

Write down the condition for line redrawing clearly, with real price values, and then you will understand what you need to do.

On the highlighted: changed by how much? What indicates the fact that SELL_Lvl has changed?

SELL_Lvl is the number of knees (orders) of the sell grid.SELL_NoLossLevel is the total level (price) of the Buy order. Well, the idea is the following: we need a line drawn at the level of a Buy Line and redrawn respectively when new Lines are opened. I do not know how to do it.
 
TYRBO:
I know how to find the price of a minimum order. I would appreciate if you could tell me how to find a minimum order ticket.

There is an example in the documentation.

It would probably be better to go through the orders in the loop and, provided that the next order is lower than the previous one, select it for further work with it. Thus, when we exit the loop, the order to be deleted will be selected.

Or you can first save its position in the order list in the loop and after the exit from the loop select it by the saved index.

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