¡Pide! - página 34

 
AnasFX:
Ok funcionó, pero ahora el problema es el rendimiento. Comprobar todo el historial lleva tiempo. Hice un backtest para un período de año y medio y me di cuenta de que es lento. La razón es que estoy revisando todas las órdenes en el historial y comparando su precio de cierre y la hora de cierre. Entonces, ¿hay alguna forma de limitar la búsqueda en el historial para que busque sólo las órdenes recientes? ¿Puedo aumentar el rendimiento de alguna manera?

puede intentar

OrderSelect(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);

pero no estoy seguro de esto, creo que recogerá la última orden en toda la historia

gracias

 

hola gente...

alguien puede ayudarme...

Tengo algún indicador para crear EA....

 
phoenix:
puedes probar

OrderSelect(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);

pero no estoy seguro de esto, creo que recogerá la última orden en toda la historia

saludos

editado de mi culpa..tiene que ser

OrderSelect(HistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY);

 

Perdón por el doble posteo pero realmente necesito ayuda...

Estoy desesperado aquí. Llevo toda la noche intentando que mi matriz funcione pero no pasa nada. Realmente he intentado ser autosuficiente y tratar de aprender pero todavía no puedo llegar a donde necesito. ¡¡¡¡¡Si alguien puede tener piedad de mí y prestarme ayuda....PLEASE!!!!!

Estoy ejecutando un script de rejilla pero me gustaría hacer un seguimiento de cuántos lotes estoy ejecutando por Símbolo. Quiero ser capaz de sumar lo que mi posición total es por tamaño de lote. Digamos que tengo 0.10, 0.10, 0.10, 0.10, 0.20, 0.30, quiero poder saber que tengo el equivalente a 0.90 lotes. También me gustaría saber el tamaño mínimo y máximo de los lotes....0.10 y 0.30

ArrayResize(OrderArray, i);

ArrayInitialize(OrderArray,0);

cnt = 0;

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

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();

OrderArray[cnt][OPEN] = OrderOpenPrice();

OrderArray[cnt][LOTS] = OrderLots();

if(OrderType() == OP_BUY)

{

////// I can't get anything to work!!!!!!!

BuyLots += OrderArray[cnt][LOTS];

////// This returns Zero when I place BuyLots in my Comments

////// This returns error messages

MaxBuyLots =ArrayMaximum(OrderArray[LOTS],WHOLE_ARRAY,0);

}

 
deeforex:
Lo siento por la doble publicación pero realmente necesito ayuda...

Estoy desesperado. Llevo toda la noche intentando que mi matriz funcione pero no pasa nada. He intentado realmente ser autosuficiente y tratar de aprender pero todavía no puedo llegar a donde necesito. ¡¡¡¡¡Si alguien puede tener piedad de mí y prestarme ayuda....PLEASE!!!!!

Estoy ejecutando un script de rejilla pero me gustaría hacer un seguimiento de cuántos lotes estoy ejecutando por Símbolo. Quiero ser capaz de sumar lo que mi posición total es por tamaño de lote. Digamos que tengo 0.10, 0.10, 0.10, 0.10, 0.20, 0.30, quiero poder saber que tengo el equivalente a 0.90 lotes. También me gustaría saber el tamaño mínimo y máximo de los lotes....0.10 y 0.30

El problema es que el arrayresize() sólo redimensiona el primer elemento, no el segundo. Obviamente sus macros LOTS,PROFIT,y OPEN deben ser 0,1,2 respectivamente. También el objeto count en el bucle for es (i) sin embargo el código del bloque se refiere a (cnt). pruebe esto y vea si funciona.

double OrderArray[][3];

ArrayResize( OrderArray, OrdersTotal() );

cnt = 0;

for (cnt = 0; cnt< OrdersTotal(); cnt++)

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();

OrderArray[cnt][OPEN] = OrderOpenPrice();

OrderArray[cnt][LOTS] = OrderLots();

if(OrderType() == OP_BUY)

{

double BuyLots;

BuyLots += OrderArray[cnt][LOTS];

MaxBuyLots =ArrayMaximum(OrderArray);

}

 

