Tranfer Processing Control

 

Hi All,

How do I transfer program control, in MQL4, to a specific line?


For Example, using VBA you could go after, Line #1 to Line #6 (Skipping line #2-#5).


Code Line #1

GoTo ResumeHere

Code Line #2

Code Line #3

Code Line #4

Code Line #5

GoTo ResumeHere:

Code Line #6


Many Thanks


Ross Crill

 
There is no such thing as a goto or line numbers.
Your post
 Code
Code Line #1

GoTo ResumeHere

Code Line #2

Code Line #3

Code Line #4

Code Line #5

GoTo ResumeHere:

Code Line #6
Code Line #1

if(!performLines2_5){

   Code Line #2

   Code Line #3

   Code Line #4

   Code Line #5

}

Code Line #6
MT4: Learn to code it.
MT5: Begin learning to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
 

So how would I do this?

I have a series of If statements (about 20 IFs)


If (Num #1)

{

Do Num #1

Go to End of Routine \\ Don't perform any other Ifs on the current tick

}

If (Num #2}

{

Do Num #2

Go to End of Routine \\ Don't perform any other Ifs on the current tick

}

If (Num #3}

{

Do Num #3

Go to End of Routine \\ Don't perform any other Ifs on the current tick

}


Thanks William


Ross

 
Seems we are back in the 80's.
 
rcrill:

Hi All,


How do I transfer program control, in MQL4, to a specific line?

As stated, there are no GOTO statements in MQL. You need to find another way.

I just use a while statement, for multiple if statements all needed to be true;. But you could use Switch or branch off to another function, or return; Depends how your EA works.

bool ok=false; 
while(true){
  if(!cond1)break;
  if(!cond2)break;
  
  ok=true;
 break;
 }
 
rcrill:

So how would I do this?

I have a series of If statements (about 20 IFs)


If (Num #1)

{

Do Num #1

Go to End of Routine \\ Don't perform any other Ifs on the current tick

}

If (Num #2}

{

Do Num #2

Go to End of Routine \\ Don't perform any other Ifs on the current tick

}

If (Num #3}

{

Do Num #3

Go to End of Routine \\ Don't perform any other Ifs on the current tick

}

if (cond_1)
  {
   // task #1
  }
else
if (cond_2}
  {
   // task #2
  }
else
if (cond_3}
  {
   // task #3
  }
else
...
Reason: