Errors, bugs, questions - page 131

 
Dmitriy2:

the code is inserted, the file is not attached


Corrections have been made.

Please try again.

 
alexvd:

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...).

 
alexvd:

Corrections have been made.

Try again.

Yes, it worked, thank you.
 
Dmitriy2:

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.

Документация по MQL5: Доступ к таймсериям и индикаторам / BarsCalculated
Документация по MQL5: Доступ к таймсериям и индикаторам / BarsCalculated
  • www.mql5.com
Доступ к таймсериям и индикаторам / BarsCalculated - Документация по MQL5
 
Rosh:
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.
I thoughtthe weighted average price only refers to technical indicators... i think i can't always get it to 0 in the tester during runs... sometimes a few cents are still sticking out
 
alexvd:

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...

 
maryan.dirtyn:
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:

Deal
Volume
Price
Buy EURUSD
0.1 lot
1.2800
Buy EURUSD0.2 lots
1.3400
Buy EURUSD0.3 lots
1.2000
Total: Long position on EURUSD
0.6 lot
?


As a result, we have a position on EURUSD with the volume of 0.6 lots, but at what price?

 
Rosh:

Weighted average by volume. For example, there were three trades on EURUSD:

Deal
Volume
Price
Buy EURUSD
0.1 lot
1.2800
Buy EURUSD0.2 lots
1.3400
Buy EURUSD0.3 lots
1.2000
Total: Long position on EURUSD
0.6 lot
?


We end up with a EURUSD position of 0.6 lots, but at what price?

Wouldn't it be easier to round the price to the level of accuracy of the currency at the server level? After all, the Expert Advisor will have to deal with adjustment of precision and price per point...
 
Interesting:
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 would the EA bother? This weighted average price will be necessary to calculate the closing of positions. The Expert Advisor will not need it. The position will have to be closed at a normal price with the necessary number of digits for this symbol.
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы - Документация по MQL5
 
Rosh:
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...

Reason: