Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 147
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
Please help - I can't understand why I get zero when calculating the VesMass array in i>0 values ?
It turns out that you should write not 4 and 5, but 4.0 and 5.0 - what is the logic - it's not clear to me...
Read the documentation and it will become clear. It's good that you did it yourself.
I've read about something like this before - so I decided to try it, but it's not clear where the logic behind it is... And I couldn't find the answer in the documentation, by the way.
You can write 4.0/5 or (double)4/5 - then the result is a real number.This is a peculiarity not only in MCL, in C++ and other programming languages too - division of two integers or variables of type (int) will give truncated to integer result. In your case 4/5=0.
You can write 4.0/5 or (double)4/5 - then the result is a real number.This is not only a feature of ICL, in C++ and other programming languages it is the same - dividing two integers or variables of type (int) will give a truncated result to an integer. In your case 4/5=0.
I understand that, but I don't understand the logic of the solution - i.e. the need.
I understand that, but I don't understand the logic behind the solution - i.e. the need.
Well you don't argue "why 2*2=4 in arithmetic, what is the logic of the solution"? You just take it as an axiom and use it. That's how it is with dividing two integers.
Well you don't argue "why 2*2=4 in arithmetic, what is the logic behind the solution"? You just take it as an axiom and use it. It's the same with dividing two integers.
I'll check with addition...
The line is a trend line. I changed properties to a ray. It did not help. If I wanted it to output the price regardless of the zero bar position (above, below).
This code doesn't work either.
int start() {
double pr=ObjectGetValueByShift("line",0);
If (Bid==pr){
Alert (pr);}
return(0);}
Is the line name spelled correctly?
Try this script, and show what it says in the logs.
}
The script detects the object, writes the name correctly. But the price is absolutely left-handed. It is marked on the photo with a horizontal line. It gives these prices regardless of whether the bars crossed the line or not.
The line is trending. Changed the properties to beam. It did not help. Ideally, the price should be displayed regardless of the position of the zero bar (top, bottom).
This code doesn't work either.
int start() {
double pr=ObjectGetValueByShift("line",0);
If (Bid==pr){
Alert (pr);}
return(0);}
Bid may easily jump your line, it is not obliged to stop at each point (i.e., you won't get the exact equality).
change the condition to for example if ((MathMin(Close[1],Open[0])<=pr && Bid>=pr) || (MathMax(Close[1],Open[0])>=pr && Bid<=pr)) or similar...
Bid can easily jump your line, it is not obliged to stop at every point (i.e., the exact equality will not happen)
change the condition to for example if ((MathMin(Close[1],Open[0])<=pr && Bid>=pr) || (MathMax(Close[1],Open[0])>=pr && Bid<=pr)) or similar...
Thank you! got the idea.
What if the situation is different. There are horizontal lines with different names on the chart. You need the script to calculate which line corresponds to which price.