¿Cómo codificar? - página 33

 
 

Comprobar orden cerrada por TP o SL

hola

¿Cómo comprobar si la orden fue cerrada por TP o SL?

master001

 

¡Ayuda en la codificación!

int k, vOrders;

vOrders = OrdersTotal();

//{

double Profit = 0;

double PipsProfit = 0;

for (k=vOrders-1;k>=0;k--)

{

if (OrderSelect(k, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol()==Symbol() && ((OrderMagicNumber () == Reference) || MagicNumber==0))

{

if (OrderType() == OP_BUY) PipsProfit+ == ((Bid - OrderOpenPrice())/Point);

Profit+= OrderProfit();

else if (OrderType() == OP_SELL) PipsProfit+ = ((OrderOpenPrice() - Ask)/Point);

{

//Profit += OrderProfit();

}

}

}

}

Alguien me dio esta codificación en el pasado y traté de trabajar con ella. Me da errores tratando con el ' + ' después de PipsProfit. ¡Puede alguien depurar esto para mí por favor! Con sincero agradecimiento de antemano por su ayuda.

Dave

 

if (OrderType() == OP_BUY) PipsProfit+ == ((Bid - OrderOpenPrice())/Point);

[/php]

The + after PipsProfit shouldn't be there at all. It is being used in a comparison NOT an incremental function. You're ASKING does PipsProfit equal Bid - etc etc ?

Try this...

[php]

if ((OrderType() == OP_BUY) && (PipsProfit == (Bid - OrderOpenPrice())/Point)){

// do something IF the above two conditions are TRUE...

}

Buena suerte

Lux

 

El problema es que no hay espacio entre PipsProfit y '+' y un espacio entre '=' y '+' ...... - en otras palabras debería ser así ->

else if (OrderType() == OP_SELL) PipsProfit += ((OrderOpenPrice() - Ask)/Point); {

También debe incluir el segundo 'Profit += OrderProfit();' en el código(quitar esos '//')

 

Pregunta de codificación

Sé que un EA puede ser codificado para operar sólo en cuentas Demo. ¿Puedo también codificar un EA para que NO opere en cuentas PAMM? Esto permitiría al EA operar en cuentas reales, pero no ser utilizado por los administradores de dinero para operar en cuentas PAMM - a menos que haya un acuerdo de licencia por separado.

 

variable(s) externa(s) separada(s) por comas

Hola,

para un indicador que utilizo tengo que establecer los dígitos para cada símbolo. Esto lo hago en el código con, por ejemplo

if(Symbol()=="GBPJPY" || Symbol()=="EURJPY" || Symbol()=="USDJPY" ....and so on) nDigits = 2;[/PHP]

Now I like to spin these symbols off to an extern variable so that the user can set his symbols for himself. I thought to add sth. like

[PHP]extern string Symbols_nDigits2 = "GBPJPY,EURJPY,USDJPY";

¿Cómo puedo utilizar esta lista de símbolos separada por comas y dividirla para poder utilizarla de nuevo en el código del indicador como se muestra arriba (if(Symbol()=="GBPJPY"....)?

(¿O hay alguna solución mejor para este "problema de los dígitos" por ahí?)

Gracias

 
MarketInfo( Symbol(), MODE_DIGITS )
 

perfecto, ¡gracias!

 

Lo tengo funcionando gracias a los dos. Os lo agradezco mucho.

Dave

<<<