Suma Beneficio Abierto Largo/Corto para Símbolo Especificado
0 respuestas
tomas262
hace 6 años #117426
Si necesita obtener el beneficio abierto actual para el símbolo especificado, puede utilizar la siguiente función en EA WIzard
1) añadir código personalizado en CustomFunction.mq4 colocado en la carpeta Wizard
float sumOpenProfit(cadena direccion, cadena simboloCadena) { float totalProfit = 0; for(int i=TotalOrdenes()-1; i>=0; i--) { if (OrderSelect(i,SELECT_BY_POS)==true) { if (direction == "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) añadir CustomAction así en Wizard
Obtener P/L abierto de largos en EURUSD
sumOpenProfit("LONG", "EURUSD");
o
obtener P/L abierto para todos los cortos activos
sumOpenProfit("CORTO", "")
Se adjunta un ejemplo de EA