¿Cómo codificar? - página 324

 
mladen:
No es tan fácil de explicar

Tienes que enviar un evento al gráfico offline que le "diga" (a tu indicador) que se genera un nuevo tick y que debe ejecutar las rutinas necesarias. Esto significa utilizar funciones de bajo nivel. El conjunto puede ser algo así:

#include

#import "user32.dll"

int GetParent(int hWnd);

#import

#define CHART_CMD_UPDATE_DATA 33324

void UpdateChartWindows()

{

int filePeriod = 1; // file period

string fileSymbol = "your offline symbol name";

string chartName = "your offline symbol chart full name";

string stringForName = " ";

//

//

//

//

//

int windowHandle = WindowHandle(fileSymbol,filePeriod);

if (windowHandle != 0)

{

windowHandle = GetParent(windowHandle);

windowHandle = GetWindow(windowHandle,GW_HWNDFIRST);

while (windowHandle != 0)

{

int len = GetWindowTextA(windowHandle,stringForName,80);

if (len > 0 && StringSubstr(stringForName,0,len) == chartName)

PostMessageA(windowHandle,WM_COMMAND,CHART_CMD_UPDATE_DATA,0);

windowHandle = GetWindow(windowHandle,GW_HWNDNEXT);

}

}

}

Gracias, lo comprobaré. Sin embargo, encuentro el problema para enviar el pedido correctamente. Mi indicador crea un nombre para el gráfico offline no estándar y las plataformas no lo abren por esta razón.

Gracias por su disponibilidad

 

Ok, El tema de la carta fuera de línea está en el trabajo.

Tengo otro problema.

Tengo que crear un indicador que calcule los volúmenes con reglas específicas.

Lo que necesito es que cada vez que haya una variación de tick el indicador debe contar la longitud del swing.

Ejemplo.

en la vela abierta el valor del buffer es 0. Así que debe contar todos los ticks realizados antes de un retroceso pero el valor final devuelto es el más alto desde el cierre de la vela.

Después, debe establecer el color del histograma reletado el movemenet hecho del rango más alto devuelto desde el buffer.

Intento de diferentes maneras pero no hay éxito.

Ayuda ^^.

Gracias

 

Gracias por todo su apoyo. Estoy aprendiendo más y con toda su ayuda arreglo todas mis peticiones...PERO.

Tengo otra^^.

Necesito crear una función void para recuperar y tiene que ser la fusión de estos dos códigos.

El primero encuentra el último openorder. y el segundo encuentra el número del openorder que tiene el openprice más alto.

Necesito hacer una función para tener directamente el número de la orden que tiene el openorderprice más alto.

Gracias

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

OrderSelect(i, SELECT_BY_POS);

