
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The amazing ability to answer the wrong question...
Now explain to me what would happen if:
1. 100 bars recalculated, entered into buffers from 0 to 99 inclusive (let's consider the direction as time series) the value 1.03
2. Suddenly, history was loaded and prev_calculated became 0.
From which bar in the indicator the value will be 1.03?
{
//--- инициализация элементов индикаторного буфера при первом запуске или при подкачке истории
for(int i=0;i<rates_total;i++)
ExtBuffer[i]=1.01;
return(rates_total);
}
Better explain how to get rid of rubbish theFIRST time the indicator is started.
Not a crutch at all. That's how I do it.
{
//--- инициализация элементов индикаторного буфера при первом запуске или при подкачке истории
for(int i=0;i<rates_total;i++)
ExtBuffer[i]=1.01;
return(rates_total);
}
So, this is the problem that should be solved. I don't need rubbish (not really, but it interferes with displaying), but I need to save the previous calculations of the indicator. When you start the indicator FIRST time the buffer gets rubbish, and when loading history all that was inserted into buffers should be saved ... and preferably without saving it to a file or to GV.
added:
This is intended to estimate the drawdown in real time every minute. The Expert Advisor works for a week without stopping, and instead of the weekly display we'll see only the last value, which is visible even without the indicator.
If a simple flag first run / no longer first run is enough, replace prev_calculated with static bool b_First_Run. And you can put buffer initialization in OnInint
No, the goals there are not so primitive.
So this is the problem that needs to be solved. I don't need rubbish (I don't need it, but it interferes with displaying), but I need to save previous calculations of the indicator. When you start the indicator FIRST time the buffer gets rubbish, and when loading history all that was inserted into buffers should be saved ... and preferably without saving it to a file or to GV.
added:
This is intended as a real time estimate of the drawdown every minute. The Expert Advisor works for a week without stopping, and instead of the weekly display we will only see the last value, which is visible even without indicator...
This is not your suggestion,Alexey Viktorov, as I understand it, you need only this - to zero buffers at the first start and not to touch anything in them during all sorts of paging
Re-checked what happens if buffer arrays are initialized in OnInit().
Even when the indicator is removed from the chart and newly set, NOT ALL, but some buffers still have the old values. Not even exactly what they were before, but one of those values extends over several bars.
Oh! That makes more sense now. I'll get back to you tonight.
Sorry for the delay in replying. The only way to save the calculated values for a given timeframe is to save them to a file. You need to take care of the synchronisation - so that when reading from the file the data are placed on their bars. The most logical solution is synchronization according to the bar open time, but there may be some subtleties: for example, the bar open time (saved to a file) was 2016.09.05. 25:02, but now we have a bar on the chart with the time equal to 2016.09.05. 25:01.
Or maybe it would be better to draw developers' attention to the problem of initialization of indicator buffers? Why is there no such problem in MT4? Maybe again not a complete understanding? The problem is that even after the mandatory initialization of buffers after taking an indicator off a chart in EACH of them, not all buffers contain rubbish, and we can't unload it from there...
Personally I don't mind crutches, but only if these crutches are not too complicated and with positive effect. But writing to a file and then reading it is a crummy crutch.