¡Pide! - página 135

 
Kalenzo:
Bueno, creo que usted está complicando las cosas demasiado. Trate de usar algunas partes más cortas de código en lugar de una función grande. Esto debería darle alguna pista:

Gracias por tu ayuda. He intentado añadir el código que me has dicho, pero para ser sincero estoy perdido. Después de añadir el código, el EA está mostrando un slue de problemas. He estado repasando la sintaxis pero estoy perdido.

También tengo una pregunta sobre el uso de funciones dentro de la función int start(). ¿Está permitido? ¿No es que los vairables inicializados dentro de una función no pueden ser vistos por otras funciones?

Así que

int inicio()

{

function( int x)

{

// Hacer algo

return(x)

}

// Hacer algo ... "¿Se puede llamar a x en la función start()?

return0;

}

He adjuntado mi fuente de EA. Su ayuda es muy apreciada.

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

//| CCCCCCCCIEA.mq4 aka 8xCIEA.mq4 |

//| By CuTzPR |

//|------------------------------------------------------------------+

#property copyright "CuTzPR@Forex-TSD"

//---- input parameters

extern double Risk_Percent=10;

extern bool Turned_On=true;

extern bool Allow_Risk=false;

extern bool TimeFilter=false;

extern double FromHourTrade=0; //Adjust for Broker GMT Time

extern double ToHourTrade=23; //Adjust for Broker GMT Time

extern double TP=20; // Take Profit Level

extern int MaxLong=5,MaxShort=5;

extern int MaxOpenOrders=10;

extern double Magic=10000;

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

//| expert start function |

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

int start()

{

int ticket;

double Lots;

bool Canopen,BlockTrade;

double Poin; // This variable was included to solve the problem where some brokers use 6 digit quotes instead of 5

static datetime timeprev; // Portion of coded was added to alloy only one trade per bar.

datetime CMT; //Close time of last trade

int total=OrdersTotal();

double Spread=Ask-Bid;

//This portion of code was added to only allow one trade per bar.

if(timeprev==Time[0])

{

return(0); //only execute on new bar

}

else if (timeprev==0)

{

timeprev=Time[0]; // do nothing if freshly added to chart

return(0);

}

else

{

timeprev=Time[0];

}

// End of alllow one trade per bar code

//*****Following code was added to control the Risk per trade.

if (Allow_Risk==true)

Lots=MathCeil(AccountFreeMargin() * Risk_Percent / 10000) / 10;

else Lots=0.1;

//End of Risk Code

//The following code was also included to solve the 6 digit broker quoting

if (Point == 0.00001) Poin = 0.0001; //6 digits

else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)

else Poin = Point; //Normal

//End Point Code

// Custom Functions

double cci=iCCI(NULL,PERIOD_M5,5,PRICE_TYPICAL,0);

double SATL=iCustom(NULL,PERIOD_H1,"$SATL",0,1);

// End of Custom Function

//Start of total count of open Long and Short Orders.

int totalOrders (totalBuy)

{

int totalNumber= 0;

for (int cnt = total ; cnt >=0 ; cnt-- )

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if (OrderMagicNumber() == Magic && OrderType() == OP_BUY)

totalNumber++;

}

return (totalNumber);

}

int totalOrders (totalSell)

{

int totalNumber = 0;

for (int cnt = total ; cnt >=0 ; cnt-- )

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if (OrderMagicNumber() == Magic && OrderType() == OP_SELL)

totalNumber++;

}

return(totalNumber);

}

int totalBuy = totalOrders(totalBuy);

int totalSell = totalOrders(totalSell);

int EAopenOrders=totalBuy+totalSell;

//End of total Open Long and Short count code

// Time filter Code

if (TimeFilter==true)

{

if (!(Hour() >= FromHourTrade && Hour() <= ToHourTrade && Minute() <=2))

BlockTrade=true;

else BlockTrade=false;

}

//End of time Filter code

// Are trades allowed to be opened?

if(EAopenOrders<=MaxOpenOrders && BlockTrade==false && Turned_On==true)

Canopen=true;

else if(EAopenOrders>MaxOpenOrders || BlockTrade==true || Turned_On==false)

Canopen=false;

// End of Allow code

//*****Trade Open Order Functions

if(Canopen==true)

{

if (totalBuy<=MaxLong)

{

if (cci>-100 && SATL<Ask)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"CCI0",Magic,0,Blue);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

Print("BUY order opened : ",OrderOpenPrice());

}

else Print ("Error opening BUY order : ",GetLastError());

return (0);

}

}

else if (totalSell<=MaxShort)

{

if (cciBid)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"CCI",Magic,0,Red);

if (ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

Print ("Sell order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL Order : ",GetLastError());

return (0);

}

}

}// End of Trade Open Order Functions

//****Close Orders if they are profitable

for (int cnt = total ; cnt >=0 ; cnt-- )

{

OrderSelect(0,SELECT_BY_POS,MODE_TRADES);

if (OrderMagicNumber()==Magic)

{

if(OrderType()==OP_BUY && TP != 0 && totalBuy!= 0)

{

if(Bid >= ((OrderOpenPrice()+TP*Poin)+Spread))

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Green); // Long position closed.

CMT=OrderCloseTime();

return(0);

}

}

}

if (OrderMagicNumber()==Magic)

{

if(OrderType()==OP_SELL && TP != 0 && totalSell!=0 )

{

if(Ask <= ((OrderOpenPrice()-TP*Poin)+Spread))

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Green); // Short position closed.

CMT=OrderCloseTime();

return(0);

}

}

}

} // Close Profitable trades loop closed

}// End of Start function

