
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 code is inserted, the file is not attached
Corrections have been made.
Please try again.
It hangs because of the infinite loop.
You have the only way out of the loop - by break. But the break you have occurs when a certain condition is met. One of the components
You get the indicator handle inside the function every time and copy it without checking if the data is ready.
Suggestion.
1. Take the handle variable to the global level.
2. Receive the indicator handle at OnInit (you do not change the parabolic parameters anyway).
3. Before copying data from the indicator buffer, check its readiness (calculability) - the function BarsCalculated (Parabolic) will help you.
4) Organize exit from the cycle, if you don't do the item 3. 3 is not fulfilled.
2. it's not changing in the test example, in fact this function is used all the time with different parameters, that's why I get the handle not in OnInit
3. i will check it, i just don't really understand what i need it for, the condition is such that it cannot fail, a series of parabolic points is the nearest bars, they should definitely be uploaded (and in general, i understand the history is uploaded to the tester one year before the specified start date of testing). It really works well. It works in MQL4 both in real and in the tester (though there is no separate parabolic function, but it is built in...).
Corrections have been made.
Try again.
2. it doesn't change in the test example, and in fact this function is used all the time with different parameters, so I get the handle not in OnInit
3. Ok, I'll make a check, I just don't really understand the point, the condition is such that it cannot fail, a series of parabolic points is the nearest bars, they should definitely be uploaded (and in general, I understand the history is uploaded to the tester a year before the specified test start date). It really works well. It works in MQL4 both in real and in the tester (though there is no separate parabolic function, but it is built in...).
3. It was already discussed and described in the reference(https://www.mql5.com/ru/docs/series/barscalculated), why it is needed.
Note
This function is useful when you want to get indicator data right after its creation (to get an indicator handle).
This is your case.
The indicator is calculated based on the bar data. The bars are there, but the calculated data may be absent.
This means that this position is the result of several trades in this instrument. As a consequence, you see the weighted average price of the position.
3. Why it is needed has already been discussed many times and is described in the help(https://www.mql5.com/ru/docs/series/barscalculated).
This is your case.
The indicator is calculated on bar data. The bars are there, but the calculated data may not be.
Yes, I have it with BarsCalculated, thank you.
But anyway it is logically wrong that it works and does not work in the tester. You need to have all checks already built in the tester, and if the request goes to some data and it's not there, then the error will appear. But the tester has bars, but for some reason it can't calculate data and keeps silent...
I thoughtthe weighted average price was just a technical indicator... I don't always get 0 when I'm running in the Strategy Tester... Sometimes a few cents may occur.
Weighted average by volume. For example, there were three trades on EURUSD:
As a result, we have a position on EURUSD with the volume of 0.6 lots, but at what price?
Weighted average by volume. For example, there were three trades on EURUSD:
We end up with a EURUSD position of 0.6 lots, but at what price?
Wouldn't it be easier to round up the price to the level of accuracy of the currency at the server level? After all, any EA would have to suffer with the adjustment in accuracy and price per point...
Why should the Expert Advisor suffer? This weighted average price is needed to calculate the closing of positions. It is of no use to the Expert Advisor. It will have to close the position at a normal price with the necessary number of signs for this symbol.
In some cases, you have to have a normalised price value, regardless of how the price is received.
It's easier to do server-side normalisation as long as the server recalculates the opening price anyway (at least in my opinion).
By the way, since we are talking about weighted average price and netting platform.
As far as I understand there are two models of trimming (partial closing) of a losing position that was previously closed:
1. Don't fix the loss on the partial close, but simply recalculate the opening price (if I'm not mistaken, that's what FC does);
2. leave the opening price unchanged, fixing the loss.
The same applies to reversing of losing positions
I want to know the developers' opinion about what method will eventually be standardized in MT5, if possible why...