RafaParticipant
Senior
Estoy estudiando una estrategia que funciona muy bien, y me gustaría hacer el SCREENER pero no se por qué motivo no funciona del todo como a mi me gustaría.
Consiste en entrar en aquellos cruces del RSI con una EMA, dependiendo del Ichimoku: Posiciones Largas, Cruce del RSI en largo, por encima de la nube: para posiciones cortas lo mismo pero al revés
I am studying a strategy which works very good, and I would like to code the SCREENER, but I don´t know why is not working in the way I would like.
The strategy is to take positions when the RSI crosses an EMA, depending of the Ichimoku: Long, when the RSI crosses the EMA long direction, above the Kumo: For short positions is the same but opposite
//****************************************************************
//* Estrategia de cruce de RSI y su EMA a cualquier nivel
//* Autor: Rafa Barreto
//****************************************************************
// ===== VALORES MODIFICABLES =====
ValorRSI = 10
ValorEMA = 10
// -- Construyendo la graficación Ichimoku --
// -- Valores NO Standar: Fibonacci: 8; 21; 55 --
// -- Valores NO Standar: Actuales : 7;22;44
// -- Valores Standar: 9; 26; 52
PeriodoCorto = 7
PeriodoMedio = 22
PeriodoLargo = 44
Tenkan = (highest[PeriodoCorto](High) + lowest[PeriodoCorto](Low)) / 2
Kijun = (highest[PeriodoMedio](High) + lowest[PeriodoMedio](Low)) / 2
SpanA = (TenKan[PeriodoMedio] + Kijun[PeriodoMedio]) / 2
SpanB = (highest[PeriodoLargo](High[PeriodoMedio]) + lowest[PeriodoLargo](Low[PeriodoMedio])) / 2
Chikou = Close
// ===== A partir de aquí no se toca el código =====
// --- Variables de la estrategia ---
MiRSI = RSI[ValorRSI](close)
MiEMARSI = ExponentialAverage[ValorEMA](RSI[ValorRSI](close))
// --- Condiciones de Posiciones Largas ---
Condicion1Larga = (close > SpanA) AND (close > SpanB)
Condicion2Larga = (Tenkan > SpanA) AND (Tenkan > SpanB)
Condicion3Larga = (Kijun > SpanA) AND (Kijun > SpanB)
Condicion4Larga = (Chikou > SpanA) AND (Chikou > SpanB)
IF (Condicion1Larga AND Condicion2Larga AND Condicion3Larga AND Condicion4Larga) THEN
CruceLargo = MiRSI CROSSES OVER MiEMARSI
ENDIF
// -- Condiciones de Posiciones Cortas ---
Condicion1Corta = (close < SpanA) AND (close < SpanB)
Condicion2Corta = (Tenkan < SpanA) AND (Tenkan < SpanB)
Condicion3Corta = (Kijun < SpanA) AND (Kijun < SpanB)
Condicion4Corta = (Chikou < SpanA) AND (Chikou < SpanB)
IF (Condicion1Corta AND Condicion2Corta AND Condicion3Corta AND Condicion4Corta) THEN
CruceCorto = MiRSI CROSSES UNDER MiEMARSI
ENDIF
// ===== SCREENER =====
SCREENER [CruceLargo OR CruceCorto]
RafaParticipant
Senior
Solo funciona con el OIL pero no con el FOREX, Por qué?
El problema es que sólo prueba el RSI y el promedio móvil pasa o cruza bajo cuando todas las demás condiciones son verdaderas. Así que todas las condiciones podrían ser probadas en el pasado y nunca ser reajustado una vez que las condiciones ichimoku no son verdaderas de nuevo.
Esta versión de código debería funcionar mejor creo, por favor confirme! 🙂
//****************************************************************
//* Estrategia de cruce de RSI y su EMA a cualquier nivel
//* Autor: Rafa Barreto
//****************************************************************
// ===== VALORES MODIFICABLES =====
ValorRSI = 10
ValorEMA = 10
// -- Construyendo la graficación Ichimoku --
// -- Valores NO Standar: Fibonacci: 8; 21; 55 --
// -- Valores NO Standar: Actuales : 7;22;44
// -- Valores Standar: 9; 26; 52
PeriodoCorto = 7
PeriodoMedio = 22
PeriodoLargo = 44
Tenkan = (highest[PeriodoCorto](High) + lowest[PeriodoCorto](Low)) / 2
Kijun = (highest[PeriodoMedio](High) + lowest[PeriodoMedio](Low)) / 2
SpanA = (TenKan[PeriodoMedio] + Kijun[PeriodoMedio]) / 2
SpanB = (highest[PeriodoLargo](High[PeriodoMedio]) + lowest[PeriodoLargo](Low[PeriodoMedio])) / 2
Chikou = Close
// ===== A partir de aquí no se toca el código =====
// --- Variables de la estrategia ---
MiRSI = RSI[ValorRSI](close)
MiEMARSI = ExponentialAverage[ValorEMA](MiRSI)
// --- Condiciones de Posiciones Largas ---
Condicion1Larga = (close > SpanA) AND (close > SpanB)
Condicion2Larga = (Tenkan > SpanA) AND (Tenkan > SpanB)
Condicion3Larga = (Kijun > SpanA) AND (Kijun > SpanB)
Condicion4Larga = (Chikou > SpanA) AND (Chikou > SpanB)
CruceLargo = MiRSI CROSSES OVER MiEMARSI and (Condicion1Larga AND Condicion2Larga AND Condicion3Larga AND Condicion4Larga)
// -- Condiciones de Posiciones Cortas ---
Condicion1Corta = (close < SpanA) AND (close < SpanB)
Condicion2Corta = (Tenkan < SpanA) AND (Tenkan < SpanB)
Condicion3Corta = (Kijun < SpanA) AND (Kijun < SpanB)
Condicion4Corta = (Chikou < SpanA) AND (Chikou < SpanB)
CruceCorto = MiRSI CROSSES UNDER MiEMARSI and (Condicion1Corta AND Condicion2Corta AND Condicion3Corta AND Condicion4Corta)
// ===== SCREENER =====
SCREENER [CruceLargo OR CruceCorto]
RafaParticipant
Senior
Muchas Gracias Nicolás, te mantendré informado
RafaParticipant
Senior
Gracias Nicolás funciona de maravilla 🙂
hola y como seria el indicador