Su ayuda es muy apreciada.

 
Limstylz:
Hola a todos,

Originalmente publiqué esto como un nuevo hilo, pero fue movido a otro hilo de programación (no tengo ninguna objeción a su movimiento BTW) y ahora parece haberse perdido debido a la cantidad de carteles en ese hilo.

¿Quizás alguien de aquí pueda ayudarme?

Limstylz echa un vistazo a este hilo de Ask! página 39. Creo que puede haber alguna información que te ayude. Buena suerte

 

Saludos amigo...

cutzpr:
Limstylz echa un vistazo a este hilo Ask! página 39. Creo que podría haber alguna información que podría ayudarle. Buena suerte

Gracias cutzpr, pero ya lo he solucionado... la maldita conexión a internet estuvo caída todo el día y tuve que usar mis propias neuronas por una vez

De todos modos, para responder a su pregunta sobre el inicio int ()... Este es el cuerpo principal del EA y se actualiza continuamente, cada tick (creo que es correcto).

Su código es un poco desconcertante... ¿puede explicar dónde está experimentando un problema? Yo podría ser capaz de ayudar si usted puede desglosar los problemas, aunque realmente sólo estoy aprendiendo MQL4 mí mismo.

 

¿Qué pasa con esto?

Alguien podría ayudarme, si copio este indicador a mi meta, necesito más de 5 minutos para abrir mi meta, pero cuando lo borro, y vuelvo a abrir mi meta, se vuelve normal de nuevo.

Archivos adjuntos:
 

¡Gracias! ¡Estupendo!

 

De vuelta a la mesa de dibujo

 

Incorporación de un indicador personalizado en un asesor experto

Hola amigos, ¿alguien sabe cómo agregar el indicador personalizado a continuación en un asesor experto? Para que no tengamos que usar el icustom para llamarlo desde el archivo?

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

//| ARSI.mq4

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

#property copyright "Alexander Kirilyuk M."

#property link ""

#property indicator_separate_window

//#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

extern int ARSIPeriod = 14;

//---- buffers

double ARSI[];

int init()

{

string short_name = "ARSI (" + ARSIPeriod + ")";

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ARSI);

//SetIndexDrawBegin(0,ARSIPeriod);

return(0);

}

int start()

{

int i, counted_bars = IndicatorCounted();

int limit;

if(Bars <= ARSIPeriod)

return(0);

if(counted_bars < 0)

{

return;

}

if(counted_bars == 0)

{

limit = Bars;

}

if(counted_bars > 0)

{

limit = Bars - counted_bars;

}

double sc;

for(i = limit; i >= 0; i--)

{

sc = MathAbs(iRSI(NULL, 0, ARSIPeriod, PRICE_CLOSE, i)/100.0 - 0.5) * 2.0;

if( Bars - i <= ARSIPeriod)

ARSI = Close;

else

ARSI = ARSI + sc * (Close - ARSI);

}

Print ("Try2 : " , ARSI[0], ":", ARSI[1]);

return(0);

}
 
yast77:
Hola amigos, ¿alguien sabe cómo añadir el indicador personalizado de abajo en un asesor experto? Para no tener que usar el icustom para llamarlo desde el archivo ?
//+------------------------------------------------------------------+

//| ARSI.mq4

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

#property copyright "Alexander Kirilyuk M."

#property link ""

#property indicator_separate_window

//#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

extern int ARSIPeriod = 14;

//---- buffers

double ARSI[];

int init()

{

string short_name = "ARSI (" + ARSIPeriod + ")";

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ARSI);

//SetIndexDrawBegin(0,ARSIPeriod);

return(0);

}

int start()

{

int i, counted_bars = IndicatorCounted();

int limit;

if(Bars <= ARSIPeriod)

return(0);

if(counted_bars < 0)

{

return;

}

if(counted_bars == 0)

{

limit = Bars;

}

if(counted_bars > 0)

{

limit = Bars - counted_bars;

}

double sc;

for(i = limit; i >= 0; i--)

{

sc = MathAbs(iRSI(NULL, 0, ARSIPeriod, PRICE_CLOSE, i)/100.0 - 0.5) * 2.0;

if( Bars - i <= ARSIPeriod)

ARSI = Close;

else

ARSI = ARSI + sc * (Close - ARSI);

}

Print ("Try2 : " , ARSI[0], ":", ARSI[1]);

return(0);

}

Debe utilizar la función iCustom en su EA para llamar a este indicador:

iCustom(Symbol(),0, "ARSI",ARSIPeriod,0,0);

El número en rojo es la barra que quieres mirar. Cámbielo según sus necesidades.

FerruFx

 
FerruFx:
Usted debe utilizar la función iCustom en su EA para llamar a este indicador:

iCustom(Symbol(),0, "ARSI",ARSIPeriod,0,0);

El número en rojo es la barra que quieres mirar. Cámbialo como necesites.

FerruFx

Gracias por tu respuesta. Ya, sé que podemos utilizar la función icustom, pero como sé, podemos incrustar la función del indicador por la entrada de la codificación del indicador, el siguiente sitio web Indicadores incrustar en Asesores Expertos (alternativa iCustom) | www.metatrader.info que se explica por codersguru describir sobre eso, pero para el indicador ARSI, no estoy seguro de cómo incrustar en un asesor experto. ¡Gracias por cualquier recomendación!

 

mejora de 10points3

Hola a todos.

Estamos tratando de mejorar 10points3. Necesitamos cambiar el código para cerrar la última tercera operación. Por favor, consulte los últimos mensajes aquí:

https://www.mql5.com/en/forum/174975/page259.

Estamos obteniendo buenos resultados aquí.

Razón de la queja: