Somma aperta Profit Long/Short per il simbolo specificato
0 risposte
tomas262
6 anni fa #117426
Se si desidera ottenere il profitto aperto corrente per un simbolo specifico, è possibile utilizzare la seguente funzione in EA WIzard
1) aggiungete il codice personalizzato in CustomFunction.mq4 collocato nella cartella Wizard
float sumOpenProfit(string direction, string symbolString) { float totalProfit = 0; for(int i=OrdersTotal()-1; i>=0; i--) { if (OrderSelect(i,SELECT_BY_POS)==true) { se (direzione == "LONG" && symbolString != "" && OrderType() == OP_BUY && OrderSymbol() == symbolString) { totalProfit += OrderProfit(); } else if (direction == "LONG" && symbolString == "" && OrderType() == OP_BUY) { totalProfit += OrderProfit(); } else if (direction == "SHORT" && symbolString != "" && OrderType() = OP_SELL && OrderSymbol() == symbolString) { totalProfit += OrderProfit(); } else if (direction == "SHORT" && symbolString == "" && OrderType() == OP_SELL) { totalProfit += OrderProfit(); } } } return totalProfit; }
2) aggiungere Azione personalizzata come questo in Wizard
Ottenere il P/L aperto dalle posizioni lunghe in EURUSD
sumOpenProfit("LONG", "EURUSD");
o
ottenere il P/L aperto per tutti gli short attivi
sumOpenProfit("SHORT", "")
L'esempio di EA è allegato