1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
63 lines of Pine Script v4 from Booz Strategy.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Booz Strategy.pine
////////////////////////////////////////////////////////////////////////////////
// ArnoldTrader - Estrategia Booz
// Creado por Arnold para la Comunidad
// Versión 1.2 - Última actualización: 2023-06-22
////////////////////////////////////////////////////////////////////////////////
//@timeframe=120
// Esta es la versión de ArnoldTrader de la Estrategia Booz, creada por Arnold para la Comunidad.
// La estrategia utiliza una combinación de promedios móviles y filtros de tendencia para identificar posibles operaciones.
// También incluye entradas personalizables para el stop loss, take profit, apalancamiento y período de backtest.
// ¡Feliz trading!
//@version=4
strategy("Estrategia Booz", "", true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, margin_long=0, margin_short=0)
// ----------------------------- Inputs ------------------------------------- //
source_ma_type = input("EMA", "Tipo de MA Fuente", options=["SMA", "EMA"])
source_ma_length = input(50, "Longitud de la MA Fuente")
fast_ma_length = input(50, "Longitud de la MA Rápida")
slow_ma_length = input(100, "Longitud de la MA Lenta")
use_trend_filter = input(true, "Filtro de Tendencia")
trend_filter_ma_type = input("EMA", "Tipo de MA Filtro de Tendencia", options=["SMA", "EMA"])
trend_filter_ma_length = input(200, "Período de la MA Filtro de Tendencia")
show_mas = input(true, "Mostrar MAs")
swing_trading_mode = input(false, "Modo de Trading Swing")
// -------------------------- Calculations ---------------------------------- //
fast_ma = ema(close, fast_ma_length)
slow_ma = ema(close, slow_ma_length)
source_ma = source_ma_type == "EMA"? ema(close, source_ma_length):
sma(close, source_ma_length)
trend_filter_ma = trend_filter_ma_type == "EMA"? ema(close, trend_filter_ma_length):
sma(close, trend_filter_ma_length)
// --------------------------- Conditions ----------------------------------- //
uptrend = not use_trend_filter or close > trend_filter_ma
buy_cond = crossover(fast_ma, slow_ma) and uptrend
downtrend = not use_trend_filter or close < trend_filter_ma
sell_cond = crossunder(fast_ma, slow_ma) and downtrend
// ---------------------------- Plotting ------------------------------------ //
bgcolor(use_trend_filter and downtrend? color.red: use_trend_filter? color.green: na)
plot(show_mas? fast_ma: na, "MA Rápida", color.green)
plot(show_mas? slow_ma: na, "MA Lenta", color.red)
plot(show_mas? source_ma: na, "MA Fuente", color.purple)
plot(show_mas? trend_filter_ma: na, "MA Filtro de Tendencia", color.blue)
// ---------------------------- Trading ------------------------------------ //
// Inputs
sl_perc = input(1.0, "Stop Loss (en %)", group="Control de Backtest")/100
tp_perc = input(1.0, "Take Profit (en %)", group="Control de Backtest")/100
leverage = input(1, "Apalancamiento", maxval=100, group="Control de Backtest")
bt_start_time = input(timestamp("2021 01 01"), "Hora de inicio de Backtest", input.time, group="Control de Backtest")
bt_end_time = input(timestamp("2029 12 31"), "Hora de finalización de Backtest", input.time, group="Control de Backtest")
// Trading Window
in_trading_window = time >= bt_start_time and time <= bt_end_time
trade_qty = (strategy.equity * leverage) / close
// Long Side
strategy.entry("Compra", strategy.long, trade_qty, when=buy_cond and in_trading_window)
long_tp = strategy.position_avg_price * (1 + tp_perc)
long_sl = strategy.position_avg_price * (1 - sl_perc)
if not swing_trading_mode
strategy.exit("Cierre Compra", "Compra", limit=long_tp, stop=long_sl)
// Short Side
strategy.entry("Venta", strategy.short, trade_qty, when=sell_cond and in_trading_window)
short_tp = strategy.position_avg_price * (1 - tp_perc)
short_sl = strategy.position_avg_price * (1 + sl_perc)
if not swing_trading_mode
strategy.exit("Cierre Venta", "Venta", limit=short_tp, stop=short_sl)
Expand (76 lines)
Overview
Estrategia Booz buys when a fast exponential moving average crosses above a slow one in an uptrend, and sells on the opposite cross in a downtrend. An optional source average and a longer trend filter, each selectable as SMA or EMA, can limit entries to the prevailing direction. Position size uses full equity scaled by a leverage input inside a chosen backtest window. Percentage stop-loss and take-profit levels are calculated from the average entry price. Moving averages and trend background colors can be shown or hidden.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Tipo de MA Fuente
string
EMA
source_ma_type
Longitud de la MA Fuente
int
50
source_ma_length
Longitud de la MA Rápida
int
50
fast_ma_length
Longitud de la MA Lenta
int
100
slow_ma_length
Filtro de Tendencia
bool
true
use_trend_filter
Tipo de MA Filtro de Tendencia
string
EMA
trend_filter_ma_type
Período de la MA Filtro de Tendencia
int
200
trend_filter_ma_length
Mostrar MAs
bool
true
show_mas
Modo de Trading Swing
bool
false
swing_trading_mode
Stop Loss (en %)
float
1.0
sl_perc
Take Profit (en %)
float
1.0
tp_perc
Apalancamiento
int
1
leverage
Show all 14 settings
Setting
Type
Default
Variable
Hora de inicio de Backtest
time
timestamp("2021 01 01")
bt_start_time
Hora de finalización de Backtest
time
timestamp("2029 12 31")
bt_end_time
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
Doge SMA is a long-only moving-average crossover strategy drawn on the price chart. It calculates a fast and a slow simple moving average of close and enters a long position when the fast average crosses above the slow average, but only inside a user-defined s
This strategy calculates and plots a fast Exponential Moving Average (EMA) and a slow EMA directly on the main price chart. It enters long trades when the fast EMA crosses above the slow EMA and exits when the fast EMA crosses below the slow EMA. Inputs allow
2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the
This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can
This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross
This educational strategy demonstrates how to configure and handle user input parameters in Pine Script. It calculates two Simple Moving Averages (SMAs) for fast and slow periods, plotting both directly on the price chart. The strategy initiates a long positio