Gracias Nicholishen,

Me estoy acercando un poco más. BuyLots devuelve lo que quiero pero ArrayMaximum me da un número extraño que no puedo entender. No devuelve el LotSize más grande.

Agradezco mucho la ayuda.

dee

 
deeforex:
Gracias Nicholishen,

Me estoy acercando un poco más. BuyLots devuelve lo que quiero pero ArrayMaximum me da un número extraño que no puedo entender. No devuelve el LotSize más grande.

Agradezco mucho la ayuda.

dee

Tendrás que dividir el array en diferentes arrays o escribir un bucle para extraer el máximo del array como:

double OrderArray...[];

ArrayResize( OrderArray, OrdersTotal() );

cnt = 0;

for (cnt = 0; cnt< OrdersTotal(); cnt++)

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArrayProfit[cnt] = OrderProfit() + OrderSwap();

OrderArrayOpen[cnt] = OrderOpenPrice();

OrderArrayLots[cnt] = OrderLots();

if(OrderType() == OP_BUY)

{

double BuyLots;

BuyLots += OrderArrayLots[cnt];

MaxBuyLots =ArrayMaximum(OrderArrayLots);

}

[/CODE]

or

[CODE]double OrderArray[][3];

ArrayResize( OrderArray, OrdersTotal() );

cnt = 0;

for (cnt = 0; cnt< OrdersTotal(); cnt++)

{

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )

{

OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();

OrderArray[cnt][OPEN] = OrderOpenPrice();

OrderArray[cnt][LOTS] = OrderLots();

if(OrderType() == OP_BUY)

{

double BuyLots;

BuyLots += OrderArray[cnt][LOTS];

}

double MBL;

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

if(OrderArrayLots[LOTS]>MBL)MBL=OrderArrayLots[LOTS];

}

MaxBuyLots =MBL;

 

Aquí hay otro ejemplo de una función que rastrea los trailing stops ajustados a través de múltiples operaciones en la misma moneda emparejando los datos de trailing con el número de ticket de la operación correspondiente - usando arrays. Tal vez esto le ayude a dar algunas ideas también.

int tsTicket[21];

double tsPrice[21];

bool tsok[21];

int tkt3[20];

int SuperClose(){// superclose by nicholishen

int cnp=ordercnt();

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

if(OrderMatch(i)){

if(0==0){//Pulls in order that meets the criteria for processing

int num=0;int pos=0;

for(int b=0;b<21;b++){// this (loopB) compares the ticket# of the selected order against the number stored in the ticket array

if(tsTicket==OrderTicket() ){

num++; pos=b;// if ticket numbers match, pos is the position in the array where the trailing data is stored

break;

}

}

if(num==0){ // if the loopB did not find a matching ticket number it is time to initialize the data

for(int j=0;j<21;j++){

if(tsTicket[j]==0){// this is looking for the earliest instance within the array to store the data

pos=j;

break;

}

}

tsTicket[pos]=OrderTicket();// setting the ticket number

tsok[pos]=false;// this is to determine when trailing kicks in

// Print("(",pos,") New ticket initialized = ",tsTicket[pos]);

}

if (OrderType()==OP_SELL) {

if (!tsok[pos] && (OrderOpenPrice()-Ask>=TSactivation*Point || TSactivation==0 ) ) {// if the trailing factor is false, but it has hit the activation point continue

tsPrice[pos]=Ask+TrailPips*Point;// this is the new trailinf stop price

tsok[pos]=true;// it's ok to proceed with trailing stop

if(TrailPips>8){// if this distance from the current price to the new stop, then modify the order.

ModifyStopLoss(Ask+TrailPips*Point,OrderTakeProfit());//modifies order

}

}

if (tsok[pos] && Ask+TrailPips*Point < tsPrice[pos] ){//if the position is gaining in profit

tsPrice[pos]=Ask+TrailPips*Point;

if(TrailPips>8){

ModifyStopLoss(Ask+TrailPips*Point,OrderTakeProfit());

}

}

if (tsok[pos] && Ask >= tsPrice[pos] ){// if the postion hits the stop price

if(CloseOrder(Ask)==STOP)return(STOP);

Print("Short Order ",tsTicket[pos]," Closed from TS");

}

}

else if (OrderType()==OP_BUY) {// reverse of SELL

if(!tsok[pos] && (Bid-OrderOpenPrice() >= TSactivation*Point || TSactivation==0 ) ) {

tsPrice[pos]=Bid-TrailPips*Point;

tsok[pos]=true;

if(TrailPips>8){

ModifyStopLoss(Bid-TrailPips*Point,OrderTakeProfit());

}

}

if (tsok[pos] && Bid-TrailPips*Point > tsPrice[pos] ){

tsPrice[pos]=Bid-TrailPips*Point;

if(TrailPips > 8){

ModifyStopLoss(Bid-TrailPips*Point,OrderTakeProfit());

}

}

if (tsok[pos] && Bid <= tsPrice[pos] ){

if(CloseOrder(Bid)==STOP)return(STOP);

Print("Long Order ",tsTicket[pos]," Closed from TS");

}

}

}

}

if(RefreshRates())return(STOP);

}

