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

 
i need help to remake indicator with open source vhpchannel_02 mt5 to view it on long history.i need to upload remade indicator for download very much please.
https://www.mql5.com/ru/forum/188487 link to the material.
Ищу канальные индикаторы для MT5
Ищу канальные индикаторы для MT5
  • 2017.03.28
  • www.mql5.com
Все привет, ищу любые канальные индикаторы, которых нет по умолчанию в MT5 Нужны для оптимизации ТС (какой их индикаторов покажет устойчивые резуль...
 
Alexey Viktorov:

While I've been away .........

At first glance it seems fine. You can check it in the script any day. But here in the documentation I don't like the example. Here is how I advise to write

Thank you, it works perfectly!
 
Alexey Viktorov:

For such a task


the indicator is not suitable.
Why? Because it's so nice to live without a cycle on every tick.
 
Aleksei Stepanenko:
Why? Because it is so nice to live without a cycle on every tick.

I need it on every tick, because I found an object to buy-bought, found an object to sell-sold

 

Yes I get it, and when the event arrives, we know instantly that the object has been created. Even before the first closest tick, and without a loop. That's the idea. We just sit and wait.

This simple example shows how we can monitor object creation on the current chart. If you get twisted, you can keep track of the other charts you want.

int OnInit() 
   {
   ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_CREATE,true); 
   return(INIT_SUCCEEDED); 
   } 

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) 
   {
   if(id==CHARTEVENT_OBJECT_CREATE)
      {
      printf(sparam);
      }
   }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
   {
   return(rates_total);
   }

Cost of processor effort: zero.

 
Aleksei Stepanenko :
Why? It's so nice to live without loops on every tick.

Because the indicator cannot make trades.

I am not against OnChartEvent, but it works only on its own chart and then we will have to put the EA on every chart, and Makar wants the EA to be on only one chart.

Aleksei Stepanenko:

... If you have a twist, you can watch the other charts you need.

Cost of Effort of the Processor: Zero.

Well, well, well... Maybe there's something I don't know? How can I get around to tracking other desired charts from one EA via OnChartEvent
 
Alexey Viktorov:

Because the indicator cannot make trades.

I'm not against OnChartEvent, but it only works on its own chart and then you would have to put the EA on every chart, and Makar wants the EA to be on only one chart.

https://www.mql5.com/ru/forum/369209

OnChartEvent события в ТС
OnChartEvent события в ТС
  • 2021.05.13
  • www.mql5.com
Предлагаю делиться опытами и наблюдениями в этой ветке Konstantin Gruzdev первый предложил на форуме идею Event spy...
 
And an indicator per chart again?
 
And a per chart indicator again?

With OnChartEvent not otherwise.

 
MakarFX:
Thanks, it works perfectly!

Shove the code that Alexey gave you into the Timer with an interval of a couple of seconds. Also add a line that if market is closed- exit, so as not to run the cycle.

This approach will relieve CPU load in fast market, and in slow market it will allow to track object appearance on another chart faster.

Reason: