Good evening! Pretty sure this function will produce exactly what I wanted, well almost. But the machine won't compile, it swears like this
'}' - not all control paths return a value htghtgfhthf.mq5 61 10 It's telling her I have something wrong with logic, not all returns are specified there. Yes, they are! On the contrary, if we put them after each opirator of if, it will be nonsense, the program will immediately produce the wrong result. It's short and to the point. If you can, how can you make it accept it?
string OrderType() {
string Si="";
long lo;
bool Bull=false;
Bull =PositionGetInteger(POSITION_TYPE,lo);
if ( Bull ) {
if ( lo==POSITION_TYPE_BUY) Si="OP_BUY";
if ( lo==POSITION_TYPE_SELL) Si="OP_SELL";
return (Si); }
// ENUM_ORDER_TYPE ORType;
Bull =OrderGetInteger(ORDER_TYPE,lo);
if ( Bull ) {
if ( lo==ORDER_TYPE_BUY_LIMIT) Si="OP_BUY_LIMIT";
if ( lo==ORDER_TYPE_SELL_LIMIT) Si="OP_SELL_LIMIT";
if ( lo==ORDER_TYPE_BUY_STOP) Si="OP_BUY_STOP";
if ( lo==ORDER_TYPE_SELL_STOP) Si="OP_SELL_STOP";
return (Si); }
}
Good evening! Pretty sure this function will produce exactly what I wanted, well almost. But the machine won't compile, it swears like this
'}' - not all control paths return a value htghtgfhthf.mq5 61 10 It's telling me I have something wrong with logic, not all returns are specified there. Yes, they are! On the contrary, if we put them after each opirator of if, it will be nonsense, the program will immediately produce the wrong result. It's short and to the point. If you can, how can you make it accept?
A word of advice: learn some technical English. Let me have a look at the code.
As for the subject: the function must return a value of the string type. Inside the function we use the if statement, which contains the return statements. Question: if the if statement detects that Bull == false, what should the function return?
Good evening! Pretty sure this function will produce exactly what I wanted, well almost. But the machine won't compile, it swears like this
'}' - not all control paths return a value htghtgfhthf.mq5 61 10 It's telling her I have something wrong with my logic, not all returns are specified there. Yes, they are! On the contrary, if we put them after each opirator of if, it will be nonsense, the program will immediately produce the wrong result. It's short and to the point. If it can, how to make it accept?
not all control paths return a value - there is no full control over value return.
It means that in string OrderType(), which must have a return value since the type is different from void, there is no guaranteed output with a return value.
Although you have set as many as 2 operators return, both of them are protected by the if condition. What will happen if both conditions are false?
Then the machine can jump out the window at will.
By the way, in this function it makes more sense to use switch counter, instead of a bunch of if's, which essentially do the same job as switch.
ZZZY Plus, we should not forget that the position must be preselected, as well as the order. And there is a standard function EnumToString for translation of enumerations into strings, so no need to re-invent the wheel.
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.
Good evening! Pretty sure this function will produce exactly what I wanted, well almost. But the machine won't compile, it swears like this
'}' - not all control paths return a value htghtgfhthf.mq5 61 10 It's telling her I have something wrong with logic, not all returns are specified there. Yes, they are! On the contrary, if we put them after each opirator of if, it will be nonsense, the program will immediately produce the wrong result. It's short and to the point. If you can, how can you make it accept it?
Good evening! Pretty sure this function will produce exactly what I wanted, well almost. But the machine won't compile, it swears like this
'}' - not all control paths return a value htghtgfhthf.mq5 61 10 It's telling me I have something wrong with logic, not all returns are specified there. Yes, they are! On the contrary, if we put them after each opirator of if, it will be nonsense, the program will immediately produce the wrong result. It's short and to the point. If you can, how can you make it accept?
A word of advice: learn some technical English. Let me have a look at the code.
As for the subject: the function must return a value of the string type. Inside the function we use the if statement, which contains the return statements. Question: if the if statement detects that Bull == false, what should the function return?
Aha!!! Thank you!!!
Thanks!!!!
Good evening! Pretty sure this function will produce exactly what I wanted, well almost. But the machine won't compile, it swears like this
'}' - not all control paths return a value htghtgfhthf.mq5 61 10 It's telling her I have something wrong with my logic, not all returns are specified there. Yes, they are! On the contrary, if we put them after each opirator of if, it will be nonsense, the program will immediately produce the wrong result. It's short and to the point. If it can, how to make it accept?
not all control paths return a value - there is no full control over value return.
It means that in string OrderType(), which must have a return value since the type is different from void, there is no guaranteed output with a return value.
Although you have set as many as 2 operators return, both of them are protected by the if condition. What will happen if both conditions are false?
Then the machine can jump out the window at will.
By the way, in this function it makes more sense to use switch counter, instead of a bunch of if's, which essentially do the same job as switch.
ZZZY Plus, we should not forget that the position must be preselected, as well as the order. And there is a standard function EnumToString for translation of enumerations into strings, so no need to re-invent the wheel.
I don't understand why OnTick is called although the price does not change?????
2012.09.10 11:52:11 Sample_Tick (EURUSD,M5) 493 1.2787 1.2789 1.2788 300000
2012.09.10 11:52:10 Sample_Tick (EURUSD,M5) 492 1.2787 1.2789 1.2788 300000
2012.09.10 11:52:09 Sample_Tick (EURUSD,M5) 491 1.2787 1.2789 1.2788 300000
2012.09.10 11:52:07 Sample_Tick (EURUSD,M5) 490 1.2787 1.2789 1.2788 300000
I do not understand why OnTick is triggered although price does not change?????
2012.09.10 11:52:11 Sample_Tick (EURUSD,M5) 493 1.2787 1.2789 1.2788 300000
2012.09.10 11:52:10 Sample_Tick (EURUSD,M5) 492 1.2787 1.2789 1.2788 300000
2012.09.10 11:52:09 Sample_Tick (EURUSD,M5) 491 1.2787 1.2789 1.2788 300000
2012.09.10 11:52:07 Sample_Tick (EURUSD,M5) 490 1.2787 1.2789 1.2788 300000
the time of the last price update does not change either?
2012.09.10 15:37:20 Sample_Tick (EURUSD.m,M5) 20 1.27841 1.27852 1.27841 2000000 2012.09.10 14:37:19
2012.09.10 15:37:20 Sample_Tick (EURUSD.m,M5) 19 1.27841 1.27852 1.27841 2000000 2012.09.10 14:37:19
2012.09.10 15:37:20 Sample_Tick (EURUSD.m,M5) 18 1.27841 1.27852 1.27841 2000000 2012.09.10 14:37:18
or
2012.09.10 15:37:12 Sample_Tick (EURUSD.m,M5) 6 1.27835 1.27845 1.27835 1000000 2012.09.10 14:37:11
2012.09.10 15:37:12 Sample_Tick (EURUSD.m,M5) 5 1.27835 1.27845 1.27835 1000000 2012.09.10 14:37:11
2012.09.10 15:37:12 Sample_Tick (EURUSD.m,M5) 4 1.27835 1.27845 1.27835 1000000 2012.09.10 14:37:10
2012.09.10 15:37:20 Sample_Tick (EURUSD.m,M5) 20 1.27841 1.27852 1.27841 2000000 2012.09.10 14:37:19