artmedia70: I see you're already coming to a decision yourself
I am coming to the decision... But it's like a dog: I understand what I understand, but I can't say it, that is, I can't represent it in the code.) Maybe it's the heat that makes my brain melt.)
Shuba: I am approaching the solution... It's like a dog: I understand what I understand, but I can't say it, i.e. I can't represent it in the code.) Maybe it's the heat that makes my brain melt.)
Now I have added to the lines: if(ZZCur == High[i] && UpCount < 2) and if(ZZCur == Low[i] && DnCount < 2) checking for the next fractal higher or lower than the first one found.
I search for fractals using the ZIGZAG-FRACTALS indicator with this function:
Try searching with this function:
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 13.08.2008 |//| Описание : Возвращает номер бара фрактала по его номеру. |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента ("" или NULL - текущий символ) |//| tf - таймфрейм ( 0 - текущий ТФ) |//| nf - номер фрактала ( 0 - последний) |//+----------------------------------------------------------------------------+int GetFractalBar(string sy="0", int tf=0, int nf=0) {
if (sy=="" || sy=="0") sy=Symbol();
double f=0;
int i, k=iBars(sy, tf), kf;
for (i=2; i<k; i++) {
f=iFractals(sy, tf, MODE_LOWER, i);
if (f!=0) {
kf++;
if (kf>nf) return(i);
}
f=iFractals(sy, tf, MODE_UPPER, i);
if (f!=0) {
kf++;
if (kf>nf) return(i);
}
}
Print("GetFractalBar(): Фрактал не найден");
return(-1);
}
This function returns the bar number of the fractal. First you call it with parameter nf = 0 - the last fractal will be found, and then you call this function in the loop, where nf = cycle counter from 1 to ... as long as necessary. In the loop body, check if the next found fractal matches the criteria you need and if it does, exit the loop. After the analysis you will have the bar numbers of two fractals you need and do with them what you want.
The function returns the bar number of the fractal. First you call it with parameter nf = 0 - the last fractal will be found, and then you call this function in the loop, where nf = cycle counter from 1 to ... as long as necessary. In the loop body, check if the next found fractal matches the criteria you need and if it does, exit the loop. After the analysis you will have the bar numbers of two fractals you need and do with them what you want.
In the tester the point on the other instruments will be 0
It was in the tester,... I have not got any information about it, but I'm sure it will be useful for me. So, as a result, I made a lot of trouble with my trawl code and took KimIV's trawl pairs monitoring function. Now everything works on demo ))
Thanks for your help everyone, your explanations are very helpful.
You can't, when you initialize a variable, it just allocates an area of RAM, so why reassign it? Just reset the variable to zero, and use it as many times as you like. As a matter of fact, what's the problem? Why deinitialise a variable? It just doesn't make sense.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I see you're already coming to a decision yourself
Maybe it's the heat that makes my brain melt.)
I am approaching the solution... It's like a dog: I understand what I understand, but I can't say it, i.e. I can't represent it in the code.)
Maybe it's the heat that makes my brain melt.)
How do you search for fractals?
I look for fractals using the ZIGZAG-FRACTALS indicator with this function:
Now I have added to the lines: if(ZZCur == High[i] && UpCount < 2) and if(ZZCur == Low[i] && DnCount < 2) checking for the next fractal higher or lower than the first one found.
We have the following lines
if(ZZCur == High[i] && ZZCur > ZZFirst && UpCount < 2) and
if(ZZCur == Low[i] && ZZCur < ZZFirst && DnCount < 2)
But in the end the search is somehow inadequate :(
In the picture a thick white line shows how it should be and a thin green line shows how it is done...
I search for fractals using the ZIGZAG-FRACTALS indicator with this function:
Try searching with this function:
This function returns the bar number of the fractal. First you call it with parameter nf = 0 - the last fractal will be found, and then you call this function in the loop, where nf = cycle counter from 1 to ... as long as necessary. In the loop body, check if the next found fractal matches the criteria you need and if it does, exit the loop. After the analysis you will have the bar numbers of two fractals you need and do with them what you want.
Try searching with this function:
The function returns the bar number of the fractal. First you call it with parameter nf = 0 - the last fractal will be found, and then you call this function in the loop, where nf = cycle counter from 1 to ... as long as necessary. In the loop body, check if the next found fractal matches the criteria you need and if it does, exit the loop. After the analysis you will have the bar numbers of two fractals you need and do with them what you want.
In the tester or on the demo?
In the tester the point on the other instruments will be 0
It was in the tester,... I have not got any information about it, but I'm sure it will be useful for me. So, as a result, I made a lot of trouble with my trawl code and took KimIV's trawl pairs monitoring function. Now everything works on demo ))
Thanks for your help everyone, your explanations are very helpful.
Seems to have solved the problem, but the question remains...
How do I deinitialise a variable for reuse?
You can't, when you initialize a variable, it just allocates an area of RAM, so why reassign it? Just reset the variable to zero, and use it as many times as you like. As a matter of fact, what's the problem? Why deinitialise a variable? It just doesn't make sense.
Why deinitialise a variable?
The condition if
here we do something
otherwise if another condition
do something else.
The point is not to multiply variables, lots of conditions and counters.