Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 243

 
Jenya77769:

Thank you, it worked, only I normalised q and w separately!

You need to normalize the difference of two numbers. And compare it to zero.
 
Artyom Trishkin:
If it's the tenth bar, how do I know the difference between the tenth and zero bar? 10-0=10
And why do I need to subtract it?


We can see on the paper that 10 - 0 = 10. But how do we write this condition into the program. I haven't found a function that would return the bar number. Or maybe I searched too hard?

 
Youri Lazurenko:

We can see on the paper that 10 - 0 = 10. But how do we write this condition into the program. I haven't found a function that would return the bar number. Or was I looking too hard?

Well, you have already found this bar. In the function that looks for the intersection.
 
Artyom Trishkin:
Well, you've ALREADY found that bar. In the function that looks for the intersection.
Yes, I found it. I think while writing your answer I understood your point - IntersectionXX() function just gives me this number, let it be 10. Did I get it right?
 
double SPREAD=MarketInfo(Symb,MODE_SPREAD);// Спред
 double q=High[0]-3.0*Point-High[1];
double w=-SPREAD*Point;

if(NormalizeDouble(q,4)> NormalizeDouble(q,4))
Artyom Trishkin
:

Normalise the difference between the two numbers. And compare it to zero.

And the way I did it, could there be mistakes?

 
Youri Lazurenko:
Yes, I found it. I think I got your point while writing the answer - IntersectionXX() is exactly what gives me this number, let it be 10. Did I get it right?
Yes
 
Artyom Trishkin:
Yes

Thank you very much. Yes, my logic, imagination and judgement are a bit lacking. Thank you again, and all the best.

 

Hello! I wanted to get the opening time of the current month's bar, but got an error 4074 (ERR_NO_MEMORY_FOR_HISTORY). It's also interesting that if I start testing from June 1, everything is correct, but from June 2 the error starts to appear. How to solve this month's problem?

   datetime iTimeMN=iTime(NULL,PERIOD_MN1,0);
   Print("iTimeMN= ",iTimeMN);
   if(iTimeMN==0)
     {
      Print(" Error= ",GetLastError());
      Sleep(1000);
     }
 

Hello all, please help with changing the values of the variables. There are two variables with an initial value of zero. For example I always have two levels on the chart. How to make so that when one level is reached the first variable changes value to "1" and only when the other level is reached it changes value back to "0", while the second variable acts in the opposite way.

 
AlGuru:

Hello all, please help with changing the values of the variables. There are two variables with an initial value of zero. For example I always have two levels on the chart. How to make, that at achievement of one level the first variable has changed value to "1" and only at achievement of other level has changed value back to "0", whereas the second variable has acted in an opposite way.


Everything seems to work. It didn't work at first though. Strange.

Reason: