Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 891
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good afternoon! Always after disabling and enabling "Allow EA to trade" a position opens that should not open. I assume that this is because the variables are not reset. How can I reset all variables after enabling or disabling "Allow EA to trade", as they are after restarting the MT4 platform?
You just need to reset those variables at the moment when this very checkbox is unchecked and not to touch them again until a user activates it again. Watch for MQLInfoInteger(MQL_TRADE_ALLOWED).
You just need to reset those variables at the moment when this very checkbox is unchecked and not to touch them again until a user activates it again. Watch for MQLInfoInteger(MQL_TRADE_ALLOWED).
This is the same branching as if(), it just looks neater and is easier to code if there are three or more single choices of integers to choose from. If there are only two variants, or non-integer expressions are compared, then only if(). Also, with if() you can combine several options (if( option1 && option2 || option3 ) {action;}), while switch cannot do it directly, only one at a time.
{
case 1: action on option 1; break;
case 2: action on option 2; break;
case 3: action on option 3; break;
default: default action; break;
}
else if( option2 ) { actions by option 2; }
else if( option3 ) { actions by option 3; }
else { default action; }
Thank you! I didn't see such a comparison in the tutorial, although maybe I'm just reading out of order.
Anyway, this is exactly what a beginner expects from a professional - to disclose subtleties that you won't find either in a textbook or in a reference.
Again with the question: is there an attachment restriction (see SRC) in the if-else loop? I can't find a reason why such primitive code doesn't work.
What exactly is wrong?
Everything :( When testing, the position opens immediately according to criteria not specified in the code, and does not close it until the end of testing, i.e. it ignores all the conditions for closing, prescribed in the code.
It is not clear whether closing conditions are specified incorrectly orthe position opened is not readable.
Everything :( During testing, the position is opened immediately, according to criteria not specified in the code, and does not close it until the end of testing, i.e. it ignores all the conditions for closing prescribed in the code.
It is not clear whether closing conditions are defined incorrectly or the open position is not readable.
In such cases, where it is not clear where the problem is, it is recommended that after each action a print describing the action (and the error output if necessary) is inserted.
Thank you. It's a lot of work, but it looks like I won't be able to find the error otherwise.
Hello.
Can you tell me how to find out the distance in pips from the current price to the maximum price of the last 10 bars?
I know the distance to the high of the 10th bar:
Idon't knowhow to find the maximum high of 10 bars and remember it.
Please help me.
Look at CopyHigh and ArrayMaximum, it will be a bar with a maximum.
Just pay attention to the direction of array indexing in CopyHigh function