| / | Forum |
|
pwfx
2006.09.11 19:13
can anyone guide me how to total up ? why the function of "TotalProfit"
in MQL II no longer be used in MQL4?
|
|
Two-Stage Modification of Opened Positions The two-stage approach allows you to avoid the unnecessary closing and re-opening of positions in situations close to the trend and in cases of possible occurrence of divirgence. |
|
codersguru
2006.09.12 16:21
Here's TotalProfit() back:
double TotalProfit() { int total = OrdersTotal(); double MyCurrentProfit=0; for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); MyCurrentProfit += OrderProfit(); } Return(MyCurrentProfit); } Hope it helps! |
|
pwfx
2006.09.27 23:56
Thanks, Codersguru.
I tried and managed to total up all open trades P/L. Further if we want to total the profit/loss of only 2 or 3 specific open trades out of 6 open trades (for example) either the open trades are same /different pair of currency, how do we code it? Your reply is appreciated. TQ. |
|
rfiche
2006.09.28 05:24
double TotalProfit(string symbol) { int total = OrdersTotal(); double MyCurrentProfit=0; for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (symbol != OrderSymbol()) continue; MyCurrentProfit += OrderProfit(); } return(MyCurrentProfit); } So, you should call "TotalProfit" function for each symbol your EA can trade. |