Questions from Beginners MQL5 MT5 MetaTrader 5 - page 694

 
Renat Akhtyamov:

well, then the indicator cycle, in which the number of bars is this very line.

I wonder - what is clear(?), i.e. where to read about the peculiarities of MT5 in offline mode, could you tell me please?

The rates_total indicator - successfully used instead of Bars() in OnCalculate() loop
 
Artyom Trishkin:
In the rates_total indicator - it is successfully used instead of Bars() in the loop in OnCalculate()

Okay. Yes, there is such a thing.

Will there be the same number of bars for different instruments/timeframes, because I have a multi-currency indicator?

I can change parameters here

Bars(_Symbol,_Period);

But what about rates_total to calculate the indicator for different timeframes and symbols?

 
Renat Akhtyamov:

Okay. Yes, there is such a thing.

Will there be the same number of bars for different instruments/timeframes, because I have a multi-currency tool?

To obtain the number of bars of history for a non-current timeframe or a non-current symbol in a multi-currency/multi-timeframe indicator, we should use Bars()
 
Artyom Trishkin:
To obtain the number of bars of history for a non-current timeframe or a non-current symbol in the multi-currency/multi-timeframe indicator, you should use Bars()

That's exactly what I'm writing about - that this feature doesn't work offline, although there is a quote history

Therefore, the indicator cannot be tested offline.

It turns out that the quote in MT5 is sent personally to each IP and may be different from the history of the quote, which is already drawn on the chart? //so goes the logic...

 
Renat Akhtyamov:

and then the indicator, in which the number of bars is this very line.

I wonder - what is clear(?), i.e. where to read about peculiarities of MT5 in offline mode, could you please tell?

It is clear that MT5. It is not clear what was done before calling Bars(). This simple script works and does not return zero even when there is no connection to the server or when there is no network at all.

I haven't tried it in indicators, that's why I asked how it is done in your case. Most likely, when re-call will be the real number of bars, the first call will cause renewal of data in cache.

void OnStart()
  {
        Print("Bars on chart - ",Bars(_Symbol,PERIOD_CURRENT));  
  }
 
Vitalie Postolache:

It is clear that MT5. It's not clear what was done before calling Bars(). This simple script works for me and does not return zero, even when there is no connection to the server or when there is no network at all.

I haven't tried it in indicators, that's why I asked how it is done in your case.

void OnStart()
  {
        Print("Bars on chart - ",Bars(_Symbol,PERIOD_CURRENT));  
  }
clearly
 

What's the best simple way to link to a candle's close to run the EA? To recalculate indicators, remove/place orders, etc.?

By timer?

But how to start the timer at the right time so that it is triggered hourly at HH:00:00? and not every hour from the activation of the timer?

 
dimnik:

What's the best simple way to link to a candle's close to run the EA? To recalculate indicators, remove/place orders, etc.?

By timer?

But how to start the timer at the right time so that it is triggered hourly at HH:00:00? and not every hour from the activation of the timer?

Check the opening time of the current candle and compare it with the opening time of the last check. If they are equal, it means that a new bar has not opened yet and return from OnTick(). If not equal - we have identified the opening of a new bar - do everything that is written in the Expert Advisor and remember the new open time for the next check.
 
Vitaly Muzichenko:

Graphic question:

There is a design like this

for(long currChart = ChartFirst();currChart != -1; currChart=ChartNext(currChart)) {
 if(currChart == график тестера) continue; // Что сюда написать?
  ObjectSetInteger(currChart,"Sync",OBJPROP_BGCOLOR,clrGreen);
}

How can I find out that the chart is not the main one, but open in tester mode and skip it?

As a suggestion.

Create a template for the chart and put a label with the name, for example, "TesterChart" or any other object, you can use zero coordinates so that it is not visible. Name this template "Tester". Now all charts from tests will have an object with this name. Next ask if the chart has this object, if yes, it is "Our Tester", skip it.

Through and through, but I don't know any other way.

 
Vasiliy Pushkaryov:
As a suggestion.

Create a template for the chart and label it with a name such as "TesterChart" or any other object, possibly at zero coordinates so that it is not visible. Name this template "Tester". Now all charts from tests will have an object with this name. Next ask if the graph has this object, if yes, it's "Our Tester", skip it.

I don't know how, but I don't know any other way.

Thank you, but this solution is not suitable in the sense that I'm testing on more than one template, but that's half the trouble, but the fact that this indicator is not only working for me, people simply get tired of filling labels in the tester.

It turns out that there is no way to determine programmatically that the chart runs in the tester? Where are you developers?

.