Hier mal mein gewurschtel. Ist nicht die tollste Lösung, funktioniert für mich aber wunderbar.
Code:
//+------------------------------------------------------------------+
//| frank-test-auslesen.mq4 |
//| Copyright 2022, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int trade = 0;
int wmax = 13;
string wah ="";
int x = 19;
int a = 0;
input int Schriftgroesse = 10;
string waehrung[] ={"EURUSD","USDCHF","EURGBP","NZDCAD","EURAUD","GBPUSD","AUDCAD","AUDUSD","CADCHF","EURNZD","GBPCHF","USDCAD","EURCHF","XAUUSD"};
struct STradeBSum {
int countb;
double profitb;
double trailPriceb;
double profitab;
};
void OnTick()
{
STradeBSum sumB;
ObjectCreate ("Bid",OBJ_LABEL,0,0,0);
ObjectSet ("Bid",OBJPROP_CORNER,4);
ObjectSet ("Bid",OBJPROP_XDISTANCE,10);
ObjectSet ("Bid",OBJPROP_YDISTANCE,18);
ObjectSetText ("Bid","Währungspaar offene Trades Profit",Schriftgroesse,"Arial",Red);
x = 19;
a = 0;
for ( a = 0; a <= wmax; a++ ){
wah = waehrung[a];
GetSumB(sumB);
x = x +30;
ObjectCreate ("test"+a,OBJ_LABEL,0,0,0);
ObjectSet ("test"+a,OBJPROP_CORNER,4);
ObjectSet ("test"+a,OBJPROP_XDISTANCE,14);
ObjectSet ("test"+a,OBJPROP_YDISTANCE,x);
ObjectSetText ("test"+a," "+wah+" "+trade+" "+DoubleToString(sumB.profitb,2),Schriftgroesse,"Arial",Red);
}
}
//+------------------------------------------------------------------+
//////////////// PROFIT BUY berechnen
void GetSumB(STradeBSum &sumB) {
sumB.countb = 0;
sumB.profitb = 0.0;
sumB.trailPriceb = 0.0;
sumB.profitb = 0.0;
int z = OrdersTotal();
trade = 0;
for (int i = z-1; i>=0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if ( OrderSymbol()==wah){
trade = trade+1;
sumB.countb++;
sumB.profitb += OrderProfit()+OrderSwap()+OrderCommission();
if (sumB.trailPriceb ==0 || OrderOpenPrice()<sumB.trailPriceb) {
sumB.trailPriceb = OrderOpenPrice();
}
}
} }
return;
}
Das ganze ziehe ich mir als EA in ein leeres Chart und bekomme angezeigt wie viele Trades von den einzelnen Währungspaaren offen sind und wieviel Profit das jeweilige Währungspaar gerade in Summe abwirft (oder eben nicht
)
Als nächstes bastel ich mir noch einen Close-Button hinter jedes Währungspaar, so dass ich alle Trades dieses Währungspaares mit einem Klick schließen kann.
Wie gesagt, nicht die schönste Lösung. Aber funktioniert und reicht für meine Zwecke