-
Don't post pictures of code, they are too hard to read.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
You have braces between your cases. They are unnecessary/redundant. And are confusing you.
-
When your code reaches case 2 from case 1, it will continue into case 2. You have no break statement to stop case 1.
- Your return false (line 31) is still part of case 2. You have no end of switch brace.
-
Don't post pictures of code, they are too hard to read.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
You have braces between your cases. They are unnecessary/redundant. And are confusing you.
-
When your code reaches case 2 from case 1, it will continue into case 2. You have no break statement to stop case 1.
- Your return false (line 31) is still part of case 2. You have no end of switch brace.
-
Don't post pictures of code, they are too hard to read.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
You have braces between your cases. They are unnecessary/redundant. And are confusing you.
-
When your code reaches case 2 from case 1, it will continue into case 2. You have no break statement to stop case 1.
- Your return false (line 31) is still part of case 2. You have no end of switch brace.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hey guys, i have a simple code that i to want make a bool custom function that looks for 2 simple patterns and if there is a pattern, takes true value (and print hello) and if not False, but when i want to code it with switch cases it gives me error. i only want it to take a number and bring it to custom function and play with it with cases.
void OnTick(){
int x=1; // i will add a for loop for this variable later
if(check(x))
Print("hello");
}
bool check(int x)
{ double open1=iOpen(Symbol(),PERIOD_D1,1); double close1=iClose(Symbol(),PERIOD_D1,1); double high1=iHigh(Symbol(),PERIOD_D1,1);
double low1=iLow(Symbol(),PERIOD_D1,1); double range=high1-low1;
double body;
switch(x)
{
case 1:
{
if(close1>open1) { //this 4 line says if candle had long talis take true value
body=close1-open1;
if(halfrange > body)
return(true);
}
}
case 2:
{
if(open1>close1) { //this 4 line says if candle had long talis take true value
body=open1-close1;
if(halfrange > body)
return(true);
}
}
return(false);
}