DEFPARAM CumulateOrders = True
//Detectar nuevas entradas
promediar = (LOngOnMarket AND ShortOnMarket[1]) OR (LOngOnMarket[1] AND ShortOnMarket) OR (OnMarket AND Not OnMarket[1])
//Ver cuantas posiciones hay abiertas
Posiciones = abs(CountOfPosition)
compra = CompraLarga1 AND CompraLarga2
//Temporalidad de 5min
TIMEFRAME(5 Minute)
CompraLarga1 = RSI[14]> 30 and Stochastic[14,3] > 20
//Temporalidad de 1min
TIMEFRAME(1 Minute )
ONCE PreciodeReferencia = 0
CompraLarga2 = RSI[14] > 30 and Stochastic[14,3] > 20
VentaLarga1 = Stochastic[14,3](close) > 40
//Borrar variables
IF Not OnMarket THEN
EntryPrice = 1
PreciodeReferencia = 0
ENDIF
//Promedia cuando baje un 1,5%
IF LongOnMarket THEN
IF close <= (PreciodeReferencia * 0.985) THEN //1.5% drop (100 - 0.015)
BUY 2 SHARES AT MARKET
PreciodeReferencia = close
ENDIF
ELSIF ShortOnMarket THEN
IF LongOnMarket >= CompraLarga2 * 0.5 THEN //1.5% drop (100 - 0.015)
SELLSHORT AT Market
ENDIF
ENDIF
// Condiciones para entrada de posiciones largas
IF NOT LongOnMarket AND CompraLarga2 THEN
BUY 2 SHARES AT MARKET
PreciodeReferencia = close
ENDIF
// Condiciones de salida de posiciones largas
If LongOnMarket AND VentaLarga1 THEN
SELL AT MARKET
ENDIF
// Stops y targets: introduzca aquí sus stops de protección y targets de beneficios
GraphOnPrice PreciodeReferencia coloured("Blue")