MqL4 Fractals
double array[4]; int count = 0; for(int i=0; i<Bars; i++) { double val = iFractals(NULL,0,MODE_UPPER,i); if(val!=0 || val!=EMPTY_VALUE) { array[count] = val; count++; If(count==4) break; } }
Typed on the phone. Not compiled and tested.
Typed on the phone. Not compiled and tested.
1. Please insert the code correctly: when editing a message, press the button
and paste your code into the pop-up window.
2. All questions about the old terminal should be discussed only in a dedicated section: MQL4 and MetaTrader 4 . I will move your topic to the specified section.
double array[4]; int count = 0; for(int i=0; i<Bars; i++) { double val = iFractals(NULL,0,MODE_UPPER,i); if(val!=0 || val!=EMPTY_VALUE) { array[count] = val; count++; If(count==4) break; } }
Typed on the phone. Not compiled and tested.
if(val!=0 || val!=EMPTY_VALUE)
This will always return true.
You probably mean to use && not ||
This will always return true.
You probably mean to use && not ||
This will always return true.
You probably mean to use && not ||
Please I have trouble still understanding arrays and how to quote them with a loop in a function. But I really want to learn and understand it . I'll be grateful if you could provide me with a document to read on it. Or some little explanation with examples will do it.
You have used the array correctly in your code.
I don't think that there is a single document that fully explains using arrays.
When you encounter a problem, post your code and explain what you are trying to do. Someone will help.
You have used the array correctly in your code.
I don't think that there is a single document that fully explains using arrays.
When you encounter a problem, post your code and explain what you are trying to do. Someone will help.
double Fractal[5]; int count = 0; for(int i=0; i<Bars; i++){ double Fvalue = iFractals(_Symbol,_Period,MODE_UPPER,i); if(Fvalue!=0 && Fvalue!=EMPTY_VALUE) { Fractal[count] = Fvalue; count++; if(count==4) break; string signal=""; if(Fractal[0]>Fractal[2] ) { signal="bullish"; if (signal=="bullish" ) { Comment("signal is buy"); } else { Comment("No signal"); }
please image description below, but i have problem with the array in the code
please image description below, but i have problem with the array in the code
Oh now I see what you are trying to achieve. Well in this case you could try
double arrUp[4],arrDn[4],val=0; int count = 0; int i = 0; datetime foundUp = 0; datetime foundDn = 0; for(i=0; i<Bars; i++) { val = iFractals(NULL,0,MODE_UPPER,i); if(val!=0) { arrUp[count] = val; if(count==0) foundUp = Time[i]; count++; if(count==4) break; } } count = 0; for(i=0; i<Bars; i++) { val = iFractals(NULL,0,MODE_LOWER,i); if(val!=0) { arrDn[count] = val; if(count==0) foundDn = Time[i]; count++; if(count==4) break; } } if(foundUp>foundDn) //Buy condition valid as per your logic if(arrUp[0]>arrUp[1]) //Buy //Opposite for sell
But I still believe there may be smarter ways to do it. You should also consider that the current fractal repaints.
Again not compiled and tested
hi guys
i'm new to mql4 and trying to write a code for the current four Fractals where i want some form of identification for the previous fractals. Problem is i'm stuck at the array. Please any help with the code would be much appreciated
below is what i have been able to do.
***