Jh. " Le crédit pour chaque indicateur leur appartient, je viens de les modifier pour ajouter quelques options supplémentaires, paramètres, etc, aussi mis à jour tout le code à PineScript 5.
=== La stratégie === Les paramètres par défaut sont déjà tels que requis par TRADE KING, vous n'avez donc rien à changer. Pour les LONGS (fond vert montre les entrées LONGS).
Pour les courts métrages (sur fond rouge, les entrées sont des courts métrages).
Veuillez consulter la chaîne YouTube de Trade King pour plus d'informations.
=== Améliorations générales === Mettez à niveau vers PineScript 5. Quelques améliorations de performance.
=== Notes personnelles === L'auteur de cette stratégie recommande les graphiques 5M, cependant, 4H s'avère être le meilleur.
Merci encore aux auteurs des indicateurs qui composent ce scénario et à TRADE KING pour avoir créé cette stratégie.
test de retour
/*backtest start: 2022-04-09 00:00:00 end: 2022-05-08 23:59:00 period: 3m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // © JoseMetal //@version=5 // //== Constantes c_verde_radiactivo = color.rgb(0, 255, 0, 0) c_verde = color.rgb(0, 128, 0, 0) c_verde_oscuro = color.rgb(0, 80, 0, 0) c_rojo_radiactivo = color.rgb(255, 0, 0, 0) c_rojo = color.rgb(128, 0, 0, 0) c_rojo_oscuro = color.rgb(80, 0, 0, 0) //== Funciones //== Declarar estrategia y período de testeo //strategy("EMA + AROON + ASH (TRADE KING's STRATEGY)", shorttitle="EMA + AROON + ASH (TRADE KING's STRATEGY)", overlay=true, initial_capital=10000, pyramiding=0, default_qty_value=10, default_qty_type=strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.00075, max_labels_count=500, max_bars_back=1000) //fecha_inicio = input.time(timestamp("1 Jan 2000"), title="• Start date", group="Test period", inline="periodo_de_pruebas") vela_en_fecha = true posicion_abierta = strategy.position_size != 0 LONG_abierto = strategy.position_size > 0 SHORT_abierto = strategy.position_size < 0 //== Condiciones de entrada y salida de estrategia GRUPO_P = "Positions" P_permitir_LONGS = input.bool(title="¿LONGS?", group=GRUPO_P, defval=true) P_permitir_SHORTS = input.bool(title="¿SHORTS?", group=GRUPO_P, defval=true) GRUPO_TPSL = "TP y SL" TPSL_TP_pivot_lookback = input.int(title="• SL lookback for pivot / Mult. TP", group=GRUPO_TPSL, defval=20, minval=1, step=1, inline="tp_sl") TPSL_SL_mult = input.float(title="", group=GRUPO_TPSL, defval=2.0, minval=0.1, step=0.2, inline="tp_sl") //== Inputs de indicadores // EMA GRUPO_EMA = "Exponential Moving Average (EMA)" EMA_length = input.int(200, minval=1, title="Length", group=GRUPO_EMA) EMA_src = input(close, title="Source", group=GRUPO_EMA) EMA = ta.ema(EMA_src, EMA_length) // Aroon GRUPO_Aroon = "Aroon" Aroon_length = input.int(title="• Length", group=GRUPO_Aroon, defval=20, minval=1) Aroon_upper = 100 * (ta.highestbars(high, Aroon_length+1) + Aroon_length) / Aroon_length Aroon_lower = 100 * (ta.lowestbars(low, Aroon_length+1) + Aroon_length) / Aroon_length // ASH GRUPO_ASH = "Absolute Strength Histogram v2 | jh" ASH_Length = input(9, title='Period of Evaluation', group=GRUPO_ASH) ASH_Smooth = input(3, title='Period of Smoothing', group=GRUPO_ASH) ASH_src = input(close, title='Source') ASH_Mode = input.string(title='Indicator Method', defval='RSI', options=['RSI', 'STOCHASTIC', 'ADX']) ASH_ma_type = input.string(title='MA', defval='WMA', options=['ALMA', 'EMA', 'WMA', 'SMA', 'SMMA', 'HMA']) ASH_alma_offset = input.float(defval=0.85, title='* Arnaud Legoux (ALMA) Only - Offset Value', minval=0, step=0.01) ASH_alma_sigma = input.int(defval=6, title='* Arnaud Legoux (ALMA) Only - Sigma Value', minval=0) _MA(type, src, len) => float result = 0 if type == 'SMA' // Simple result := ta.sma(src, len) result if type == 'EMA' // Exponential result := ta.ema(src, len) result if type == 'WMA' // Weighted result := ta.wma(src, len) result if type == 'SMMA' // Smoothed w = ta.wma(src, len) result := na(w[1]) ? ta.sma(src, len) : (w[1] * (len - 1) + src) / len result if type == 'HMA' // Hull result := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len))) result if type == 'ALMA' // Arnaud Legoux result := ta.alma(src, len, ASH_alma_offset, ASH_alma_sigma) result result Price1 = _MA('SMA', ASH_src, 1) Price2 = _MA('SMA', ASH_src[1], 1) // RSI Bulls0 = 0.5 * (math.abs(Price1 - Price2) + Price1 - Price2) Bears0 = 0.5 * (math.abs(Price1 - Price2) - (Price1 - Price2)) // STOCHASTIC Bulls1 = Price1 - ta.lowest(Price1, ASH_Length) Bears1 = ta.highest(Price1, ASH_Length) - Price1 // ADX Bulls2 = 0.5 * (math.abs(high - high[1]) + high - high[1]) Bears2 = 0.5 * (math.abs(low[1] - low) + low[1] - low) Bulls = ASH_Mode == 'RSI' ? Bulls0 : ASH_Mode == 'STOCHASTIC' ? Bulls1 : Bulls2 Bears = ASH_Mode == 'RSI' ? Bears0 : ASH_Mode == 'STOCHASTIC' ? Bears1 : Bears2 AvgBulls = _MA(ASH_ma_type, Bulls, ASH_Length) AvgBears = _MA(ASH_ma_type, Bears, ASH_Length) SmthBulls = _MA(ASH_ma_type, AvgBulls, ASH_Smooth) SmthBears = _MA(ASH_ma_type, AvgBears, ASH_Smooth) difference = math.abs(SmthBulls - SmthBears) //== Cálculo de condiciones EMA_alcista = close > EMA EMA_bajista = close < EMA Aroon_cruce_alcista = ta.crossover(Aroon_upper, Aroon_lower) Aroon_cruce_bajista = ta.crossunder(Aroon_upper, Aroon_lower) ASH_alcista = SmthBulls > SmthBears ASH_bajista = SmthBulls < SmthBears //== Entrada (deben cumplirse todas para entrar) longCondition1 = EMA_alcista longCondition2 = Aroon_cruce_alcista longCondition3 = ASH_alcista long_conditions = longCondition1 and longCondition2 and longCondition3 entrar_en_LONG = P_permitir_LONGS and long_conditions and vela_en_fecha and not posicion_abierta shortCondition1 = EMA_bajista shortCondition2 = Aroon_cruce_bajista shortCondition3 = ASH_bajista short_conditions = shortCondition1 and shortCondition2 and shortCondition3 entrar_en_SHORT = P_permitir_SHORTS and short_conditions and vela_en_fecha and not posicion_abierta var LONG_stop_loss = 0.0 var LONG_take_profit = 0.0 var SHORT_stop_loss = 0.0 var SHORT_take_profit = 0.0 //psl = ta.pivotlow(TPSL_TP_pivot_lookback, TPSL_TP_pivot_lookback) //psh = ta.pivothigh(TPSL_TP_pivot_lookback, TPSL_TP_pivot_lookback) psl = ta.lowest(TPSL_TP_pivot_lookback) psh = ta.highest(TPSL_TP_pivot_lookback) if (entrar_en_LONG) LONG_stop_loss := psl - close*0.001 LONG_take_profit := close + ((close - LONG_stop_loss) * TPSL_SL_mult) strategy.entry("+ Long", strategy.long) strategy.exit("- Long", "+ Long", limit=LONG_take_profit, stop=LONG_stop_loss) if (entrar_en_SHORT) SHORT_stop_loss := psh + close*0.001 SHORT_take_profit := close - ((SHORT_stop_loss - close) * TPSL_SL_mult) strategy.entry("+ Short", strategy.short) strategy.exit("- Short", "+ Short", limit=SHORT_take_profit, stop=SHORT_stop_loss) //== Ploteo en pantalla // EMA plot(EMA, color=color.white, linewidth=2) // Símbolo de entrada (entre o no en compra) bgcolor = color.new(color.black, 100) if (entrar_en_LONG or entrar_en_SHORT) bgcolor := color.new(color.green, 90) bgcolor(bgcolor) // Precio de compra, Take Profit, Stop Loss y relleno avg_position_price_plot = plot(series=posicion_abierta ? strategy.position_avg_price : na, color=color.new(color.white, 25), style=plot.style_linebr, linewidth=2, title="Precio Entrada") LONG_tp_plot = plot(LONG_abierto and LONG_take_profit > 0.0 ? LONG_take_profit : na, color=color.new(color.lime, 25), style=plot.style_linebr, linewidth=3, title="LONG Take Profit") LONG_sl_plot = plot(LONG_abierto and LONG_stop_loss > 0.0 ? LONG_stop_loss : na, color=color.new(color.red, 25), style=plot.style_linebr, linewidth=3, title="Long Stop Loss") fill(avg_position_price_plot, LONG_tp_plot, color=color.new(color.olive, 85)) fill(avg_position_price_plot, LONG_sl_plot, color=color.new(color.maroon, 85)) SHORT_tp_plot = plot(SHORT_abierto and SHORT_take_profit > 0.0 ? SHORT_take_profit : na, color=color.new(color.lime, 25), style=plot.style_linebr, linewidth=3, title="SHORT Take Profit") SHORT_sl_plot = plot(SHORT_abierto and SHORT_stop_loss > 0.0 ? SHORT_stop_loss : na, color=color.new(color.red, 25), style=plot.style_linebr, linewidth=3, title="Short Stop Loss") fill(avg_position_price_plot, SHORT_tp_plot, color=color.new(color.olive, 85)) fill(avg_position_price_plot, SHORT_sl_plot, color=color.new(color.maroon, 85))