Help me with this part of my code

To add comments, please log in or register
FARHANG
141
FARHANG  
Hi, the code below is intended to find the the closest tops and bottoms to the current time and report when there has been a breakout. I would appreciate it if you can point out the bug(s) to me. The problem is it also reports breakout of previous tops and bottoms not only the nearest ones.

double check,
check1;
int start()
  {
  double min=Low[4],
         max=High[4];
    int a=23,
        m=5,
       n=5,
      x=23,
      y=14,
      b=14;
    //here we find the nearest tops and lows//
  for(int c=m;c<a;c++)
 {
  if (Low[c]<=min)
   min=Low[c];
  if (c!=a-1)
  continue;
  if (min==Low[b])
   {
  break;
   }       
a++;
b++;
m++;
 }
 for(int z=n;z<x;z++)
 {
  if (High[z]>=max)
   max=High[z];
  if (z!=x-1)
  continue;
  if (max==High[y])
       {    
  break;
       }     
   x++;
 y++;
 n++;      
 }
 //calculating the breakout
       if (((Close[1]<min || (Close[2]<min || Close[3]<min)) && Close[4]>min) && check!=Close[1]-High[1])
 {
 Alert("min is ", min, "breakout");
 check=Close[1]-High[1];
 }
 if (((Close[1]>max || (Close[2]>max || Close[3]>max)) && Close[4]<max) && check1!=Close[2]-High[2] )
  {
  Alert("max is " , max, "breakout");
  check1=Close[2]-High[2];
  }
   return;
  }
Ickyrus
878
Ickyrus  

I think you need to check your understanding of the continue and break loop flow control statements.

Trying putting the continue on the same line as for example if () {dosomthing(); continue} ; and remember that this takes you the } close of the for loop
The break takes you out of the for loop.

FARHANG
141
FARHANG  
Ickyrus wrote >>

I think you need to check your understanding of the continue and break loop flow control statements.

Trying putting the continue on the same line as for example if () {dosomthing(); continue} ; and remember that this takes you the } close of the for loop
The break takes you out of the for loop.


I'm sorry but I didn't quite get what you were trying to say . Please elaborate a little more with some examples if possible.
Ickyrus
878
Ickyrus  

In your mind what is the next thing that should be done after the exection of the continue instruction?
-
if the answer is a++; b++ ; m++ then the code is NOT working as you intended it
-
if the answer is it increments the c variable and does another execution of the loop then it is working as intended.

FARHANG
141
FARHANG  
The second one. I know what continue; does and I don't think I asked for a basic programming lesson. I made myself perfectly clear as to what I need the code to be doing and what it does instead and I'm looking for possible bug(s) in my program which I obviously could not find. Please only give me a solution or a suggestion if you have one. Thanks in advance!
Ickyrus
878
Ickyrus  
farhang wrote >>
The second one. I know what continue; does and I don't think I asked for a basic programming lesson. I made myself perfectly clear as to what I need the code to be doing and what it does instead and I'm looking for possible bug(s) in my program which I obviously could not find. Please only give me a solution or a suggestion if you have one. Thanks in advance!

Sorry
I was avoiding the heavy concentration of pretending to be a computer and write numbers down for each instruction.
-
-
if (min==Low[b]) break; // if min equal to low[14] we have found low but min is a double precision value so it is difficult for two doubles to be exactly the same
-
If(min>=Low[b]-0.0001 && min<=Low[b]+0.0001) break ; //choose a range accuracy for a floating point number
Ickyrus
878
Ickyrus  

Thought - why not use the fractal indicator to find the last low and high?

FARHANG
141
FARHANG  
Still the same. It finds previous tops and bottoms as well.
FARHANG
141
FARHANG  
Ickyrus:

Thought - why not use the fractal indicator to find the last low and high?


Where can I find the code for that indicator?
Ickyrus
878
Ickyrus  
farhang wrote >>


Where can I find the code for that indicator?


https://www.mql5.com/en/code/7982
FARHANG
141
FARHANG  
Ickyrus thanks a lot but I really don't need YOUR help. Right now I'm one more link answer away from going wacko on y'all. Can't anybody in this god forsaken forum just help me with the code I have posted since god knows when? And please keep your thoughts about why don't you do this or that to yourselves. Isn't there a professional here who can simply point out to me what I'm doing wrong so everyone can live happily ever after? Am I asking for too much?
12
To add comments, please log in or register