Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese
Eso funciona para el precio. Quiere encontrar el más alto y el más bajo de un idicador.
Lux
Hola,
Puedes probar esto :
....
int highest=0, lowest=0, bar=WindowBarsPerChart();
for(int shift=0;shift<bar;shift++)
{
double indie=iCustom(.........,shift);
if(highest<indie) highest=indie;
if(lowest==0) lowest=indie;
if(lowest>indie) lowest=indie;
}
.....
nota: este código calcula también la vela abierta actual, si quieres calcular sólo la vela cerrada, utiliza shift=1.
Espero que esto ayude,
Ardie
Actualizar programáticamente el indicador de repintado
Hola,
Estoy buscando una manera de refrescar un indicador de repintado cada x minutos.
La única manera de refrescarlo actualmente, es hacer clic en el indicador en el gráfico y luego hacer clic en "ok". ¿Podemos automatizarlo con código MQL4?
He encontrado algo en el sitio de codersguru, Programmatically Refresh your charts | www.metatrader.info, pero parece que no me funciona. ¿O hay alguien que lo haya probado y haya obtenido un resultado diferente (que funcione)?
Gracias
Lo siento por mi Englsih.
Quiero contar el número de veces que la condición es verdadera sólo una vez por barra. El ordenador suma muchas veces por barra. ¿Qué hago mal?
Lo siento por mi Englsih. Quiero contar el número de veces que la condición es verdadera sólo una vez por barra. Computadora sumar muchas veces por bar. ¿Qué hago mal?
Usa una función como esta...
bool NewBar() {
static datetime LastTime = 0;
if (Time[0] != LastTime) {
LastTime = Time[0];
return (true);
} else
return (false);
}
[/php]
Then put an if statement round your main code, like...
[php]
if(NewBar() == true){
// do the main processing here
}
Espero que eso ayude.
Lux
Eso fue muy amable de tu parte, Lux.
He encontrado esto:
Sólo procesar cada barra una vez - MQL4 foro
Automatizado 2008.01.15 18:54 Podrías ejecutar tu código en el primer tick de una nueva barra ( es decir, justo después de que la barra anterior se haya cerrado ).
Aquí tienes una función que devolverá TRUE si se acaba de formar una nueva barra:
// Esta función devuelve TRUE en el primer tick de una barra, es decir, después de que la barra anterior se haya cerrado
bool NuevaBarra()
{
if(PreviousBarTime<Time[0])
{
PreviousBarTime = Time[0];
return(true);
}
return(false); // en caso de que no se ejecute la sentencia if - else
} necesitas declarar el datetime PreviousBarTime al principio de tu EA...
entonces en tu código podrías usar simplemente
if ( NewBar() )
{
...... código que necesita para ser ejecutado después de una barra ha cerrado aquí ....
} gracias
automatedfx@gmail.com
---------------------------------------------------
Me he dado cuenta de que has utilizado STATIC... Lo he buscado... ¿cuál es la ventaja de usar STATIC frente a una variable global?
ea de entradas múltiples
me gustaria encontrar o necesitar ayuda para crear un ea con los siguientes parametros de entrada. cuatro entradas comerciales separadas cada una con no. de lotes, stop loss, trailing stop, break even, y profit target. las operaciones se abriran al hacer click en el boton de expert advisor.
gracias
Necesito ayuda en la opción de trailing stop
Encontré este EA en el foro MQL4, un EA bastante interesante.
¿podría alguien ayudar a añadir una opción de trailing stop que puede establecer trailing stop sólo se activan después de que el valor de beneficio de golpe que he establecido?
themastermind2.mq4
Hola a todos...
Tengo un problema con el EA que escribí... en realidad, el EA basado en el indicador MACD.. cuando el MACD se convierte en forma de 'n', abre el puesto de venta, y cuando el MACD se convierte en forma de 'u', el EA abrirá la compra...
El problema es que el EA no abrió ningún puesto... después de hacer algunas pruebas de espalda también, no hay ningún puesto abierto por este EA... ¿puede alguien ayudarme a encontrar lo que está mal con el código?
Aquí está el código ...
extern double TakeProfit = 20;
extern double Lots = 0.1;
extern double StopLoss = 20;
extern double MagicNumber = 17384;
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
double MacdBuffer1[];
double MacdBuffer2[];
double MacdBuffer3[];
double MacdBuffer4[];
double MacdBuffer5[];
double MacdBuffer6[];
double MacdBuffer7[];
double MacdBuffer8[];
int init()
{
//----
//SetIndexBuffer(0, lag1_buffer);
//SetIndexBuffer(1, lag2_buffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
for(int i=0; i<limit; i++)
MacdBuffer1=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
MacdBuffer2=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-1)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-1);
MacdBuffer3=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+1)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+1);
MacdBuffer4=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-2)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-2);
MacdBuffer5=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+2)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+2);
MacdBuffer6=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-3)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-3);
MacdBuffer7=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+3)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+3);
/*Alert( "MacdBuffer7 =",MacdBuffer7);
Alert( "MacdBuffer5 =",MacdBuffer5);
Alert( "MacdBuffer3 =",MacdBuffer3);
Alert( "MacdBuffer1 =",MacdBuffer1);
Alert( "MacdBuffer2 =",MacdBuffer2);
Alert( "MacdBuffer4 =",MacdBuffer4);
Alert( "MacdBuffer6 =",MacdBuffer6);*/
//----
int ticket_buy, ticket_sell, total;
total=OrdersTotal();
//MACD become 'u' shape
if (MacdBuffer7>MacdBuffer5&&MacdBuffer5>MacdBuffer3&&MacdBuffer3>MacdBuffer1
&&MacdBuffer1<MacdBuffer2&&MacdBuffer2<MacdBuffer4&&MacdBuffer4<MacdBuffer6)
{
if (total < 1) {
ticket_buy=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"scalp 1 min - buy",MagicNumber,0,Green);
if(ticket_buy>0)
{
if(OrderSelect(ticket_buy,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
} else {
}
}
//MACD become 'n' shape
if(MacdBuffer7<MacdBuffer5&&MacdBuffer5<MacdBuffer3&&MacdBuffer3<MacdBuffer1
&&MacdBuffer1>MacdBuffer2&&MacdBuffer2>MacdBuffer4&&MacdBuffer4>MacdBuffer6)
{
if (total < 1) {
ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"scalp 1 min - sell",MagicNumber,0,Red);
if(ticket_sell>0)
{
if(OrderSelect(ticket_sell,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
} else {
}
}
//----
return(0);
}
//+------------------------------------------------------------------+Espero que alguien me puede ayudar a resolver el problema.. no soy un buen en los códigos de programación.. gracias..