Ayuda a la codificación - página 405

 
Tomcat98:
Hola Mladen,

Esto es lo que dice el bucle para aquellas órdenes pendientes donde Multi_Indic_00 es un oscilador y Up_Prime_00 es un nivel de definición.

//+--------------------------------------------------------------------+

//---- Comprueba y cierra si el tipo de orden es límite y la tendencia ha cambiado.

if(OrderType()==OP_BUYLIMIT)

if(( Multi_Indic_00 ) <= (Up_Prime_00 ))

{

_OrderDelete=OrderDelete(OrderTicket());

}

if(OrderType()==OP_SELLLIMIT)

if( Multi_Indic_00 ) >= ( Down_Prime_00 ))

{

_OrderDelete=OrderDelete(OrderTicket());

}

//+--------------------------------------------------------------------+

Bueno nada especial....

Feliz comercio.

Sinceramente.

Tomcat98

Tomcat98

Lo que me gustaría ver es la declaración de bucle for(). Si tienes una sentencia for como esta :

for (int i = 0; i < OrdersTotal(); i++)

entonces se perderán algunos pedidos si mientras tanto se han cerrado o eliminado algunos pedidos. Por otro lado, si el bucle for() es así

for (int i = OrdersTotal()-1; i >= 0; i--)

entonces procesará todos los pedidos

 

Mladen ,

Ah, ya veo:

Aquí está para el proceso de cierre:

"

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!=MAGIC | OrderSymbol()!=Symbol()) continue;

"

Tomcat98

 
Tomcat98:
Mladen ,

Oh, ya veo:

Aquí está para el proceso de cierre:

"

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!=MAGIC | OrderSymbol()!=Symbol()) continue;

"

Tomcat98

Tomcat98

Cambie el bucle por

for(int i=TotalPedidos()-1;i>=0;i--)

y debería estar bien

 

Mladen,

¡Bingo!

Ahora hace exactamente lo que necesitaba.

Muchas gracias por tu gran ayuda.

"A la gente no le importa cuánto sabes hasta que saben cuánto te importa"

- Theodore Roosevelt

Sinceramente.

Tomcat98

 
Tomcat98:
Mladen,

¡Bingo!

Ahora hace exactamente lo que necesitaba.

Muchas gracias por su gran ayuda.

"A la gente no le importa cuánto sabes hasta que saben cuánto te importa"

- Theodore Roosevelt

Sinceramente.

Tomcat98

Feliz codificación

 

Hola Mladen, gracias por todo, ahora funciona bien...

ahora estoy atascado con un indicador creado que no es la recarga por lo que cada vez que un cierre de la vela que tengo que recargar el indicador, ¿me puede ayudar a solucionar esto? aquí es parte del código (es un indicador de tendencia basado en lagunas idea simple, gracias:

#property copyright "Copyright © 2014 Daniel Luchinger"

#property link

#property strict

#property strict

#property ventana_gráfica_del_indicador

#property indicator_buffers 4

#property indicator_color1 clrLime

#property indicator_color2 clrRed

#propiedad indicator_color3 clrMagenta

#propiedad indicador_color4 clrCyan

#define COMPRA 1

#define VENDER 2

doble Compra[],

Vender[],

PrimeraCompra[],

PrimeraVenta[];

int OnInit() {

SetIndexBuffer(0,PrimeraCompra);

SetIndexBuffer(1,PrimeraVenta);

SetIndexBuffer(2,Compra);

SetIndexBuffer(3,Venta);

for(int i=0; i<4; i++) {

SetIndexStyle (i,DRAW_ARROW,STYLE_SOLID,2);}

SetIndexArrow (0,233);

SetIndexArrow (1,234);

SetIndexArrow (2,233);

SetIndexArrow (3,234);

return(INIT_SUCCEED);}

void OnDeinit(const int reason) {}

int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[],

const double &open[], const double &high[], const double &low[],

const double &close[], const long &tick_volume[], const long &volume[],

const int &spread[]) {

static int lastSignal=0;

for(int i=MathMin(rates_total-prev_calculated, rates_total-1); i>=0; i--) {

PrimeraCompra=PrimeraVenta=Compra=Venta=Valor_Empleo;

datetime when=Hora;

if((High-Close)<0) {

if(lastSignal==SELL) {

PrimeraCompra=Cierre;

SoundAlert(when, "Buy");}

lastSignal=BUY;}

if((Low-Close)>0){

if(últimaSeñal==BUY) {

PrimeraVenta=Cierre;

SoundAlert(when, "Sell");}

últimaSeñal=Vender;}

}

return(rates_total);}

