En el archivo también se pueden encontrar otras funciones, las cuales calculan la tendencia previa, así como los patrones. De momento no las explico, por el hecho de que aún estoy retocándolas, y estas funciones formarán parte de un indicador general.
Además, aún me queda por comprobar el buen funcionamiento.
La función de las velas es:
int tipovela(int i)Saludos a todos y espero que os valga.
{
//Dojis
if(Open[i] == Close[i])
{
if(Low[i] == Open[i])
{
Alert("Doji lapida");
return(4);
}
if((High[i]-Open[i]) == (Open[i]-Low[i]))
{
Alert("Doji clasico");
return(1);
}
if((High[i]-Open[i]) > (3*(Open[i]-Low[i])))
{
Alert("Doji larga sombra superior");
return(2);
}
if((Open[i]-Low[i]) > (3*(High[i]-Open[i])))
{
Alert("Doji larga sombra inferior");//Doji libelula
return(3);
}
Alert("Doji");
return(27);
}
//Marubozus
//Marubozu alcista
if((High[i] == Close[i]) && (Close[i] > Open[i]) &&
(Open[i] == Low[i]))
{
Alert("Marubozu alcista");
return(5);
}
//Marubozu bajista
if((High[i] == Open[i]) && (Open[i] > Close[i]) &&
(Close[i] == Low[i]))
{
Alert("Marubozu bajista");
return(6);
}
//Marubozu cerrado alcista
if((High[i] == Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
((Close[i]-Open[i]) > (3*(Open[i]-Low[i]))) )
{
Alert("Marubozu cerrado alcista");
return(10);
}
//Marubozu cerrado bajista
if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] == Low[i]) &&
((Open[i]-Close[i]) > (3*(High[i]-Open[i]))))
{
Alert("Marubozu cerrado bajista");
return(13);
}
//Marubozu abierto alcista
if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] == Low[i]) &&
((Close[i]-Open[i]) > (3*(High[i]-Close[i]))))
{
Alert("Marubozu abierto alcista");
return(16);
}
//Marubozu abierto bajista
if((High[i] == Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((Open[i]-Close[i]) > (3*(Close[i]-Low[i]))))
{
Alert("Marubozu abierto bajista");
return(17);
}
//Martillo invertido alcista
if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] == Low[i]) &&
((High[i]-Close[i]) > (2*(Close[i]-Open[i]))))
{
Alert("Martillo invertido alcista");
return(14);
}
//Martillo invertido bajista
if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] == Low[i]) &&
((High[i]-Open[i]) > (2*(Open[i]-Close[i]))))
{
Alert("Martillo invertido bajista");
return(15);
}
//Martillo alcista
if((High[i] == Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
((Open[i]-Low[i]) > (2*(Close[i]-Open[i]))))
{
Alert("Martillo alcista");
return(12);
}
//Martillo bajista
if((High[i] == Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((Close[i]-Low[i]) > (2*(Open[i]-Close[i]))))
{
Alert("Martillo bajista");
return(11);
}
//Larga sombra superior alcista
if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
((High[i]-Close[i]) > (3*(Open[i]-Low[i]))) &&
((High[i]-Close[i]) > (3*(Close[i]-Open[i]))))
{
Alert("Larga sombra superior alcista");
return(19);
}
//Larga sombra superior bajista
if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((High[i]-Open[i]) > (3*(Close[i]-Low[i]))) &&
((High[i]-Open[i]) > (3*(Open[i]-Close[i]))))
{
Alert("Larga sombra superior bajista");
return(20);
}
//Larga sombra inferior alcista
if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
((Open[i]-Low[i]) > (3*(Close[i]-Open[i]))) &&
((Open[i]-Low[i]) > (3*(High[i]-Close[i]))))
{
Alert("Larga sombra inferior alcista");
return(21);
}
//Larga sombra inferior bajista
if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((Close[i]-Low[i]) > (3*(Open[i]-Close[i]))) &&
((Close[i]-Low[i]) > (3*(High[i]-Open[i]))))
{
Alert("Larga sombra inferior bajista");
return(22);
}
//Onda alta alcista
if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
((High[i]-Close[i]) > (3*(Close[i]-Open[i]))) &&
((Open[i]-Low[i]) > (3*(Close[i]-Open[i]))))
{
Alert("Onda alta alcista");
return(23);
}
//Onda alta bajista
if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((High[i]-Open[i]) > (3*(Open[i]-Close[i]))) &&
((Close[i]-Low[i]) > (3*(Open[i]-Close[i]))) )
{
Alert("Onda alta bajista");
return(24);
}
//Peonza alcista
if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
// ((High[i]-Close[i]) < (Close[i]-Open[i])) && // ((Open[i]-Low[i]) < (Close[i]-Open[i])) && ((High[i]-Close[i]) == (Close[i]-Open[i])) && ((Open[i]-Low[i]) == (Close[i]-Open[i])) && ((MathAbs(Close[i]-Open[i])) < (MathAbs(Close[i+1]-Open[i+1]))) && ((MathAbs(Close[i]-Open[i])) < (MathAbs(Close[i+2]-Open[i+2]))) && ((MathAbs(Close[i]-Open[i])) < (MathAbs(Close[i+3]-Open[i+3]))) ) { Alert("Peonza alcista"); return(8); } //Peonza bajista if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((High[i]-Open[i]) < (Open[i]-Close[i])) && ((Close[i]-Low[i]) < (Open[i]-Close[i])) && ((High[i]-Open[i]) == (Close[i]-Low[i])) && ((MathAbs(Close[i]-Open[i])) < (MathAbs(Close[i+1]-Open[i+1]))) && ((MathAbs(Close[i]-Open[i])) < (MathAbs(Close[i+2]-Open[i+2]))) && ((MathAbs(Close[i]-Open[i])) < (MathAbs(Close[i+3]-Open[i+3]))) ) { Alert("Peonza bajista"); return(7); } //Gran vela alcista if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
((Close[i]-Open[i]) > (3*(High[i]-Close[i]))) &&
((Close[i]-Open[i]) > (3*(Open[i]-Low[i]))) &&
((MathAbs(Close[i]-Open[i])) > (3*(MathAbs(Open[i+1]-Close[i+1])))) &&
((MathAbs(Close[i]-Open[i])) > (3*(MathAbs(Open[i+2]-Close[i+2])))) &&
((MathAbs(Close[i]-Open[i])) > (3*(MathAbs(Open[i+3]-Close[i+3])))) )
{
Alert("Gran vela alcista");
return(9);
}
//Larga vela alcista
if((High[i] > Close[i]) && (Close[i] > Open[i]) &&
(Open[i] > Low[i]) &&
((MathAbs(Close[i]-Open[i])) > (MathAbs(Close[i+1]-Open[i+1]))) &&
((MathAbs(Close[i]-Open[i])) > (MathAbs(Close[i+2]-Open[i+2]))) )
{
Alert("Larga vela alcista");
return(25);
}
//Gran vela bajista
if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((Open[i]-Close[i]) > (3*(High[i]-Open[i]))) &&
((Open[i]-Close[i]) > (3*(Close[i]-Low[i]))) &&
((MathAbs(Close[i]-Open[i])) > (3*(MathAbs(Open[i+1]-Close[i+1])))) &&
((MathAbs(Close[i]-Open[i])) > (3*(MathAbs(Open[i+2]-Close[i+2])))) &&
((MathAbs(Close[i]-Open[i])) > (3*(MathAbs(Open[i+3]-Close[i+3])))) )
{
Alert("Gran vela bajista");
return(18);
}
//Larga vela bajista
if((High[i] > Open[i]) && (Open[i] > Close[i]) &&
(Close[i] > Low[i]) &&
((MathAbs(Close[i]-Open[i])) > (MathAbs(Close[i+1]-Open[i+1]))) &&
((MathAbs(Close[i]-Open[i])) > (MathAbs(Close[i+2]-Open[i+2]))) )
{
Alert("Larga vela bajista");
return(26);
}
//Ultima comprobacion
//Vela bajista
if((High[i] >= Open[i]) && (Open[i] > Close[i]) &&
(Close[i] >= Low[i]))
{
Alert("Vela bajista");
return(28);
}
//Vela alcista
if((High[i] >= Close[i]) && (Close[i] > Open[i]) &&
(Open[i] >= Low[i]))
{
Alert("Vela alcista");
return(29);
}
return(0);
}