[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 82
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
Thank you, but it won't work for me. I don't need an offset. Above I wrote. Suppose for the first candle buffer[1]=Hight[1], for the third buffer[3]=Hight[3] and for the second one we need to calculate: buffer[2]=MathAbs(Higth[1]-Hight[3])/2 and get what I want in the picture.
wolf05632:
SZY: How can I make an indicator work, i.e. make calculations (it WORKS, not visible) only on a certain timeframe (H1)?
Why didn't you like my version? :)) Much simpler and less calculations. Or do you want to keep values in buffer at each bar?
I tried it, thank you, but it didn't work. I couldn't get it to show on the chart. I might have misunderstood something. The only thing I understood the main thing: elements in the buffer must go sequentially (1,2,3...), i.e. without any gaps (1,3,5...) and EVERY! element in the buffer must have a value assigned! :-)
Roman, thanks for the reply..... Unfortunately, I still don't understand one thing. In the textbook, https://book.mql4.com/ru/basics/expressions, under "Type Approach. Option 4.1. Calculating the result of an integer type
and Variant 4.2. A similar situation occurs if we look for a result as a value of a real type", the same formula is given, but in one case, the type of variable F is designated as int
and in the second example, the variable is double
Unfortunately, I still don't understand the logic of the conversion. If in the first variant it is clear why int is assigned to variable F (i.e., according to rule of implicit type conversion), then why double.... is assigned in the second variant totally confuses me.
Please clarify what I may have missed in my explanations here?
Thank you in advance.
I tried it, thank you, but it didn't work. It didn't show anything on the chart. Maybe I misunderstood something?
Did you copy the whole code or just what was in the start() function? It's important!
The only thing I understood the most important: elements in the buffer must go one after another (1,2,3...), i.e. without gaps (1,3,5...) and EVERY! element in the buffer must have a value assigned to it! :-)
Roman, thanks for the reply..... Unfortunately, I still don't understand one thing. In the textbook, https://book.mql4.com/ru/basics/expressions, under "Type Adduction. Option 4.1. Calculating the result of an integer type
and Variant 4.2. A similar situation occurs when looking for a result as a value of a real type", the same formula is given, but in one case, the type of the variable F is denoted as int
and in the second example, the variable is already a double
Unfortunately, I still don't understand the logic of the conversion. If in the first variant it is clear why int is assigned to variable F (i.e., according to rule of implicit type conversion), then why in the second variant they assigned double.... is completely confused me.
Please explain what I might have missed in my explanation.
Thanks in advance.
n
The interanger type is a duble type, the duble variable type has a wider range, so it is not possible that variables in an expression "have the possibility" of being of different types, and the result is a variable that has a narrower range of accepted values, in this case, the interanger type. I.e., if at least one variable in an expression is of type duble, the result must and can also be in the range of duble, otherwise there will be a compile-time error - type mismatch.
Please see here for details.
Integer is a duble type, and duble variables have a wider scope, so it is not possible for variables in an expression to "have the possibility" to be of different types, and the result is a variable which has a narrower range of accepted values, in this case, the integer type. I.e., if at least one variable in an expression is of type duble, the result must and can also be in the range of duble, otherwise there will be a compile-time error - type mismatch.
For more details, see here.
I often use implicit type conversion. But I have to use unnecessary parentheses.
Guys, what does #INF mean - is it out of allowed range of double? see second line from the top (it counts the product of double TWR, namely its previous value is multiplied by the next one). What is the correct way to count THOSE values taken by TWR variable?
If you read this section of the textbook carefully, you will see that you must first look at the expression to the left of the assignment "=":
According to the rule:
A is a variable of type double to the left, and so the value of A+Y is a number of type double.
Next, pay attention to the type of variable to which the expression is assigned.
In the first case: "first the type of expression A+Y will be converted to int type (according to the rule of calculating integers), and then this result will become the value of the integer variable F".
In the second case: "the target type of variable F (to the left of the assignment operation sign), in this case the type double, is the same as the type double of expression A+Y, so no target type conversion occurs".
Verstehen? :)))
Guys, what does #INF mean - is it out of allowed range of double? see second line from the top (it counts the product of double TWR, namely its previous value is multiplied by the next one). How to correctly count THOSE values taken by TWR variable?
Generally INFINITY (INF for short ) is infinity! :)) Yes, it turns out that double lacks power (memory) to store such a huge number.
And how to calculate correctly, I can only guess... Create Own type, conditionally: store in an additional variable digit, and double multiply by 10^n, where n is digit capacity. But in this case, accuracy is lost, and I see that your accuracy is getting worse and worse...
But it may be simpler to change the logic of calculations? :))) Or maybe there's a mistake somewhere.