void SoundAlert(datetime i, string dir) {

static datetime lastAlert=0;

if(lastAlert!=i) {

Alert(StringFormat("Señal %s en %s a %s",dir,Symbol(),TimeToStr(i));

 
daniel1983:
Hola Mladen, gracias por todo, ahora funciona bien...

ahora estoy atascado con un indicador creado que no es la recarga por lo que cada vez que un cierre de la vela que tengo que recargar el indicador, ¿me puede ayudar a solucionar esto? aquí es parte del código (es un indicador de tendencia basado en lagunas idea simple, gracias:

#property copyright "Copyright © 2014 Daniel Luchinger"

#property link

#property strict

#property strict

#property ventana_gráfica_del_indicador

#property indicator_buffers 4

#property indicator_color1 clrLime

#property indicator_color2 clrRed

#propiedad indicator_color3 clrMagenta

#propiedad indicador_color4 clrCyan

#define COMPRA 1

#define VENDER 2

doble Compra[],

Vender[],

PrimeraCompra[],

PrimeraVenta[];

int OnInit() {

SetIndexBuffer(0,PrimeraCompra);

SetIndexBuffer(1,PrimeraVenta);

SetIndexBuffer(2,Compra);

SetIndexBuffer(3,Venta);

for(int i=0; i<4; i++) {

SetIndexStyle (i,DRAW_ARROW,STYLE_SOLID,2);}

SetIndexArrow (0,233);

SetIndexArrow (1,234);

SetIndexArrow (2,233);

SetIndexArrow (3,234);

return(INIT_SUCCEED);}

void OnDeinit(const int reason) {}

int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[],

const double &open[], const double &high[], const double &low[],

const double &close[], const long &tick_volume[], const long &volume[],

const int &spread[]) {

static int lastSignal=0;

for(int i=MathMin(rates_total-prev_calculated, rates_total-1); i>=0; i--) {

PrimeraCompra=PrimeraVenta=Compra=Venta=Valor_Empleo;

datetime when=Hora;

if((High-Close)<0) {

if(lastSignal==SELL) {

PrimeraCompra=Cierre;

SoundAlert(when, "Buy");}

lastSignal=BUY;}

if((Low-Close)>0){

if(últimaSeñal==BUY) {

PrimeraVenta=Cierre;

SoundAlert(when, "Sell");}

lastSignal=Vender;}

}

return(rates_total);}

void SoundAlert(datetime i, string dir) {

static datetime lastAlert=0;

if(lastAlert!=i) {

Alert(StringFormat("Señal %s en %s a %s",dir,Symbol(),TimeToStr(i));

daniel1983

Pruébalo así :

#property copyright "Copyright © 2014 Daniel Luchinger"

#property link ""

#property strict

#property strict

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 clrLime

#property indicator_color2 clrRed

#property indicator_color3 clrMagenta

#property indicator_color4 clrCyan

#define BUY 1

#define SELL 2

double Buy[],

Sell[],

FirstBuy[],

FirstSell[];

int OnInit() {

SetIndexBuffer(0,FirstBuy);

SetIndexBuffer(1,FirstSell);

SetIndexBuffer(2,Buy);

SetIndexBuffer(3,Sell);

for(int i=0; i<4; i++) {

SetIndexStyle (i,DRAW_ARROW,STYLE_SOLID,2);}

SetIndexArrow (0,233);

SetIndexArrow (1,234);

SetIndexArrow (2,233);

SetIndexArrow (3,234);

return(INIT_SUCCEEDED);}

void OnDeinit(const int reason) {}

int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[],

const double &open[], const double &high[], const double &low[],

const double &close[], const long &tick_volume[], const long &volume[],

const int &spread[]) {

static int lastSignal=0;

for(int i=MathMin(rates_total-prev_calculated, rates_total-2); i>=0; i--)

{

FirstBuy=FirstSell=Buy=Sell=EMPTY_VALUE;

datetime when=Time;

if((High-Close)<0) {

if(lastSignal==SELL) {

FirstBuy=Close;

SoundAlert(when,"Buy");}

lastSignal=BUY;}

if((Low-Close)>0){

if(lastSignal==BUY) {

FirstSell=Close;

SoundAlert(when,"Sell");}

lastSignal=SELL;}

}

return(rates_total);

}

void SoundAlert(datetime i, string dir) {

static datetime lastAlert=0;

if(lastAlert!=i) {

Alert(StringFormat("%s signal on %s at %s",dir,Symbol(),TimeToStr(i)));

}

}

 

Hola Mladen, gracias pero al escribir el código de esta manera, hay señales que faltan, por favor, echa un vistazo hice una imagen comparándolos en el gráfico diario USDJPY:

¿Qué puede ser esto?

Archivos adjuntos:
 
daniel1983:
Hola Mladen, gracias pero escribiendo el código de esta manera, hay señales que faltan, por favor, echa un vistazo hice una imagen comparándolos en el gráfico diario USDJPY:

¿Qué puede ser esto?

daniel1983

En tu código has utilizado valores futuros (estos :

High-Close

Low-Close

Yo usé Close - que es un valor anterior normal. Cámbialo por pero entonces volverá a pintar

 

Estimados mrtools y mladen

¿Puede alguien ayudarme? La media móvil de Tom Demark es un indicador clave dentro de mi estrategia, sin embargo, una alarma sería muy útil para cuando se indique un nuevo estante; estaría muy agradecido si se pudiera codificar una alarma en el indicador. Espero su amable ayuda.

Muchas gracias

Archivos adjuntos:
Razón de la queja: