Baseline Backtest [Loxx]

loxx Updated   
Baseline Backtest is the backtesting strategy for the simple-form moving averages that appear in Loxx's publish scripts.

You can read about some of these Moving Averages here:

Moving averages not included in script above are AMA, KAMA, T3, Kalman Filter, and VIDYA. You can read about these additional moving averages by searching my scripts where they are used throughout my public indicators.

This backtest also includes Expanded Source Types you can read about here:

v1.0 Included Moving Averages
Adaptive Moving Average - AMA
ADXvma - Average Directional Volatility Moving Average
Ahrens Moving Average
Alexander Moving Average - ALXMA
Double Exponential Moving Average - DEMA
Double Smoothed Exponential Moving Average - DSEMA
Exponential Moving Average - EMA
Fast Exponential Moving Average - FEMA
Fractal Adaptive Moving Average - FRAMA
Hull Moving Average - HMA
IE/2 - Early maout by Tim Tilson
Integral of Linear Regression Slope - ILRS
Instantaneous Trendline
Kalman Filter
Kaufman Adaptive Moving Average - KAMA
Laguerre Filter
Leader Exponential Moving Average
Linear Regression Value - LSMA (Least Squares Moving Average)
Linear Weighted Moving Average - LWMA
McGinley Dynamic
McNicholl EMA
Non-Lag Moving Average
Parabolic Weighted Moving Average
Recursive Moving Trendline
Simple Moving Average - SMA
Sine Weighted Moving Average
Smoothed Moving Average - SMMA
Super Smoother
Three-pole Ehlers Butterworth
Three-pole Ehlers Smoother
Triangular Moving Average - TMA
Triple Exponential Moving Average - TEMA
Two-pole Ehlers Butterworth
Two-pole Ehlers smoother
Variable Index Dynamic Average - VIDYA
Volume Weighted EMA - VEMA
Zero-Lag DEMA - Zero Lag Double Exponential Moving Average
Zero-Lag Moving Average
Zero Lag TEMA - Zero Lag Triple Exponential Moving Average

Volatility Types
v1.0 Included Volatility
Average True Range (ATR)
True Range Double (TRD)

Take profit philosophy
The Take Profits and Stop Loss are based on multiples of volatility. So, if you set Take Profit 1 to a multiple of 1, which is the default, then the the Take Profit 1 for a Long is:

source + multiplier x volatility in price or source + 1.0 x volatility in price

If you set the Stoploss to a multiplier of 1.5, then the Stoploss for a Long is set to:

source - multiplier x volatility in price or source - 1.5 x volatility in price

Trading Rules
Post Baseline Cross Qualifier (PBCQ): If price crosses the baseline but the trade is invalid due to additional qualifiers, then the strategy doesn't enter a trade on that candle. This setting allows you override this disqualification in the following manner: If price crosses XX bars ago and is now qualified by other qualifiers, then the strategy enters a trade.

Volatility: If price crosses the baseline, we check to see how far it has moved in terms of multiples of volatility denoted in price (ATR x multiple). If price has moved by at least "Qualifier multiplier" and less than "Range Multiplier", then the strategy enters a trade. This range is shown on the chart with yellow area that tracks price above/blow the baseline. Also, see the dots at the top of the chart. If the dots are green, then price passes the volatility test for a long. If the dots are red, then price passes the volatility test for a short.

Take Profit/Stoploss Quantity Removed
1 Take Profit: 100% of the trade is closed when the profit target or stoploss is reached.
2 Take Profits: Quantity is split 50/50 between Take Profit 1 and Take Profit 2
3 Take Profits: Quantify is split 50/25/25.

Example: If you select 3 Take Profits and you purchase 1 BTC, then when Take Profit 1 hits, the strategy will remove 50% of the trade, meaning you'll have 0.5 BTC left in the trade. When Take Profit 2 hits, the strategy will remove 50% of 0.5 BTC leaving 0.25 BTC in the trade. When Take Profit 3 hits, then whatever is left in the trade is removed from the trade.

Moving Stoploss
1 Take Profit: The Stoploss doesn't move
2 Take Profits: After Take Profit 1 is hit, then the Stoploss moves to the trade Entry
3 Take Profits: After Take Profit 1 is hit, then the Stoploss for Take Profit 2 and Take Profit 3 is move to trade Entry. When Take Profit 2 is hit, then Take Profit 3 Stoploss is moved to Take Profit 1

Date Range
Select starting (from) date for the backtest and ending (through) date for the backtest.

Other things to know
The strategy does't exit on the entry candle. This is a safety measure to keep the backtest results clean and accurate. After the strategy enters a trade, it will wait until candle close to set take profits and stoploss. This should have minnimal effects on the backtest results compared to live trading. This may or may not be updated in the future

Additional moving averages, volatility types, qualifiers, and other advanced features will be added in future releases.
Release Notes:
Removed 1-bar signal delay. You should see a signal speed increase.
Release Notes:
Added Donchian.

Public Telegram Group, t.me/algxtrading_public

VIP Membership Info: www.patreon.com/algxtrading/membership
Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact loxx for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases you can find a good open-source alternative for free in our Community Scripts.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Author's instructions

For instructions on how to access, send me a private message here on TradingView or message me using the contact information listed in my TradingView profile.

Want to use this script on a chart?

Warning: please read before requesting access.