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

 
Artyom Trishkin:

I showed above what to do. Why bother with so much when there is a method recommended by the developers?

Was the question to choose on which timeframes to display the object and on which not?

Let's say there is a trading panel on the chart. Then I manually build objects (trading levels, vertical lines, rectangles).

Everything I build manually will be applied to the trading panel. All objects are on the same timeframe.

And how does the "developers recommended method" help in this case?

 
Aliaksei Karalkou:
Hello.

I want to transfer the ATP indicator to the price chart. But I don't know how to do it. I want it to show the maximal movement in volatility from the midline of the same period. If anyone has the code, thank you for sharing.

https://www.mql5.com/ru/code/23304

Multi_ATR_Bands
Multi_ATR_Bands
  • www.mql5.com
Индикатор Three ATR Bands with multiple selection
 
Artyom Trishkin:

Property OBJPROP_TIMEFRAMES:

OBJ_NO_PERIODS - not visible on all periods,

OBJ_ALL_PERIODS - visible on all periods

Thank you.

The method really turned out to work and is very compact.

The object now stays visually above all others.

 
Maksym Mudrakov:

Was it a question of selecting which timeframes to display the object on and which not?

Let's say there is a trading panel on the chart. Then I manually build objects (trading levels, vertical lines, rectangles).

Everything I build manually will be applied to the trading panel. All objects are on the same timeframe.

And how does the "developers recommended method" help in this case ?

I took note of your suggestion, but I had flicker when deleting and re-drawing an object.

The method suggestedby Artyom Trishkin actually works!

Now there is no redrawing and flickering of the object and it visually stays above all.

By the way, in my case it was also a trading panel that was blocked by arrows from open and closed trades.

How I solved the problem:

// Глобальное объявление
int last_tick_objects = 0;                // количество объектов на прошлом тике
// имена графических объектов:
string tp_rctngl = "TP Rectangle";
string sl_rctngl = "SL Rectangle";
string vol_rctngl = "Volume Rectangle";

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   long cid = ChartID();
   if(ObjectsTotal() != last_tick_objects)  // количество объектов поменялось
     {
      last_tick_objects = ObjectsTotal();   // запоминаем новое количество объектов
      // выводим на передний план объекты: tp_rctngl, sl_rctngl, vol_rctngl
      if(ObjectFind(cid, tp_rctngl) > -1) // объект существует
        {
         ObjectSetInteger(cid, tp_rctngl, OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);  // делаем невидимым на всех таймах
         ObjectSetInteger(cid, tp_rctngl, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS); // делаем видимым на всех таймах
        }
      //---
      if(ObjectFind(cid, sl_rctngl) > -1) // объект существует
        {
         ObjectSetInteger(cid, sl_rctngl, OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);  // делаем невидимым на всех таймах
         ObjectSetInteger(cid, sl_rctngl, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS); // делаем видимым на всех таймах
        }
      //---
      if(ObjectFind(cid, vol_rctngl) > -1) // объект существует
        {
         ObjectSetInteger(cid, vol_rctngl, OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS); // делаем невидимым на всех таймах
         ObjectSetInteger(cid, vol_rctngl, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);// делаем видимым на всех таймах
        }
      ChartRedraw(cid);// перерисовка графика для применения изменений
     }
  }
//+------------------------------------------------------------------+
 

I am writing an EA that from time to time needs to perform several long cycles of different recalculations (e.g. every 12, 24, 48 hours). Each such recalculation takes 1.5-2 hours on one core (i.e. in one thread) - and naturally, processing of new ticks and trading by this EA are paused

... Such calculations can be delegated to another EA in another thread and the final data can be transferred between EAs usingthe EventChartCustom function and OnChartEvent event handler


But I need to be able to publish the EA in the marketplace - so delegating recalculations and recalculations in the same thread is not suitable. Is there an analogue of the thread library from C++ or some other version for implementing such a specific EA in MQL5? (I've entered the word "thread" with "documentation" filter into search engine on the website and there is nothing).

 
Oleg Remizov:

I took note of your suggestion, but I had flicker when deleting and redrawing an object.

The method suggestedby Artyom Trishkin actually works!

Now there is no redrawing and flickering of the object and it visually stays above all.

By the way, in my case it was also a trading panel that was blocked by arrows from open and closed trades.

How I solved the problem:

The point is that the flickering is due to the fact that deleting and rendering happens very often, you only need to catch the appearance of new objects. If the method works, of course I'll take it on board too, but since the documentation doesn't mention such a useful property, I've never paid attention to it.

Although the question remains if you use your own trading panel in conjunction with a third-party indicator that also builds objects.

 
Maksym Mudrakov:

Was the question to choose on which timeframes to display the object and on which not?

Let's say there is a trading panel on the chart. Then I manually build objects (trading levels, vertical lines, rectangles).

Everything I build manually will be applied to the trading panel. All objects are on the same time frame.

And how does the "developers recommended method" help in this case?

Forum on trading, automated trading systems and strategy testing

Any questions from newbies on MQL4 and MQL5, help and discussion on algorithms and codes

Oleg Remizov, 2020.04.26 14:44

Thank you.

The method has really proved to be effective and very compact.

Now the object is visually higher than all the others.


 
Maksym Mudrakov:

The point is that the flicker is due to the fact that deletion and rendering happens very often, you just need to catch the appearance of new objects. If the method works, then of course I'll adopt it as well, but since the documentation doesn't mention such a useful property, I've never paid attention to it.

Although the question remains if you use your own trading panel in combination with a third-party indicator that also builds objects.

The method recommended by Slava was the only acceptable one. You can search his posts - it's in his profile - publications/all posts.

And, yes, how does your method of recreating all objects help in the same situation?

 
Artyom Trishkin:

Slava recommended the method as the only one most suitable. You can search his posts - it's in his profile - publications/all posts.

And, yes, how would your method of recreating all the objects help in the same situation?

I would do the following, with a third-party indicator you need to track ObjectsTotal(), and if the largest index of my panel object is less than ObjectsTotal()-1, then recreate the panel. Need to try your method in all sorts of situations first, but so far I don't see any more freedom in using Objects Visibility.
 
Artyom Trishkin:

I cannot build Meta Trader 5