if(OrderSymbol() == Symbol() && OrderType() == TYPE ) {

if(TYPE == OP_BUY) {

double OPrice = OrderOpenPrice();[/PHP]

[PHP]for(int e=0;e<OrdersTotal();e++) {

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

if(OrderSymbol() == Symbol() && OrderType() == TYPE) {

if(TYPE == OP_BUY) {

if(OrderOpenPrice()>test(OP_BUY) Hbuys++;

}

}

}

return(Hbuys);

}

 
dasio:
Gracias por todo su apoyo. Estoy aprendiendo más y con toda su ayuda arreglo todas mis peticiones...PERO.

Tengo otro^^.

Tengo que crear una función void para recuperar y tiene que ser la fusión de estos dos códigos.

El primero encuentra la última orden abierta y el segundo encuentra el número de la orden abierta que tiene el precio abierto más alto.

Necesito hacer una función para tener directamente el número de la orden que tiene el openorderprice más alto.

Gracias

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

OrderSelect(i, SELECT_BY_POS);

if(OrderSymbol() == Symbol() && OrderType() == TYPE ) {

if(TYPE == OP_BUY) {

double OPrice = OrderOpenPrice();[/PHP]

for(int e=0;e<OrdersTotal();e++) {

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

if(OrderSymbol() == Symbol() && OrderType() == TYPE) {

if(TYPE == OP_BUY) {

if(OrderOpenPrice()>test(OP_BUY) Hbuys++;

}

}

}

return(Hbuys);

}

Hice un error en el segundo código. Es correcto

[PHP]for(int e=0;e<OrdersTotal();e++) {

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

if(OrderSymbol() == Symbol() && OrderType() == TYPE) {

if(TYPE == OP_BUY) {

if(OrderOpenPrice()>OPrice Hbuys++;

}

}

}

return(Hbuys);

}

 

dasio

Una función void es una función que no devuelve ningún valor. Si ese es el caso, la única forma razonable de hacerlo es utilizar alguna variable que se pase por referencia a la función (en mi experiencia, utilizar variables de ámbito global para ese fin es una muy mala práctica: evita las reglas de codificación estructuradas y, en los casos en que hay que buscar errores, es una pesadilla cuando se utilizan esas variables). ¿Es eso lo que tenías en mente?

dasio:
He cometido un error en el segundo código. Es correcto
for(int e=0;e<OrdersTotal();e++) {

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

if(OrderSymbol() == Symbol() && OrderType() == TYPE) {

if(TYPE == OP_BUY) {

if(OrderOpenPrice()>OPrice Hbuys++;

}

}

}

return(Hbuys);

}

 
mladen:
dasio la función void es una función que no devuelve ningún valor. Si ese es el caso, entonces la única manera razonable de hacerlo es usar alguna variable que se pase por referencia a la función (en mi experiencia, usar variables de ámbito global para ese propósito es una muy mala práctica - evita las reglas de codificación estructuradas, y, en los casos en que hay que buscar errores, es una pesadilla cuando se usan tales variables). ¿Es eso lo que tenías en mente?

Gracias por su respuesta,

Sólo necesito el número de compras que tienen el mayor openorder y el menor openorderm respecto a la última orden de compra abierta.

Tengo que utilizar el resultado como moltiplier en una función vois para alguna comprobación.

De esta manera es mucho más sencillo recuperar este registro cuando se solicite. Tal vez de esta manera puedo recuperar simplemente CalculateCurrentBuy(Symbol())

int CalculateHighestbuy(string symbol) {

int Hopen=0;

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

code here

}

}

return(Hopen);

}

 

¿Rejilla de seguimiento?

for(int i = 1; i < Stop.Order.Levels+1; i++)

{

if(Set.SELLSTOP && s.ticketP==0){

OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Ask-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}

if(Set.BUYSTOP && b.ticketP==0){

OrderSend(Symbol(),OP_BUYSTOP,Buy.Lots+i*Buy.Multiplier,Bid+i*(Trail.BUYSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}

}[/CODE]

I can set a grid using the above code but how do I get the Buy Grid and Sell grid grid to trail independently or as a set and retain the separate grid spacing? I have tried all sorts of things and must be missing something obvious. All I get is either all the pending orders move to the same level and then trail as a group or the pending orders start moving up and down with the price action.

[CODE] void TrailingOrders() {

if (Trail.BUYSTOP.Orders && OrderType()==OP_BUYSTOP) {

if (OrderOpenPrice()-Ask>(Trail.BUYSTOP.Orders.Distance)*myPoint) {

OrderModify(OrderTicket(),Ask+OrderOpenPrice()+(Trail.BUYSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Aqua);

}

}

if (Trail.SELLSTOP.Orders && OrderType()==OP_SELLSTOP) {

if (Bid-OrderOpenPrice()>(Trail.SELLSTOP.Orders.Distance)*myPoint) {

OrderModify(OrderTicket(),Bid-OrderOpenPrice()-(Trail.SELLSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Yellow);

}

}

}

Este código se arrastrará 2 órdenes, pero ¿cómo puedo modificarlo para que se arrastren más? En cuanto intento configurar el código de seguimiento para varios niveles como el código de la rejilla anterior, se convierte en un flan.

Cualquier idea sería apreciada.

Saludos CJA

 

...

cja

Lo he probado con el siguiente código y funciona bien (ver la imagen de ejemplo: diferentes pasos ya aplicados)

No sabía para qué servían las variables s.ticketP y b.ticketP, así que las utilicé como se ve en el código

extern double Trail.SELLSTOP.Orders.Distance = 15;

extern double Trail.BUYSTOP.Orders.Distance = 20;

extern int Stop.Order.Levels = 4;

extern double Sell.Lots = 0.1;

extern double Sell.Multiplier = 0.1;

extern double Buy.Lots = 0.1;

extern double Buy.Multiplier = 0.2;

extern bool Set.SELLSTOP = true;

extern bool Set.BUYSTOP = true;

int init()

{

return(0);

}

int start()

{

double myPoint=1; if (Digits==3 || Digits==5) myPoint=10; myPoint *= Point;

static int s.ticketP=0;

static int b.ticketP=0;

for(int i = 1; i < Stop.Order.Levels+1; i++)

{

if(Set.SELLSTOP && s.ticketP==0){ OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Bid-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}

if(Set.BUYSTOP && b.ticketP==0){ OrderSend(Symbol(),OP_BUYSTOP ,Buy.Lots+i *Buy.Multiplier ,Ask+i*(Trail.BUYSTOP.Orders.Distance)*myPoint ,0,0,0,0,0,0,CLR_NONE);}

}

s.ticketP=Stop.Order.Levels;

b.ticketP=Stop.Order.Levels;

return(0);

}

cja:
for(int i = 1; i < Stop.Order.Levels+1; i++)

{

if(Set.SELLSTOP && s.ticketP==0){

OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Ask-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}

if(Set.BUYSTOP && b.ticketP==0){

OrderSend(Symbol(),OP_BUYSTOP,Buy.Lots+i*Buy.Multiplier,Bid+i*(Trail.BUYSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}

}[/CODE]

I can set a grid using the above code but how do I get the Buy Grid and Sell grid grid to trail independently or as a set and retain the separate grid spacing? I have tried all sorts of things and must be missing something obvious. All I get is either all the pending orders move to the same level and then trail as a group or the pending orders start moving up and down with the price action.

[CODE] void TrailingOrders() {

if (Trail.BUYSTOP.Orders && OrderType()==OP_BUYSTOP) {

if (OrderOpenPrice()-Ask>(Trail.BUYSTOP.Orders.Distance)*myPoint) {

OrderModify(OrderTicket(),Ask+OrderOpenPrice()+(Trail.BUYSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Aqua);

}

}

if (Trail.SELLSTOP.Orders && OrderType()==OP_SELLSTOP) {

if (Bid-OrderOpenPrice()>(Trail.SELLSTOP.Orders.Distance)*myPoint) {

OrderModify(OrderTicket(),Bid-OrderOpenPrice()-(Trail.SELLSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Yellow);

}

}

}

Este código hace el seguimiento de 2 pedidos, pero ¿cómo puedo modificarlo para que haga el seguimiento de más? En cuanto intento configurar el código de seguimiento para varios niveles, como el código de la cuadrícula anterior, se convierte en un flan.

Cualquier idea sería apreciada.

Saludos CJA
Archivos adjuntos:
stopd.gif  36 kb
 

Rejilla de arrastre

mladen:
cja

Lo he probado con el siguiente código y funciona bien (ver la imagen de ejemplo: diferentes pasos ya aplicados)

No sabía para qué servían las variables s.ticketP y b.ticketP, así que las utilicé como se ve en el código

extern double Trail.SELLSTOP.Orders.Distance = 15;

extern double Trail.BUYSTOP.Orders.Distance = 20;

extern int Stop.Order.Levels = 4;

extern double Sell.Lots = 0.1;

extern double Sell.Multiplier = 0.1;

extern double Buy.Lots = 0.1;

extern double Buy.Multiplier = 0.2;

extern bool Set.SELLSTOP = true;

extern bool Set.BUYSTOP = true;

int init()

{

return(0);

}

int start()

{

double myPoint=1; if (Digits==3 || Digits==5) myPoint=10; myPoint *= Point;

static int s.ticketP=0;

static int b.ticketP=0;

for(int i = 1; i < Stop.Order.Levels+1; i++)

{

if(Set.SELLSTOP && s.ticketP==0){ OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Bid-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}

if(Set.BUYSTOP && b.ticketP==0){ OrderSend(Symbol(),OP_BUYSTOP ,Buy.Lots+i *Buy.Multiplier ,Ask+i*(Trail.BUYSTOP.Orders.Distance)*myPoint ,0,0,0,0,0,0,CLR_NONE);}

}

s.ticketP=Stop.Order.Levels;

b.ticketP=Stop.Order.Levels;

return(0);

}

Hola mladen,

Gracias por tu ayuda, sin embargo, puede que no me haya explicado bien en mi post anterior. No tengo ningún problema para establecer una rejilla, el problema que tengo es que la rejilla se arrastra sin perder la separación de órdenes.

s.ticketP & b.ticketP simplemente se refiere al código de órdenes pendientes BUYSTOP & SELLSTOP que se utiliza en otra parte del EA.

Saludos CJA

 

Rejilla de arrastre

cja:
Hola mladen,

Gracias por su ayuda, sin embargo, puede que no me haya explicado bien en mi mensaje anterior. No tengo ningún problema en establecer una rejilla, el problema que tengo es arrastrar la rejilla sin perder la separación de la orden.

s.ticketP & b.ticketP simplemente se refiere al código de órdenes pendientes BUYSTOP & SELLSTOP que se utiliza en otra parte del EA.

Saludos CJA

Hola mladen,

¿Tienes tiempo para echarle un vistazo a esto?

Saludos cordiales CJA

Razón de la queja: