Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Estrategia Larry Connors [JoseMetal]

A Pine Script v5 strategy built on SMA or EMA or WMA or HMA (close, 10), RSI (close, 2) and ATR (7). It has 8 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 10% of equity and pays no commission. 26 settings; defaults include Fecha inicio 0, TPSL SL ATR mult 3.1 and TPSL TP ATR mult 3.1.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Estrategia Larry Connors [JoseMetal] repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 10 of 10 trades.
How did Estrategia Larry Connors [JoseMetal] do on BTCUSDT 1D with default settings?
+2.70%
From 26 Jan 2024 to 21 Oct 2026, over 24 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Estrategia Larry Connors [JoseMetal] run in Pine Script v6?
Yes
Same 24 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Estrategia Larry Connors [JoseMetal] use a stop loss?
Yes
strategy.exit sets a stop on line 149, 159, 164, 168.
Does Estrategia Larry Connors [JoseMetal] run in Zeal Terminal?
Yes
It compiles in 55 ms and runs 1,000 bars in 127 ms, in the browser.

BTCUSDT · 1D · default settings

  • Media de salida
  • Media tendencial
  • Precio Entrada
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (26)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$10,270$20,253Equity from $10,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
+2.70%
$269.90
Buy and hold
+102.5%
same period
Closed trades
24
17 won · 7 lost
Profitable
70.8%
of closed trades
Profit factor
1.81
gross profit ÷ gross loss
Max drawdown
2.38%
−$238.18

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    12 settings have no label

    In the settings dialog fecha_inicio (line 32), fecha_fin (line 34), TPSL_SL_ATR_mult (line 44), TPSL_TP_ATR_mult (line 46), TPSL_break_even_mult (line 50), MA_SALIDA_fuente (line 58), MA_SALIDA_length (line 59), MA_TENDENCIA_fuente (line 62), MA_TENDENCIA_length (line 63), RSI_length (line 80), RSI_nivel_ob (line 83), ATR_length (line 87) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Período de pruebas
Fecha inicio (no label in the script)Las fechas son inclusivas0timevela_en_fecha
Fecha de finalizaciónfalseboolvela_en_fecha
Fecha fin (no label in the script)timestamp("1 Jan 2999")timevela_en_fecha
Posiciones
¿LONGS?trueboolentrar_en_LONG
¿SHORTS?trueboolentrar_en_SHORT
Stop Loss y Take Profit (ATR)
¿Usar Stop Loss? / Mult. ATRfalseboolline 141 exit Cerrar Long line 151 exit Cerrar Short
TPSL SL ATR mult (no label in the script)Si está activado, se usará el ATR multiplicado por éste valor como Stop Loss3.1float · min 0.1 · step 0.1ATR_sl
¿Usar Take Profit? / Mult. ATRfalseboolline 143 exit Cerrar Long line 153 exit Cerrar Short
TPSL TP ATR mult (no label in the script)Si está activado, se usará el ATR multiplicado por éste valor como Take Profit3.1float · min 0.1 · step 0.1ATR_tp
Break Even (ATR)
¿Proteger posiciones? (Break Even)falseboolNivel requerido para activar 'Break Even' Nivel de 'Break Even' line 145 line 155 line 161
• Mult. para BREAK EVEN y STOP LOSSCuando el precio avance a nuestro favor y llegue éste ATR, el Stop Loss se moverá a BREAK EVEN, de modo que la operación quede protegida.\nEl 'nivel de stop loss' nos permite que el stop se mueva aún más a favor de nuestro precio de entrada para además asegurar ganancias1.0float · min 0.0 · step 0.1ATR_be_req
TPSL break even mult (no label in the script)0.8float · min 0.0 · step 0.1ATR_be
General
Colorear velastrueboolcolor_velas
Marcar velas neutrastrueboolcolor_velas
MAs
• (Media de salida) Tipo / Fuente / Long.SMAstring · options ["SMA", "EMA", "WMA", "HMA"]line 65 line 67 line 69
MA SALIDA fuente (no label in the script)closesourceMA_SALIDA
MA SALIDA length (no label in the script)10int · min 1MA_SALIDA
• (Media de tendencia) Tipo / Fuente / Long.SMAstring · options ["SMA", "EMA", "WMA", "HMA"]line 71 line 73 line 75
MA TENDENCIA fuente (no label in the script)closesourceMA_TENDENCIA
MA TENDENCIA length (no label in the script)200int · min 1MA_TENDENCIA
RSI
• Fuente / LongitudclosesourceRSI
RSI length (no label in the script)2int · min 1RSI
• Sobreventa / Sobrecompra5int · min 0 · max 99RSI_en_sobreventa
RSI nivel ob (no label in the script)95int · min 1 · max 100RSI_en_sobrecompra
ATR
• Referencia / LongitudclosesourceATR_LONG_sl ATR_LONG_tp ATR_SHORT_sl ATR_SHORT_tp ATR_LONG_break_even_req ATR_SHORT_break_even_req ATR_LONG_break_even ATR_SHORT_break_even
ATR length (no label in the script)7int · min 1ATR

What it calculates

  • SMA / EMA / WMA / HMAMA SALIDA fuente (close), MA SALIDA length (10)MA_SALIDA · line 60
  • SMA / EMA / WMA / HMAMA TENDENCIA fuente (close), MA TENDENCIA length (200)MA_TENDENCIA · line 64
  • RSI• Fuente / Longitud (close), RSI length (2)RSI · line 81
  • ATRATR length (7)ATR · line 88

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

The script has 73 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Close Abrir Long(LONG_abierto and exit_LONG_conditions)On110
Close Abrir Short(SHORT_abierto and exit_SHORT_conditions)On112
Open Abrir Long long(entrar_en_LONG)On148
Exit Cerrar Long stop and limit(entrar_en_LONG)On149
Open Abrir Short short(entrar_en_SHORT)On158
Exit Cerrar Short stop and limit(entrar_en_SHORT)On159
Exit Cerrar Long stop and limit(LONG_abierto and LONG_stop_loss < LONG_break_even and close > LONG_break_even_req)On164
Exit Cerrar Short stop and limit(SHORT_abierto and SHORT_stop_loss > SHORT_break_even and close < SHORT_break_even_req)On168

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

10/10trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+2.7%+102.5%2471%1.812.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.3%+5.5%1861%1.500.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.5%+9.8%2458%0.806.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.1%+8.4%1974%1.150.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−2.3%+16.7%2854%0.776.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.2%+21.5%1867%0.871.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−1.6%+148.3%1953%0.684.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.3%+17.1%1681%1.430.9%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1070%$43.54
Sideways market1070%$165.14
Falling market475%$61.21

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

2.3%

The 95th percentile of the worst drawdown when the same 24 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.4% to 2.3%; the tick is what actually happened, 1.7%. Order luck alone moves it this much.

0%3%
All 24 trades
SideEntryExitBarsP&L
short14 Feb 2024 49,699.6023 Feb 2024 51,288.409−$31.97
short1 Mar 2024 61,131.0016 Mar 2024 69,499.8015−$136.46
short24 Apr 2024 66,414.0025 Apr 2024 64,289.601$31.45
short7 Jun 2024 70,799.1012 Jun 2024 67,314.205$48.55
short18 Jul 2024 64,088.0025 Jul 2024 65,376.007−$19.92
short15 Sep 2024 59,993.001 Oct 2024 63,327.6016−$54.98
long6 Nov 2024 69,372.007 Nov 2024 75,572.001$87.91
long25 Dec 2024 98,663.6026 Dec 2024 99,429.601$7.71
long28 Feb 2025 84,708.603 Mar 2025 94,270.003$112.11
long1 Jun 2025 104,592.008 Jun 2025 105,552.007$9.22
long4 Aug 2025 114,209.008 Aug 2025 117,472.004$28.73
long21 Aug 2025 114,271.0023 Aug 2025 116,936.002$23.51
long25 Sep 2025 113,307.0030 Sep 2025 114,312.005$8.96
long13 Oct 2025 114,959.0024 Oct 2025 110,078.0011−$42.94
short7 Jan 2026 93,748.0010 Jan 2026 90,641.303$33.38
short16 Jan 2026 95,604.8020 Jan 2026 92,631.004$31.43
short18 Mar 2026 73,909.4019 Mar 2026 71,246.601$36.52
short9 Apr 2026 71,069.9020 Apr 2026 73,801.8011−$39.10
short8 May 2026 80,006.0013 May 2026 80,504.505−$6.31
short17 Jun 2026 65,675.0019 Jun 2026 62,958.002$41.90
short8 Jul 2026 63,364.0014 Jul 2026 62,334.506$16.52
short23 Jul 2026 66,114.5025 Jul 2026 64,140.002$30.42
long12 Sep 2026 77,225.7019 Sep 2026 80,883.907$48.40
long10 Oct 2026 82,635.6021 Oct 2026 83,028.1011$4.88

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Estrategia Larry Connors [JoseMetal] this page—v5 strategy+2.7%242.4%
3 x EMA + Stochastic RSI + ATR by tomimarsonema rsi sma atrv4 strategy−42.3%1844.8%
Atrend by OTS by prim722ema rsi sma atrv4 strategy+12.1%7634.4%
DRSI DMA Scalping Strategy No Repaint by allenlksma wma ema rsiv4 strategy−99.5%44137.7%
EMA crossover (daily TF) by tradeswithashishema sma rsi atrv5 strategy+11.0%1211.6%
Delta-RSI Strategy (with filters) by tbiktagrsi ema atr smav4 strategy−28.8%7183.8%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Yes