for(i=0;i<21;i++){// this searches the array for ticket numbers that are now obsolete due to an order that has closed

if(tsTicket>0){

bool found=false;

for(b=0;b<OrdersTotal();b++){

OrderSelect(b,SELECT_BY_POS);

if(tsTicket==OrderTicket()){

found=true;

break;

}

}

if(!found){// if there are matching ticket numbers in the trade pool and the array then nothing happens

tsTicket=0;tsPrice=0;tsok=false;// if there is an obolete ticket the the data is reset. And the next new ticket data can occupy this space

// Print("Array pos ",i," Cleaned");

}

}

}

return(0);

}

int ordercnt(){

int c;

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

if(OrderSelect(i,SELECT_BY_POS)){

if(OrderMagicNumber()==ID && OrderSymbol()==Symbol()){

tkt3[c]=OrderTicket();

c++;

}

}

}

return(c);

}

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

int curcnt(){

int c;

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

if(OrderSelect(i,SELECT_BY_POS)){

if(OrderSymbol()==Symbol()){

c++;

return(c);

}

}

}

return(c);

}

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

bool OrderMatch(int i){

if(OrderSelect(tkt3,SELECT_BY_TICKET)){

if(OrderMagicNumber()==ID && OrderSymbol()==Symbol()){

return(true);

}

}

return(false);

}
 

Gracias de nuevo.

He cambiado la 3ª de la última línea por esta

if(OrderArray[LOTS]>MBL)MBL=OrderArray[LOTS];

y conseguí que funcionara. Ya se me pasó la hora de dormir. Mañana cuando me despierte estudiaré la lógica de tu código. ¡¡¡Pero como soy un cabezota voy a averiguar cómo usar la maldita función ArrayMaximum!!! También tendré que leer más sobre la indexación para ver cómo mis viejas costumbres estaban taaaan equivocadas.

¡¡¡¡Gracias de nuevo!!!!

dee

 
deeforex:
¡Gracias de nuevo!

Cambié la 3ª de la última línea por esta

if(OrderArray[LOTS]>MBL)MBL=OrderArray[LOTS];

y conseguí que funcionara. Ya se me pasó la hora de dormir. Mañana cuando me despierte estudiaré la lógica de tu código. ¡¡¡Pero como soy terco voy a averiguar cómo usar la maldita función ArrayMaximum!!! También tendré que leer más sobre la indexación para ver cómo mis viejas costumbres estaban taaaan equivocadas.

¡¡¡¡Gracias de nuevo!!!!

dee

Para ahorrarte tiempo, la razón por la que la función max no funcionaba para lo que querías es porque estás usando un array multidimensional y estás almacenando diferentes tipos de datos. Se devolverá el máximo de los datos, por lo que es probable que se devuelve un número de beneficio o cualquier cosa más alta que su tamaño máximo de lote REAL