
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
This is also correct if "cnt" is set to zero, but then the value is again incomprehensible as in screenshot 3 (should be a profit value of 4.27)
int cnt=0;
double LastProfit=0;
for(i=0;i<OrdersHistoryTotal();i++)
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) && (OrderType()==OP_BUY || OrderType()==OP_SELL) && OrderSymbol()==Symbol() && OrderMagicNumber()==magic) {
if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
if ((op<0 || OrderType()==op) && cnt==0) {LastProfit+=OrderProfit()+OrderCommission()+OrderSwap(); cnt++;} else {cnt=0;}
}
return(LastProfit);
}
It's not good when I do not have logical thinking(
You see, in the real market the deposit will melt in 3 days with this kind of logic.
It's bad when you don't think logically(
That's right.
The pending order was deleted
That's right.
The pending order has been deleted
OK, then how do you return a ticket of closed orders that are equal to OrderCloseTime() and calculate their profit?
Like this:
OK, then how do you return a ticket of closed orders that are equal to OrderCloseTime() and calculate their profit?
Something like this:
What if it closes on a stop?
ticket=OrderClose(......);
if(ticket>0){//увеличить размер массива на один и записать тикет закрытого ордера}
What if it closes on a stop?
ticket=OrderClose(......);
if(ticket>0){//увеличить размер массива на один и записать тикет закрытого ордера}
Well, what arrays, what tickets, what orders?
After the first restart of the terminal, or shutdown over the weekend, you will simply lose all the data, and that will be the end of all the writing and calculations.
For example, when I was writing for myself the system of counting accumulated drawdown or profit, it looked like this: for each market order during the opening a global variable with the ticket name of this order is created and when we want to recalculate the profit/loss, we simply check the current order list against the list of global variables and perform the calculation by deleting the excess variables and adding the profit directly to the ticket from the name.
This is a heavy load on the system, in an indicator it works fine, but in an EA the enumeration of a dozen global variables may cause the terminal to freeze.
There is an opening and closing time, you have to work with it, and there is no difficulty in getting it, and with one time record you can get all the information about the state of the account, and you don't need a bicycle.
What arrays, what tickets, what orders?
After the first restart of the terminal, or a weekend shutdown, you will simply lose all the data, and that will be the end of all the writing and calculations.
it's solvable
I don't have to explain it to you.
This is a heavy load on the system, in an indicator it works fine, but in an EA the enumeration of dozens of global variables can end up with a hang of the terminal.
There are opening and closing times, that's what you need to work from, and there's no difficulty in getting it, with one time record you can get all the information about the state of the account, and you don't need a bicycle.