Same 24 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © JoseMetal-//@version=5+//@version=6// Descripción de la estrategia:⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 55 msYes 1,000 bars in 127 msNot measured
PineTSNot testedNot testedNot measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © JoseMetal//@version=5// Descripción de la estrategia:// + LONG:// El precio debe estar por encima de la SMA lenta.// Cuando una vela cierra en la zona de sobreventa del RSI, la siguiente vela cierra fuera de la zona de sobreventa y el precio de cierre está POR DEBAJO de la SMA rápida = abre LONG.// Se cierra cuando una vela cierra POR ENCIMA de la SMA rápida.// - SHORT:// El precio debe estar POR DEBAJO de la SMA lenta.// Cuando una vela cierra en la zona de sobrecompra del RSI, la siguiente vela cierra fuera de la zona de sobrecompra y el precio de cierre está POR ENCIMA de la SMA rápida = abre SHORT.// Se cierra cuando una vela cierra POR DEBAJO de la SMA rápida.// *La estrategia de Larry Connor NO utiliza un Stop Loss o Take Profit fijo, como él dijo, eso reduce el rendimiento significativamente//== Constantesc_blanco              = color.rgb(255, 255, 255, 0)c_negro               = color.rgb(0, 0, 0, 0)c_amarillo_radiactivo = color.rgb(255, 255, 0, 0)c_cian_radiactivo     = color.rgb(0, 255, 255, 0)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) c_naranja_oscuro      = color.rgb(200, 120, 0, 0)noneColor             = color.new(color.white, 100)max_float             = 10000000000.0//== Funciones//== Declarar estrategia y período de testeostrategy("Larry Connors Strategy [JoseMetal]", shorttitle="Larry Connors Strategy [JoseMetal]", 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.0, max_labels_count=500, max_bars_back=1000)GRUPO_per_pruebas = "Período de pruebas"fecha_inicio     = input.time(0, "• Fecha de inicio", group=GRUPO_per_pruebas, tooltip="Las fechas son inclusivas") // timestamp("1 Jan 2000")fecha_fin_usar   = input.bool(false, "Fecha de finalización", group=GRUPO_per_pruebas, inline="fecha_finalizacion")fecha_fin        = input.time(timestamp("1 Jan 2999"), "", group=GRUPO_per_pruebas, inline="fecha_finalizacion")vela_en_fecha    = time >= fecha_inicio and (fecha_fin_usar ? time <= fecha_fin : true)posicion_abierta = strategy.position_size != 0LONG_abierto     = strategy.position_size > 0SHORT_abierto    = strategy.position_size < 0GRUPO_P           = "Posiciones"P_permitir_LONGS  = input.bool(title="¿LONGS?", group=GRUPO_P, defval=true, inline="pos_activadas")P_permitir_SHORTS = input.bool(title="¿SHORTS?", group=GRUPO_P, defval=true, inline="pos_activadas")GRUPO_TPSL       = "Stop Loss y Take Profit (ATR)"TPSL_SL_ATR_usar = input.bool(false, "¿Usar Stop Loss? / Mult. ATR", group=GRUPO_TPSL, inline="stop_loss")TPSL_SL_ATR_mult = input.float(3.1, "", group=GRUPO_TPSL, minval=0.1, step=0.1, inline="stop_loss", tooltip="Si está activado, se usará el ATR multiplicado por éste valor como Stop Loss")TPSL_TP_ATR_usar = input.bool(false, "¿Usar Take Profit? / Mult. ATR", group=GRUPO_TPSL, inline="take_profit")TPSL_TP_ATR_mult = input.float(3.1, "", group=GRUPO_TPSL, minval=0.1, step=0.1, inline="take_profit", tooltip="Si está activado, se usará el ATR multiplicado por éste valor como Take Profit")GRUPO_BE = "Break Even (ATR)"usar_be = input.bool(false, "¿Proteger posiciones? (Break Even)", group=GRUPO_BE)TPSL_break_even_req_mult = input.float(title="• Mult. para BREAK EVEN y STOP LOSS", group=GRUPO_BE, defval=1.0, minval=0.0, step=0.1, inline="be", tooltip="Cuando el precio avance a nuestro favor y llegue éste ATR, el Stop Loss se moverá a BREAK EVEN, de modo que la operación quede protegida.\nEl 'nivel de stop loss' nos permite que el stop se mueva aún más a favor de nuestro precio de entrada para además asegurar ganancias")TPSL_break_even_mult     = input.float(title="", group=GRUPO_BE, defval=0.8, minval=0.0, step=0.1, inline="be")GRUPO_general = "General"mostrar_color_velas = input.bool(title="Colorear velas", defval=true, group=GRUPO_general)mostrar_color_velas_2 = input.bool(title="Marcar velas neutras", defval=true, group=GRUPO_general)//== Inputs de indicadores// Medias móvilesGRUPO_MAs = "MAs"MA_SALIDA_tipo   = input.string(title="• (Media de salida) Tipo / Fuente / Long.", group=GRUPO_MAs, defval="SMA", options=["SMA", "EMA", "WMA", "HMA"], inline="ma_salida")MA_SALIDA_fuente = input.source(title="", group=GRUPO_MAs, defval=close, inline="ma_salida")MA_SALIDA_length = input.int(title="", group=GRUPO_MAs, defval=10, minval=1, inline="ma_salida")MA_SALIDA        = ta.sma(MA_SALIDA_fuente, MA_SALIDA_length)MA_TENDENCIA_tipo   = input.string(title="• (Media de tendencia) Tipo / Fuente / Long.", group=GRUPO_MAs, defval="SMA", options=["SMA", "EMA", "WMA", "HMA"], inline="ma_tendencia")MA_TENDENCIA_fuente = input.source(title="", group=GRUPO_MAs, defval=close, inline="ma_tendencia")MA_TENDENCIA_length = input.int(title="", group=GRUPO_MAs, defval=200, minval=1, inline="ma_tendencia")MA_TENDENCIA        = ta.sma(MA_TENDENCIA_fuente, MA_TENDENCIA_length)if (MA_SALIDA_tipo == "EMA")    MA_SALIDA := ta.ema(MA_SALIDA_fuente, MA_SALIDA_length)else if (MA_SALIDA_tipo == "WMA")    MA_SALIDA := ta.wma(MA_SALIDA_fuente, MA_SALIDA_length)else if (MA_SALIDA_tipo == "HMA")    MA_SALIDA := ta.hma(MA_SALIDA_fuente, MA_SALIDA_length)if (MA_TENDENCIA_tipo == "EMA")    MA_TENDENCIA := ta.ema(MA_TENDENCIA_fuente, MA_TENDENCIA_length)else if (MA_TENDENCIA_tipo == "WMA")    MA_TENDENCIA := ta.wma(MA_TENDENCIA_fuente, MA_TENDENCIA_length)else if (MA_TENDENCIA_tipo == "HMA")    MA_TENDENCIA := ta.hma(MA_TENDENCIA_fuente, MA_TENDENCIA_length)// RSIGRUPO_RSI    = "RSI"RSI_src      = input.source(title="• Fuente / Longitud", group=GRUPO_RSI, defval=close, inline="rsi_calc")RSI_length   = input.int(title="", group=GRUPO_RSI, defval=2, minval=1, inline="rsi_calc")RSI          = ta.rsi(RSI_src, RSI_length)RSI_nivel_os = input.int(title="• Sobreventa / Sobrecompra", group=GRUPO_RSI, defval=5, minval=0, maxval=99, inline="rsi_niveles")RSI_nivel_ob = input.int(title="", group=GRUPO_RSI, defval=95, minval=1, maxval=100, inline="rsi_niveles")// ATRGRUPO_ATR      = "ATR"ATR_referencia = input.source(title="• Referencia / Longitud", group=GRUPO_ATR, defval=close, inline="atr_calc") // La fuente no se aplica al cálculo del ATR, es para el posicionamiento respecto al precio en el gráficoATR_length     = input.int(title="", group=GRUPO_ATR, defval=7, minval=1, inline="atr_calc")ATR            = ta.atr(ATR_length)ATR_sl         = ATR * TPSL_SL_ATR_multATR_tp         = ATR * TPSL_TP_ATR_multATR_be_req     = ATR * TPSL_break_even_req_multATR_be         = ATR * TPSL_break_even_multATR_LONG_sl    = ATR_referencia - ATR_sl // De forma contraria el inferior se puede usar como STOP LOSS o TRAILING STOPATR_LONG_tp    = ATR_referencia + ATR_tp // El ATR sobre las velas se puede usar como TAKE PROFITATR_SHORT_sl   = ATR_referencia + ATR_sl // ""ATR_SHORT_tp   = ATR_referencia - ATR_tp // Para Shorts es al revésATR_LONG_break_even_req  = ATR_referencia + ATR_be_reqATR_SHORT_break_even_req = ATR_referencia - ATR_be_reqATR_LONG_break_even  = ATR_referencia + ATR_beATR_SHORT_break_even = ATR_referencia - ATR_be//== Cálculo de condicionescierre_sobre_MA_SALIDA = close > MA_SALIDAtendencia_alcista  = close > MA_TENDENCIARSI_en_sobreventa  = RSI < RSI_nivel_osRSI_en_sobrecompra = RSI > RSI_nivel_ob//== Salida de posicionesexit_LONG_conditions  = cierre_sobre_MA_SALIDAexit_SHORT_conditions = not cierre_sobre_MA_SALIDAif (LONG_abierto and exit_LONG_conditions)    strategy.close("Abrir Long")if (SHORT_abierto and exit_SHORT_conditions)    strategy.close("Abrir Short")//== Entrada de posiciones (deben cumplirse todas para entrar)LONG_condition_1    = tendencia_alcistaLONG_condition_2    = not cierre_sobre_MA_SALIDA // Vela con cierre bajo la media rápidaLONG_condition_3    = RSI_en_sobreventa[1] and not RSI_en_sobreventa // Sobreventa en la vela anterior y ya no en la actualall_LONG_conditions = LONG_condition_1 and LONG_condition_2 and LONG_condition_3entrar_en_LONG      = P_permitir_LONGS and all_LONG_conditions and vela_en_fecha and not LONG_abiertoSHORT_condition_1    = not tendencia_alcistaSHORT_condition_2    = cierre_sobre_MA_SALIDA // Vela con cierre sobre la media rápidaSHORT_condition_3    = RSI_en_sobrecompra[1] and not RSI_en_sobrecompra // Sobrecompra en la vela anterior y ya no en la actualall_SHORT_conditions = SHORT_condition_1 and SHORT_condition_2 and SHORT_condition_3entrar_en_SHORT      = P_permitir_SHORTS and all_SHORT_conditions and vela_en_fecha and not SHORT_abiertovar LONG_stop_loss       = 0.0var LONG_take_profit     = max_floatvar LONG_break_even_req  = 0.0var LONG_break_even      = 0.0var SHORT_stop_loss      = max_floatvar SHORT_take_profit    = 0.0var SHORT_break_even_req = 0.0var SHORT_break_even     = 0.0var en_be = falseif (not posicion_abierta)    en_be := false    LONG_stop_loss    := 0.0    LONG_take_profit  := max_float    SHORT_stop_loss   := max_float    SHORT_take_profit := 0.0if (not posicion_abierta)    if (entrar_en_LONG)        if (TPSL_SL_ATR_usar)            LONG_stop_loss   := ATR_LONG_sl        if (TPSL_TP_ATR_usar)            LONG_take_profit := ATR_LONG_tp        if (usar_be)            LONG_break_even_req := ATR_LONG_break_even_req            LONG_break_even     := ATR_LONG_break_even        strategy.entry("Abrir Long", strategy.long)        strategy.exit("Cerrar Long", "Abrir Long", stop=TPSL_SL_ATR_usar ? LONG_stop_loss : na, limit=TPSL_TP_ATR_usar ? LONG_take_profit : na)    else if (entrar_en_SHORT)        if (TPSL_SL_ATR_usar)            SHORT_stop_loss   := ATR_SHORT_sl        if (TPSL_TP_ATR_usar)            SHORT_take_profit := ATR_SHORT_tp        if (usar_be)            SHORT_break_even_req := ATR_SHORT_break_even_req            SHORT_break_even     := ATR_SHORT_break_even        strategy.entry("Abrir Short", strategy.short)        strategy.exit("Cerrar Short", "Abrir Short", stop=TPSL_SL_ATR_usar ? SHORT_stop_loss : na, limit=TPSL_TP_ATR_usar ? SHORT_take_profit : na)// Proteger operativa (Break Even)if (usar_be and not en_be)    if (LONG_abierto and LONG_stop_loss < LONG_break_even and close > LONG_break_even_req)        LONG_stop_loss := LONG_break_even        strategy.exit("Cerrar Long", "Abrir Long", stop=LONG_stop_loss, limit=TPSL_TP_ATR_usar ? LONG_take_profit : na)        en_be := true    else if (SHORT_abierto and SHORT_stop_loss > SHORT_break_even and close < SHORT_break_even_req)        SHORT_stop_loss := SHORT_break_even        strategy.exit("Cerrar Short", "Abrir Short", stop=SHORT_stop_loss, limit=TPSL_TP_ATR_usar ? SHORT_take_profit : na)        en_be := true//== Ploteo en pantalla// SMAsplot(MA_SALIDA, "Media de salida", color=color.aqua, linewidth=2)plot(MA_TENDENCIA, "Media tendencial", color=tendencia_alcista ? #00a800 : #ca0000, linewidth=4)// Color de fondobgcolor = entrar_en_LONG ? color.new(color.green, 85) : entrar_en_SHORT ? color.new(color.red, 85) : color.new(color.black, 100)bgcolor(bgcolor)// Color de las velas según sobrecompra/sobreventa del RSIcolor_velas = mostrar_color_velas ? (RSI_en_sobreventa ? c_verde_radiactivo : RSI_en_sobrecompra ? c_rojo_radiactivo : mostrar_color_velas_2 ? c_negro : na) : nabarcolor(color_velas)// Precio de compra, Stop Loss, Take Profit, Break Even...avg_position_price_plot = plot(posicion_abierta ? strategy.position_avg_price : na, color=color.new(color.white, 25), style=plot.style_linebr, linewidth=2, title="Precio Entrada")break_even_req_plot     = plot(posicion_abierta and usar_be and not en_be ? (LONG_abierto ? LONG_break_even_req : SHORT_break_even_req) : na, color=color.new(color.blue, 25), style=plot.style_linebr, linewidth=1, title="Nivel requerido para activar 'Break Even'")break_even_plot         = plot(posicion_abierta and usar_be and not en_be ? (LONG_abierto ? LONG_break_even : SHORT_break_even) : na, color=color.new(color.aqua, 25), style=plot.style_linebr, linewidth=1, title="Nivel de 'Break Even'")LONG_sl_plot            = plot(LONG_abierto and LONG_stop_loss > 0.0 ? LONG_stop_loss : na, color=en_be ? color.new(color.aqua, 25) : color.new(color.red, 25), style=plot.style_linebr, linewidth=3, title="Long Stop Loss")LONG_tp_plot            = plot(LONG_abierto and LONG_take_profit < max_float ? LONG_take_profit : na, color=color.new(color.lime, 25), style=plot.style_linebr, linewidth=3, title="LONG Take Profit")fill(avg_position_price_plot, LONG_sl_plot, color=color.new(color.maroon, 85))fill(avg_position_price_plot, LONG_tp_plot, color=color.new(color.olive, 85))SHORT_sl_plot            = plot(SHORT_abierto and SHORT_stop_loss < max_float ? SHORT_stop_loss : na, color=en_be ? color.new(color.aqua, 25) : color.new(color.red, 25), style=plot.style_linebr, linewidth=3, title="Short Stop Loss")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")fill(avg_position_price_plot, SHORT_sl_plot, color=color.new(color.maroon, 85))fill(avg_position_price_plot, SHORT_tp_plot, color=color.new(color.olive, 85))