Estas son estrategias combinadas para obtener una señal acumulada.
Primera estrategia Este indicador representa una media móvil exponencial de 2/20. En el caso del indicador AVG X 2/20, la barra EMA se pintará cuando se cumplan los criterios de Alerta.
Segunda estrategia El artículo relacionado es material con derechos de autor de Acciones y materias primas Mar 2010
Advertencia:
Prueba posterior
//@version=5 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 05/04/2022 // This is combo strategies for get a cumulative signal. // // First strategy // This indicator plots 2/20 exponential moving average. For the Mov // Avg X 2/20 Indicator, the EMA bar will be painted when the Alert criteria is met. // // Second strategy // The related article is copyrighted material from // Stocks & Commodities Mar 2010 // // // WARNING: // - For purpose educate only // - This script to change bars colors. //////////////////////////////////////////////////////////// EMA20(Length) => pos = 0.0 xPrice = close xXA = ta.ema(xPrice, Length) nHH = math.max(high, high[1]) nLL = math.min(low, low[1]) nXS = nLL > xXA or nHH < xXA ? nLL : nHH iff_1 = nXS < close[1] ? 1 : nz(pos[1], 0) pos := nXS > close[1] ? -1 : iff_1 pos BPF(Length,Delta,SellZone,BuyZone) => pos = 0.0 xPrice = hl2 beta = math.cos(3.14 * (360 / Length) / 180) gamma = 1 / math.cos(3.14 * (720 * Delta / Length) / 180) alpha = gamma - math.sqrt(gamma * gamma - 1) BP = 0.0 BP := 0.5 * (1 - alpha) * (xPrice - xPrice[2]) + beta * (1 + alpha) * nz(BP[1]) - alpha * nz(BP[2]) pos:= BP > SellZone ? 1 : BP <= BuyZone? -1 : nz(pos[1], 0) pos strategy(title='Combo 2/20 EMA & Bandpass Filter', shorttitle='Combo', overlay=true) var I1 = '●═════ 2/20 EMA ═════●' Length = input.int(14, minval=1, group=I1) var I2 = '●═════ Bandpass Filter ═════●' LengthBPF = input.int(20, minval=1, group=I2) Delta = input(0.5, group=I2) SellZone = input.float(5, step = 0.01, group=I2) BuyZone = input.float(-5, step = 0.01, group=I2) var misc = '●═════ MISC ═════●' reverse = input.bool(false, title='Trade reverse', group=misc) var timePeriodHeader = '●═════ Time Start ═════●' d = input.int(1, title='From Day', minval=1, maxval=31, group=timePeriodHeader) m = input.int(1, title='From Month', minval=1, maxval=12, group=timePeriodHeader) y = input.int(2005, title='From Year', minval=0, group=timePeriodHeader) StartTrade = time > timestamp(y, m, d, 00, 00) ? true : false posEMA20 = EMA20(Length) prePosBPF = BPF(LengthBPF,Delta,SellZone,BuyZone) iff_1 = posEMA20 == -1 and prePosBPF == -1 and StartTrade ? -1 : 0 pos = posEMA20 == 1 and prePosBPF == 1 and StartTrade ? 1 : iff_1 iff_2 = reverse and pos == -1 ? 1 : pos possig = reverse and pos == 1 ? -1 : iff_2 if possig == 1 strategy.entry('Long', strategy.long) if possig == -1 strategy.entry('Short', strategy.short) if possig == 0 strategy.close_all() //barcolor(possig == -1 ? #b50404 : possig == 1 ? #079605 : #0536b3)