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
kombat 17.07.2009 22:13
Add up, get the buy-summer 3 lots and counter this volume with sell 3 lots.
.......................
As an option, yes. Although, if there are already open Sell orders, the EA may close not the ones you need. It should be solved.
kombat 17.07.2009 22:13.
But to answer your question: is it possible to close all positions?
yes it is, one by one, it's quick script, aap! and that's it...
.........................
That's what I'm using now. A set of scripts - you use this one and that one... But I tried to code my strategy into Expert Advisor and encountered a number of difficulties.
I have something that does not work here, it means it does not close no errors.
In the ClosePositions() function, its b-Positions.mqh library, KimIV uses a call to its other ClosePosBySelect() function which prohibits the use of ee in the tester :
if (!IsTesting() && (!IsExpertEnabled() || IsStopped())) break;
For history tests use his library b-ForTest.mqh
In the ClosePositions() function, its b-Positions.mqh library, KimIV uses a call to its other function ClosePosBySelect() which prohibits using ee in the tester :
if (!IsTesting() && (!IsExpertEnabled() || IsStopped())) break;
For history tests, use his library b-ForTest.mqh
You misunderstood my code... Translating into Russian... If NOT test mode AND (EA is NOT allowed to trade OR the Expert Advisor is stopped), then abort loop. To put it simply, this line ensures exit from the loop, when you press button "Expert Advisors" on the toolbar.
Good evening,
Unfortunately, there is a discrepancy with the array as well... When order counting is done with a condition if lots are bigger than 0 (Lts>0), lots are closed one by one (when profit has been reached), but total profit should be taken into account:
And at condition in orders count, if lots are more than 1 (Lts>1), lots are not closed:
Please advise who can see the error.
Or maybe, Igor, I have a misunderstanding of using your function?
BuyOrdProf=GetProfitOpenBuyPosInCurrency(OP_BUY); // Call function
Igor, please tell me how to insert your PriceOpenLastPos function into the indicator.
When compiling the editor gives error on the first bracket and subsequent variables.
double PriceOpenLastPos( string sy="", int op=-1, int mn=-1) {
datetime t;
double r=0;
int k=OrdersTotal();
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy==") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (t<OrderOpenTime()) {
t=OrderOpenTime();
r=OrderOpenPrice();
}
}
}
}
}
}
}
return(r);
}
}
'(' - function definition unexpected D:\MT4\experts\indicators\Astrea.mq4 (627, 24)
'sy' - variable not defined D:\MT4\experts\indicators\Astrea.mq4 (632, 7)
etc.
I implement the logic of trading signals formation in an indicator and send the generated signal to the Expert Advisor via a global variable to open/close orders.
I need the open price of an order to make some decisions, so I am trying to do that. My indicator is a dynamic one and it can be debugged only in demo mode or in Visualisation mode in a tester.
The picture is that it is not the total profit that is taken into account, but the profit of the individual orders.
BuyOrdProf=GetProfitOpenBuyPosInCurrency(OP_BUY); // Function call
Incorrect parameter passing into the function. It should be like this:
Incorrect parameter passing into the function. It should be like this:
Adding a binding to the symbol in the function call doesn't help. Why does it count the profit for each position separately (picture above)?