And how, of these, customisable, fractals, do you choose the maximum one?
//| nl - количество баров слева | //| nr - количество баров справа | //+----------------------------------------------------------------------------+ double GetNearestUpFractal(string sy="0", int tf=0, int nl=2, int nr=2) { bool f; int fb, i, nb=-1;
if (sy=="" || sy=="0") sy=Symbol(); if (nl<1) nl=1; if (nr<1) nr=1;
fb=nr; while (nb<0) { fb++; f=True; for (i=fb; i>fb-nr; i--) { if (iHigh(sy, tf, i)<iHigh(sy, tf, i-1)) { f=False; break; } } if (f) { for (i=fb; i<fb+nl; i++) { if (iHigh(sy, tf, i)<iHigh(sy, tf, i+1)) { f=False; break; } } if (f) { nb=fb; break; } } }
And how, of these, customisable, fractals, do you choose the maximum one?
//| nl - количество баров слева | //| nr - количество баров справа | //+----------------------------------------------------------------------------+ double GetNearestUpFractal(string sy="0", int tf=0, int nl=2, int nr=2) { bool f; int fb, i, nb=-1;
if (sy=="" || sy=="0") sy=Symbol(); if (nl<1) nl=1; if (nr<1) nr=1;
fb=nr; while (nb<0) { fb++; f=True; for (i=fb; i>fb-nr; i--) { if (iHigh(sy, tf, i)<iHigh(sy, tf, i-1)) { f=False; break; } } if (f) { for (i=fb; i<fb+nl; i++) { if (iHigh(sy, tf, i)<iHigh(sy, tf, i+1)) { f=False; break; } } if (f) { nb=fb; break; } } }
return(iHigh(sy, tf, nb)); }
#property strict
voidOnStart() { int i=1,cnt=1; double lastupfr=0;
while(cnt<5) { double upfr=GetNearestUpFractal(_Symbol,0,2,2); if(upfr!=0) { if(upfr>lastupfr) lastupfr=upfr; cnt++; } i++; } Comment("Biggest UpFractal = ",lastupfr); } //----------- //| nl - количество баров слева | //| nr - количество баров справа | //+----------------------------------------------------------------------------+ double GetNearestUpFractal(string sy="0", int tf=0, int nl=2, int nr=2) { bool f; int fb, i, nb=-1;
if (sy=="" || sy=="0") sy=Symbol(); if (nl<1) nl=1; if (nr<1) nr=1;
fb=nr; while (nb<0) { fb++; f=True; for (i=fb; i>fb-nr; i--) { if (iHigh(sy, tf, i)<iHigh(sy, tf, i-1)) { f=False; break; } } if (f) { for (i=fb; i<fb+nl; i++) { if (iHigh(sy, tf, i)<iHigh(sy, tf, i+1)) { f=False; break; } } if (f) { nb=fb; break; } } }
Alexey Kozitsyn: Um... You need to select the 4 fractals set up for selection, and by blowing away the worthless inferior fractals, leave one Maximka:)
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.
Hello, can you please help me find the price of the larger fractal, from the first - near top four fractals.
Hello, can you please help me find the price of the larger fractal, from the first - near top four fractals.
{
Comment("Min = ",MaxMinFractal(MODE_LOWER, 4),"; Max = ",MaxMinFractal(MODE_UPPER, 4));
}
//===============================================================================================
//--------------------------------- Возвращает Max/Min фрактала --------------------------------+
//===============================================================================================
double MaxMinFractal(int mode=MODE_UPPER, int nf=4) {
string symb=Symbol();
double f=0,min=9999999,max=0;
int kf=0;
for(int i=3; i<iBars(symb, 0); i++) {
if(mode==MODE_LOWER){
f=iFractals(symb, 0, MODE_LOWER, i);
if(f!=0) {
kf++;
if(min>iLow(symb,0,i)) min=iLow(symb,0,i);
if(kf>=nf) return(min);
}}
if(mode==MODE_UPPER){
f=iFractals(symb, 0, MODE_UPPER, i);
if(f!=0) {
kf++;
if(max<iHigh(symb,0,i)) max=iHigh(symb,0,i);
if(kf>=nf) return(max);
}}}
return(-1);
}
Hello, can you please help me find the price of the larger fractal, from the first - near top four fractals.
void OnStart()
{
int i=1,cnt=1;
double lastupfr=0;
while(cnt<5)
{
double upfr=iFractals(_Symbol,0,1,i);
if(upfr!=0)
{
if(upfr>lastupfr) lastupfr=upfr;
cnt++;
}
i++;
}
Comment("Biggest UpFractal = ",lastupfr);
}
Even shorter ) Thank you.
And how, of these, customisable, fractals, do you choose the maximum one?
//| nr - количество баров справа |
//+----------------------------------------------------------------------------+
double GetNearestUpFractal(string sy="0", int tf=0, int nl=2, int nr=2) {
bool f;
int fb, i, nb=-1;
if (sy=="" || sy=="0") sy=Symbol();
if (nl<1) nl=1;
if (nr<1) nr=1;
fb=nr;
while (nb<0) {
fb++;
f=True;
for (i=fb; i>fb-nr; i--) {
if (iHigh(sy, tf, i)<iHigh(sy, tf, i-1)) { f=False; break; }
}
if (f) {
for (i=fb; i<fb+nl; i++) {
if (iHigh(sy, tf, i)<iHigh(sy, tf, i+1)) { f=False; break; }
}
if (f) { nb=fb; break; }
}
}
return(iHigh(sy, tf, nb));
}
Even shorter ) Thank you.
And how, of these, customisable, fractals, do you choose the maximum one?
//| nr - количество баров справа |
//+----------------------------------------------------------------------------+
double GetNearestUpFractal(string sy="0", int tf=0, int nl=2, int nr=2) {
bool f;
int fb, i, nb=-1;
if (sy=="" || sy=="0") sy=Symbol();
if (nl<1) nl=1;
if (nr<1) nr=1;
fb=nr;
while (nb<0) {
fb++;
f=True;
for (i=fb; i>fb-nr; i--) {
if (iHigh(sy, tf, i)<iHigh(sy, tf, i-1)) { f=False; break; }
}
if (f) {
for (i=fb; i<fb+nl; i++) {
if (iHigh(sy, tf, i)<iHigh(sy, tf, i+1)) { f=False; break; }
}
if (f) { nb=fb; break; }
}
}
return(iHigh(sy, tf, nb));
}
void OnStart()
{
int i=1,cnt=1;
double lastupfr=0;
while(cnt<5)
{
double upfr=GetNearestUpFractal(_Symbol,0,2,2);
if(upfr!=0)
{
if(upfr>lastupfr) lastupfr=upfr;
cnt++;
}
i++;
}
Comment("Biggest UpFractal = ",lastupfr);
}
//-----------
//| nl - количество баров слева |
//| nr - количество баров справа |
//+----------------------------------------------------------------------------+
double GetNearestUpFractal(string sy="0", int tf=0, int nl=2, int nr=2) {
bool f;
int fb, i, nb=-1;
if (sy=="" || sy=="0") sy=Symbol();
if (nl<1) nl=1;
if (nr<1) nr=1;
fb=nr;
while (nb<0) {
fb++;
f=True;
for (i=fb; i>fb-nr; i--) {
if (iHigh(sy, tf, i)<iHigh(sy, tf, i-1)) { f=False; break; }
}
if (f) {
for (i=fb; i<fb+nl; i++) {
if (iHigh(sy, tf, i)<iHigh(sy, tf, i+1)) { f=False; break; }
}
if (f) { nb=fb; break; }
}
}
return(iHigh(sy, tf, nb));
}
So returns the price of the nearest fractal.
How do I find the maximum of the four configurable fractals?
So returns the price of the near fractal.
How do I find the maximum of the four configurable fractals?
Um... You need to select the 4 fractals set up for selection, and by blowing away the worthless inferior fractals, leave one Maximka:)
How do you do it?