gPointPow error
1 respuesta
anemosbr
hace 3 años #266917
Quiero interrumpir las ordenes cuando el ea alcance un determinado beneficio y he visto el siguiente código en otro mensaje del foro:
double sqGetPLInPipsToday() {
cadena todayTime = TimeToStr( TimeCurrent(), TIME_DATE);
double plHoy = 0;
for(int i=0;i<TotalHistorialPedidos();i++) {
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol() == Symbol()) {
if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
// saltar órdenes pendientes
continuar;
}
if(TimeToStr( OrderOpenTime(), TIME_DATE) == todayTime) {
Log("Comparando ", TimeToStr( OrderOpenTime(), TIME_DATE), " = ", todayTime);
if(OrderType() == OP_BUY) {
plToday += OrderClosePrice() - OrderOpenPrice();
} else {
plToday += OrderOpenPrice() - OrderClosePrice();
}
}
}
}
for (int cc = TotalPedidos() - 1; cc >= 0; cc-) {
if (OrderSelect(cc, SELECT_BY_POS) && OrderSymbol() == Symbol()) {
if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
// saltar órdenes pendientes
continuar;
}
if(TimeToStr( OrderOpenTime(), TIME_DATE) == todayTime) {
if(OrderType() == OP_BUY) {
plToday += sqGetBid(OrderSymbol()) - OrderOpenPrice();
} else {
plToday += OrderOpenPrice() - sqGetAsk(OrderSymbol());
}
}
}
}
return (plHoy*gPuntoPow);
}
Sin embargo, cuando intento insertar el código siguiente en la línea de códigos generada en AlgoWizard, obtengo el siguiente mensaje de error:
gPointPow' - identificador no declarado
¿Cómo puedo solucionar este error? ¿Tengo que añadir algo?
tomas262
hace 3 años #267302
Hola,
¿Intenta obtener los valores diarios de P/L? Se puede obtener fácilmente restando AccountEquity() menos AccountEquity() del día anterior o si ejecutas varios EAs usando diferentes números mágicos puedes usar este código
double Beneficio_total= NULL;int cnt = NULL;
for(cnt=0;cnt<=TotalPedidos();cnt++){
OrderSelect(cnt,SELECT_BY_POS);
if(OrderSymbol() == Symbol() && OrderMagicNumber()==magic)
{if( OrderType() == OP_BUY | OrderType() == OP_SELL )
{Beneficio_total= Beneficio_total+ OrderProfit() + OrderSwap() + OrderCommission();}
}
}
Avísame si necesitas ayuda.
Viendo 1 respuesta (de un total de 1)