a trading strategy based on Elliott Wave Theory - page 273

 
<br / translate="no"> Hearst calculation for 3000 bars in MQL4 took me about 40 milliseconds. We probably mean different things (the word calculation), so if you can send me the algorithm of your calculation (preferably) or code in MathCad (if necessary I can also use Matcad).

Something is wrong with the calculations in any case. My email is rosh AT metaquotes DOT ru.


I may have expressed myself incorrectly again. I didn't mean one sample - 600 counts counts for 20 minutes. Roughly speaking 500 iterations, i.e. first sample, for the dead zone [0; 100], second [0; 101], then [0; 102], [0; 103].... [0; 600]. Besides, this is MathCAD, and products of this class are not the best in terms of optimal calculations. The developers introduced serious optimization only in version 13 which I am using. Before that even numerical solution of simple equation could take a long time.

My calculation of the index is slightly different than can be found in available sources, while I don't deviate from classic Hearst's ideology. In other words, I cannot say that I calculate statistics by name. :о) The algorithm itself is optimally written, checked and rechecked.

PS: Thank you very much for your willingness to help. It is very possible, that it will be needed. I'll share the algorithm, if a better mechanism can be implemented in the near future. I have a couple of ideas.
 
<br/ translate="no"> Hearst calculation for 3000 bars in MQL4 took me about 40 milliseconds. Most likely we mean different things by it (the word calculation), so if you can send me in general words your calculation algorithm (preferably) or code in MathCad (if necessary I will also use Matcad).


There are quite a few algorithms. I found a singularity spectrum calculation in my archive. It is described conceptually in many books, e.g. by Feder, Bozhokin and many others. The number of iterations for one sample is quite decent. In particular, an iterative process of exponentiation is performed to estimate the "movement" contributed by each interval, revealing different types of signal behaviour (e.g. "now" intervals with larger deviations from the trend contribute more "movement", etc.).

You can read it all, but let me remind you of the main characteristic - the alpha value, at which F(alpha) reaches the maximum, is the generalized Hurst index (sometimes, the skyline parameter)


Calculation for the sample of 500 samples. The generalized Hurst index equals 0.6.


And here is the series itself (up to the vertical red line) for which the calculation was done and what happened later.



I did not go into "business" (although it is very interesting) because I have not yet figured out some things, namely the method of removing local trends. Using different methods results in different characteristics of the series. Another peculiarity is that it requires decent samples.

to Rosh, solandr

I have a question for the future. I am concerned about the fact that the Expert Advisor will be "out of action" for an objectively long time and therefore will not be engaged in the process of monitoring the current orders. I assume that calling the script will also not help - the Expert Advisor will wait until the script is executed. So I wondered if I should introduce an external (or global, what is better?) variable, for example:

extern string SIGNAL_FORECAST



When I get a signal that there is no forecast for some reason, the Expert Advisor sets the appropriate value of this parameter with the requirement for its execution. At this time, some indicator (it doesn't make any forecasts but has calculation functions) reads this variable all the time. As soon as it receives a forecast execution order, it initializes the calculation, but before that it writes "calculation started" into the variable. After the execution "calculation done". The Expert Advisor reads that the calculation is done ....

Will it all work? I.e. the Expert Advisor will theoretically be relieved of the burden of calculating everything?

 
Hi Sergey. It seems to me the best way to do it is in the form of Expert+Expert or Expert+Script bundle. The second option is preferable, I think.
Expert Advisor performs calculations and saves the signal flag and relevant parameters in a set of global variables upon signal receipt. The script opens orders according to the received instructions and implements them. The script runs in an endless loop, changing the frequency of this loop itself depending on the situation. The Expert Advisor, of course, runs after the completion of calculations, by the arrival of a tick.

The indicator is not suitable here because (as far as I know) its calculations are interrupted when a new tick comes.

In any case, I have decided to follow exactly this scheme.
 
Experts, scripts and indicators are calculated in MT4 in parallel, that is, at the same time with the appropriate sharing of available CPU resources. You can organize 2 Expert Advisors, one of which will calculate for several hours, and the other will be an executor, which through global variables of the terminal will receive the results of the previous cycle of calculations of the first Expert Advisor and make the necessary trade operations. Both Expert Advisors will work independently (in terms of execution) of each other. The first Expert Advisor will be started for a few hours at the arrival of the first tick, and the second one will be started at every new tick, or, for example, with a specified period (in case of an infinite loop with the necessary pause).
 
Hi Sergey. I think the best way to do it is as Expert+Expert or Expert+Script bundle. The second option is preferable, I think. <br/ translate="no">.

The second variant has the inconvenience of having to manually pass this same script to the chart at every next launch of the terminal. We will get tired of it very quickly. It is better to use the first variant. You might as well organize exactly the same infinite loop in start() function as in the script.
 
to Yurixx, solandr

Thank you very much for the advice. I don't work with MT for a long time, while I was doing my research I forgot that scripts can be run in a loop and I even had no thoughts about two Expert Advisors.

But on the other hand you can't set a tester on such an astrolabe, right? Although, it is probably not so crucial.

Thanks again. :о)))
 
What if you run a script from the indicator? In this case, new data arrivals to the indicator will still interrupt the calculations?
 
2 grasn:
Still, your calculation time is too long. I think in this situation it would be better to do them outside MT (after all C is 17 times faster than MQL4). I don't know if Matcad can generate C code, but that would be handy. The result would be written to a file and read from the Expert Advisor. This file can be a kind of step-by-step instruction for the Expert Advisor (in general data transfer to MT has not interested me much so far, maybe there are other ways). Having written the "instruction" for a certain history interval, you can use the tester. But will the tester support Expert Advisor+Expert or Expert Advisor+Script? I suspect that it will not.
 
By the way, as far as I understand, the calculations are not interrupted now. It is performed on the data values at the start of the calculation, after which the terminal jumps to fresh data.
 
to Candid

2 grasn:
Still, your calculation time is too long. I think in this situation it would be better to do them outside MT (after all C is 17 times faster than MQL4). I don't know if Matcad can generate C code, but it would be useful. The result would be written to a file and read from the Expert Advisor. This file can be a kind of step-by-step instruction for the Expert Advisor (in general data transfer to MT has not interested me much so far, maybe there are other ways). Having written the "instruction" for a certain history interval, you can use the tester. But will the tester support Expert Advisor+expert or Expert Advisor+script combination? I suspect that it will not.


That's right, the calculation time is quite long, I will deal with it. MathCAD can't generate C code, but MathLab can do it (if they're not lying of course :o) The testing in MT is needed to get more or less grounded results from trade point of view (and not multiple forecast tests in MathCAD, though positive). After testing in MT I'll think what to do next, including moving calculations to a separate server, about what I've written before. But it's like climbers, the more knots on the rope, the worse it is.
Reason: