Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 961

 
goodearth:

Damn right! I keep forgetting that. Thanks for reminding me.

Is there no way around this restriction?


There is a control for the number of bars required for the calculation.

if (Bars<MinBar) return;
 
rapid_minus:
On three of the symbols there is a councillor "according to Sleptsov" and on the fourth another councillor. Do they interfere with each other? I have never seen any mention that only one EA must be placed on one symbol on MT4.
No, there are no such restrictions. The question was whether an extraneous EA may close all orders. And we should check whether there is no condition to close all of the orders of another EA. Or at least check whether such a problem will occur if only one EA is set.
 
AlexeyVik:
No, there are no such restrictions. The question was whether an alien EA cannot close all the orders. And we should check whether there is no condition to close all of the orders of others in it. Or at least check if there will be such a problem if only one EA has been set.
Thank you. I will try on Monday. But in this case, the foreign EA should close only losing orders on all symbols. How does it look in the code? I have not encountered this yet.
 
AlexeyVik:

Please clarify, I am totally confused:

I found a script that closes orders with profit or with minus, but I don't understand the logic - bool close_only_profit_orders=false is set in external variables and then it is checked with negation in f-i start: if(OrderType()==OP_BUY && (!close_only_profit_orders || order_prof>0). That is, if it is not false or there are orders with a profit, then the OrderClose() function follows. But nowhere in the code, there are no conditions for the variable close_only_profit_orders to become true. Then what is it for at all?

 
rapid_minus:

Please clarify, I am totally confused:

I found a script that closes orders with profit or with minus, but I don't understand the logic - bool close_only_profit_orders=false is set in external variables and then it is checked with negation in f-i start: if(OrderType()==OP_BUY && (!close_only_profit_orders || order_prof>0). That is, if it is not false or there are orders with a profit, then the OrderClose() function follows. But nowhere in the code, there are no conditions for the variable close_only_profit_orders to become true. Then what is it for at all?


If bool close_only_profit_orders=true;, then only profitable ones will be closed.

That is so.

 
r772ra:

If, bool close_only_profit_orders=true; then only profitable ones are closed.

That is so.

But nowhere in the code, there are no conditions according to which the variable close_only_profit_orders becomes true, i.e. it will never become true unless we make ittrue ourselves, as this is an external variable. So,if we make ittrue, it will mean that we should not close profitable orders. But then there is a contradiction with OR -|| order_prof>0.

Or rather the opposite : if it is false, we should not close, and then there is a contradiction, and iftrue, then everything is fine...(?)

Completely confused.

 
rapid_minus:
But nowhere in the code is there a condition for the close_only_profit_orders variable to become true, i.e. it will never become true.

It is up to you whether to close all or just the profitable ones.

 
rapid_minus:

But nowhere in the code is there any condition for the variable close_only_profit_orders to become true, i.e. it will never become true unless we make ittrue ourselves, as this is an external variable. So,if we make ittrue, it will mean that we should not close profitable orders. But then there is a contradiction with OR -|| order_prof>0.

Or rather the opposite : if it is false, we should not close, and then there is a contradiction, and iftrue, then everything is fine...(?)

Totally confused.

Logic!

extern boolclose_only_profit_orders = false; // Close any, profit and loss positions, of course, according to some conditions.

extern boolclose_only_profit_orders = true; // only profitable positions are closed, losing ones are not closed either, according to some conditions.

You can check in the tester which variant is better! Or in optimization mode 0 = false and 1 = true.

 
Thank you all
 
rapid_minus:

Please clarify, I am totally confused:

Found a script that closes orders with profit or with minus, but I don't understand the logic - bool close_only_profit_orders=false is set in external variables and then it is checked with negation in f-i start: if(OrderType()==OP_BUY && (!close_only_profit_orders || order_prof>0). That is, if it is not false or there are orders with a profit, then the OrderClose() function follows. But nowhere in the code, there are no conditions under which the variable close_only_profit_orders becomes true. Then what is it for?


There is nothing to be found by this variable. This is a figment of the programmer's imagination; only the developer knows what is in your EA. I can only speculate for what reason this can happen and how to check it. I've just met an EA that stupidly closed all the orders on all pairs before it started working. Well, that's a figment of the programmer's imagination. Thus, if your Expert Advisor will work as it should, we have to look for where it was written to close orders and for what reason. Maybe, different magicians will help.
Reason: