Risk to Reward - FIXED SL BacktesterDon't know how to code? No problem! TradingView is an excellent platform for you. ✅ ✅
If you have an indicator that you want to backtest using a risk-to-reward ratio or fixed take profit/stop loss levels, then the Risk to Reward - FIXED SL Backtester script is the perfect solution for you.
introducing Risk to Reward - FIXED SL Backtester Script which will allow you to test any indicator / Signal with RR or Fixed SL system
How does it work ?!
Once you connect the script to your indicator, it will analyze your entry points and perform calculations based on them. It will then open trades for you according to the specified inputs in the script settings.
HOW TO CONNECT IT to your indicator?
simply open your indicator code and add the below line of code to it
plot(Signal ? 100 : 0,"Signal",display = display.data_window)
Replace Signal with the long condition from your own indicator. You can also modify the value 100 to any number you prefer. After that, open the settings.
Once the script is connected to your indicator, you can choose from two options:
Risk To Reward Ratio System
Fixed TP/ SL System
🔸if you select the Risk to Reward System ⤵️
The Risk-to-Reward System requires the calculation of a stop loss. That's why I have included three different types of stop-loss calculations for you to choose from:
ATR Based SL
Pivot Low SL
VWAP Based SL
Your stop loss and take profit levels will be automatically calculated based on the selected stop loss method and your risk-to-reward ratio.
You can also adjust their values to match your desired risk level. The trades will be displayed on the chart.
with the ability to change their values to match your risk.
once this is done, trades will be displayed on the chart
🔸if you select the Fixed system ⤵️
You have 2 inputs, which are FIXED TP & Fixed SL
input the values you want, and trades will be on your chart...
I have also added a Breakeven feature for you.
with this Breakeven feature the trade will not just move SL to Entry ?! NO NO, it will place it above entry by a % you input yourself, so you always win! 🚀
Here is an example
Enjoy, and have fun, if you have any questions do not hesitate to ask
Trend Analysis
Buy&Sell Bullish Engulfing - The Quant Science🇺🇸
GENERAL OVERVIEW
Buy&Sell Bullish Engulfing - The Quant Science It is a Buy&Sell strategy based on the 'Bullish Engulfing' candlestick pattern. The main goal of the strategy is to achieve a consistent and sustainable return over time, with a manageable level of risk.
Bullish Engulfing
The template was developed at the top of the Indicator provided by TradingView called 'Engulfing - Bullish'.
ENTRY AND EXIT CRITERIA
Entry: A single long order is opened when the candlestick pattern is formed, and the percentage size of the order (%) is fixed by the trader through the user interface.
Exit: The long trade is closed on a percentage equity take profit-stop loss.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
🇮🇹
PANORAMICA GENERALE
Buy&Sell Bullish Engulfing - The Quant Science è una strategia Buy&Sell basata sul candlestick pattern 'Bullish Engulfing'. L'obiettivo principale della strategia è ottenere un ritorno costante e sostenibile nel tempo, con un livello gestibile di rischio.
Bullish Engulfing
Il template è stato sviluppato al top dell' Indicatore fornito da Trading View chiamato 'Engulfing - Bullish'.
CRITERI DI ENTRATA E USCITA
Entrata: viene aperto un singolo ordine long quando si forma il candlestick pattern, la size percentuale dell'ordine (%) viene selezionato tramite l'interfaccia utente dal trader.
Uscita: la chiusura della posizione avviene unicamente tramite un take profit-stop loss percentuale calcolato sul capitale.
Powertrend - Volume Range Filter Strategy [wbburgin]The Powertrend is a range filter that is based off of volume, instead of price. This helps the range filter capture trends more accurately than a price-based range filter, because the range filter will update itself from changes in volume instead of changes in price. In certain scenarios this means that the Powertrend will be more profitable than a normal range filter.
Essentials of the Strategy
This is a breakout strategy which works best on trending assets with high volume and liquidity. It should be used on middle to higher timeframes and can be used on all assets that have volume provided by the data source (stocks, crypto, forex). It is long-only as of now. It can work on lower timeframes if you optimize the strategy filters to make less trades or if your exchange/broker is low/no fees, provided that your exchange/broker has high liquidity and volume.
The strategy enters a long position if the range filter is trending upwards and the price crosses over the upper range band, which signifies a price-volume breakout. The strategy closes the long position if the range filter is trending downwards and the price crosses under the lower range band, which signifies a breakdown. Both these conditions can be altered by the three filter options in the settings. The default trend filter is not alterable because it helps prevent false entries and exits that are against the trend.
Settings
The Length setting is the lookback period for the range smoothing.
The ADX Filter setting enables you to turn on an ADX filter, which will halt entries and exits unless the ADX of your customizable length is above a ADX VWMA of that length.
The Range Supertrend setting creates a supertrend from the top and bottom ranges, which can be used to filter entries and exits. The length is customizable. The filter can show you whether the range is making higher highs and lower lows. Below is an example of the Range Supertrend being used as a filter and plotted on-chart:
The VWMA setting halts entries if they are below a customizable length VWMA.
Both the Range Supertrend and the VWMA can also be plotted separately without actually filtering the strategy, so that you can use them independently if you wish. You can turn off the bar color, the highlighting, and the labels if you wish in the settings. A note about the bar color: if the color changes but the strategy does not signal an exit or entry this means that the crossover was against the trend. In these circumstances it may be indicative of a pullback to enter or exit or to add onto your position.
About the Strategy Results Below
A range filter is normally composed of two components - the range filter itself and a smoothing function. In the development of this script I tested both normal and volume-based varieties of the range filter and the smoothing function:
Tests Performed
Volume-based Range x VWMA smoothing
Price-based Range x VWMA smoothing
Price-based Range x EMA smoothing
Volume-based Range x EMA smoothing (final result)
The highest-performing was a volume-based range filter and a normal EMA-based smoothing function, but that does not mean that this strategy will be profitable - exits are based off of signal reversion so I strongly encourage you to develop your own take profits/stop losses for the strategy if you think it may be a good fit for you. The results below are with a commission value of 0.05% (because I built the strategy first for equities), slippage of 3, so if your exchange/broker has a higher fee schedule, I recommend adding filters and/or moving to higher timeframes for the strategy. Additionally, I used 10% of equity in each trade, while using the Range Supertrend filter (the previous upload was unrealistic because it used 100% of equity - missed a 0, apologies, and added in slippage).
Ta StrategyHello guys
This script follows traditional technical indicators
MACD, ADX, RSI and pivot points
If the price is above the resistance and the MACD has crossover ,and the RSI 14 is above 50
ADX is higher than 20, and DI+ is higher than DI-. This is a buy signal and vice versa for a sell signal
The script moves the stop loss to the entry price after the first target is reached
You can specify the quantity you want to sell when the price reaches the first target
There are also options like if you want the script to entry long or short, or both
you can reverse the strategy if it does not work well
If you want to inquire about any details, please let me know in the comments
Volume-Weighted Supertrend Strategy [wbburgin]This is a script that can be used as a strategy or a standalone indicator.
The Volume-Weighted Supertrend is a supertrend based on a rolling VWAP, instead of a normal price source. The strategy has two components - a supertrend based off of this VWAP (shown on the chart) and a supertrend from volume itself (not plotted on the chart directly). The supertrend from volume is an example of my "Supertrend Any Source" indicator, where a custom ATR is created from non-OHLC data; this is available as both a separate public script and also in my "wbburgin_utils" library for you to use in your own script creation.
The supertrend from volume acts as a confirmation filter for the VWAP-supertrend shown on-chart. If the volume supertrend is trending up and the VWAP-based supertrend is also trending up, a buy signal is generated. Likewise, if the volume supertrend is trending down and the VWAP-supertrend is trending down, a sell signal is generated. The colors are based off of whether both supertrends are trending up or down: green for both up, blue for only price up, orange for only price down, and red for both down.
The settings enable you to change the volume length and the ATR length separately, as well as the multiplier and the source for the price supertrend. If you load the indicator for the first time and see no entries and exits, this is because "Show Strategy Entries and Exits" is disabled in the settings. This is if you plan on using the strategy as an indicator and don't want to be bothered by the entry and exit symbols on the chart. Additionally, for those who like clean charts (like me), you can turn all the labels off in the settings, as well as the highlighting.
My default strategy settings for the strategy results shown below are as follows: 5% equity per trade, 5 degrees of pyramiding, commissions of 0.08% per trade. This strategy doesn't come with stops yet, so please be aware of that before using it to trade - I highly suggest you create your own stops based off of your R/R ratio and personal risk tolerance. Additionally, it works best on trending assets (b/c of the supertrends) with high volume. This might mean it does not work as well on lower timeframes.
HK Percentile Interpolation One
This script is designed to execute a trading strategy based on Heikin Ashi candlesticks, moving averages, and percentile levels.
Please note that you should keep your original chart in normal candlestick mode and not switch it to Heikin Ashi mode. The script itself calculates Heikin Ashi values from regular candlesticks. If your chart is already in Heikin Ashi mode, the script would be calculating Heikin Ashi values based on Heikin Ashi values, which would produce incorrect results.
The strategy begins trading from a start date that you can specify by modifying the `startDate` parameter. The format of the date is "YYYY MM DD". So, for example, to start the strategy from January 1, 2022, you would set `startDate = timestamp("2022 01 01")`.
The script uses Heikin Ashi candlesticks, which are plotted in the chart. This approach can be useful for spotting trends and reversals more easily than with regular candlestick charts. This is particularly useful when backtesting in TradingView's "Rewind" mode, as you can see how the Heikin Ashi candles behaved at each step of the strategy.
Buy and sell signals are generated based on two factors:
1. The crossing over or under of the Heikin Ashi close price and the 75th percentile price level.
2. The Heikin Ashi close price being above certain moving averages.
You have the flexibility to adjust several parameters in the script, including:
1. The stop loss and trailing stop percentages (`stopLossPercentage` and `trailStopPercentage`). These parameters allow the strategy to exit trades if the price moves against you by a certain percentage.
2. The lookback period (`lookback`) used to calculate percentile levels. This determines the range of past bars used in the percentile calculation.
3. The lengths of the two moving averages (`yellowLine_length` and `purplLine_length`). These determine how sensitive the moving averages are to recent price changes.
4. The minimum holding period (`holdPeriod`). This sets the minimum number of bars that a trade must be kept open before it can be closed.
Please adjust these parameters according to your trading preferences and risk tolerance. Happy trading!
Master Supertrend Strategy [Trendoscope]Here is the strategy version of the indicator - Master Supertrend
Options and variations are same throughout.
🎲 Variations
Following variations are provided in the form of settings.
🎯 Range Type
Instead of ATR, different types of ranges can be used for stop calculation. Here is the complete list used in the script.
Plus/Minus Range* - Calculates plus range and minus range for each candle and uses them for different sides of stop calculation
Ladder ATR - Based on the existing concept of Ladder ATR defined in Supertrend-Ladder-ATR
True Range - True range derived from standard function ta.tr
Standard Deviation - Standard deviation of close prices
🎯 Applied Calculation
In standard ATR, rma of TR is used for calculations. But, the application calculation provides option to users to use different mechanisms. It can be a type of moving average or few other types of calculations.
Available values are
sma
ema
hma
rma
wma
high
median
🎯 Other options
Few other options provided are
Use Close Price - If selected stops are calculated based on the close price instead of high/low prices
Wait for Close If selected, change of supertrend direction is calculated based on close price instead of high/low prices
Diminishing Stop Distance - When selected, stop distance for the trend direction can only reduce and cannot increase. This option is useful for keeping the tight stops on strong trends.
🎯 Plus Minus Range*
One of the range type used is Plus/Minus Range. What it means and how are these ranges calculated? Let's have a look.
Plus Range is an upward movement of a candle from its last price or open price whichever is lower.
Minus Range is a downward movement of a candle from its last price or open price whichever is higher.
This divides True Range into two separate range for positive and negative side.
Note : Effectiveness on daily charts are quire visible. However, if you want to use it for lower timeframes, please play around with settings before settling on suitable configuration.
Hobbiecode - SP500 IBS + HigherThis is a simple strategy that is working well on SPY but also well performing on Mini Futures SP500. The strategy is composed by the followin rules:
1. Today is Monday.
2. The close must be lower than the close on Friday.
3. The IBS must be below 0.5.
4. If 1-3 are true, then enter at the close.
5. Sell 5 trading days later (at the close).
If you backtest it on Mini Futures SP500 you will be able to track data from 1993. It is important to select D1 as timeframe.
Please share any comment or idea below.
Have a good trading,
Ramón.
Initial Balance Panel Strategy for BitcoinInitial Balance Strategy
Initial Balance Strategy uses a source code of "Initial Balance Monitoring Panel" that build from "Initial Balance Markets Time Zones - Overall Highest and Lowest".
Initial Balance is based on the highest and lowest price action within the first 60 minutes of trading. Reading online this can depict which way the market can trend for the session. More information about Initial Balance Panel you can read at the end of the article.
Strategy idea
The main idea is to catch the trend move when most of the 16 Crypto pairs break the Low or High levels together. I found good results when 15 of 16 pairs is break that levels and after we manage the trade within some trail stop indicator, I choose Volatility Stop for this strategy.
Additional Strategy idea
The second one idea that was not made is to catch the pullback after fully green/red zones in Initial Balance Panel become white. That mean the main trend can be finished and we can try to catch good pullback in opposite direction.
Binance Crypto pairs
The strategy use the 16 default Crypto currencies pairs from the Binance. As additional variations of the strategy can be changing the currencies pairs and their number.
List of default pairs:
BINANCE:BTCUSDT, BINANCE:ETHUSDT, BINANCE:EOSUSDT, BINANCE:LTCUSDT, BINANCE:XRPUSDT, BINANCE:DASHUSDT, BINANCE:IOTAUSDT, BINANCE:NEOUSDT, BINANCE:QTUMUSDT, BINANCE:XMRUSDT, BINANCE:ZECUSDT, BINANCE:ETCUSDT, BINANCE:ADAUSDT, BINANCE:XTZUSDT, BINANCE:LINKUSDT, BINANCE:DOTUSDT
Summary
The strategy works very well for a buy trades with settings 15 crypto pairs of 16 that follow the trend with breaking the long initial balance level.
Initial Balance Monitoring Panel
Allows you to have an instant view of 16 Crypto pairs within a monitoring panel, monitoring Initial Balance (Asia, London, New York Stock Exchanges).
The code can easily be changed to suit the crypto pairs you are trading.
The setup of my chart would also include this indicator and the "Initial Balance Markets Time Zones - Overall Highest and Lowest" (with all IBs enabled) as shown above.
Initial Balance is based on the highest and lowest price action within the first 60 minutes of trading. Reading online this can depict which way the market can trend for the session.
The indicator has been coded for Crypto (so other symbols may not work as expected).
Though Initial Balance is based off the first 60 minutes of the trading markets opening, but Crypto is 24/7, this indicator looks at how Asia, London and New York Stock Exchanges opening trading can affect Crypto price action.
Source: Initial Balance Monitoring Panel
Pure Morning 2.0 - Candlestick Pattern Doji StrategyThe new "Pure Morning 2.0 - Candlestick Pattern Doji Strategy" is a trend-following, intraday cryptocurrency trading system authored by devil_machine.
The system identifies Doji and Morning Doji Star candlestick formations above the EMA60 as entry points for long trades.
For best results we recommend to use on 15-minute, 30-minute, or 1-hour timeframes, and are ideal for high-volatility markets.
The strategy also utilizes a profit target or trailing stop for exits, with stop loss set at the lowest low of the last 100 candles. The strategy's configuration details, such as Doji tolerance, and exit configurations are adjustable.
In this new version 2.0, we've incorporated a new selectable filter. Since the stop loss is set at the lowest low, this filter ensures that this value isn't too far from the entry price, thereby optimizing the Risk-Reward ratio.
In the specific case of ALPINE, a 9% Take-Profit and and Stop-Loss at Lowest Low of the last 100 candles were set, with an activated trailing-stop percentage, Max Loss Filter is not active.
Name : Pure Morning 2.0 - Candlestick Pattern Doji Strategy
Author : @devil_machine
Category : Trend Follower based on candlestick patterns.
Operating mode : Spot or Futures (only long).
Trades duration : Intraday
Timeframe : 15m, 30m, 1H
Market : Crypto
Suggested usage : Short-term trading, when the market is in trend and it is showing high volatility .
Entry : When a Doji or Morning Doji Star formation occurs above the EMA60.
Exit : Profit target or Trailing stop, Stop loss on the lowest low of the last 100 candles.
Configuration :
- Doji Settings (tolerances) for Entry Condition
- Max Loss Filter (Lowest Low filter)
- Exit Long configuration
- Trailing stop
Backtesting :
⁃ Exchange: BINANCE
⁃ Pair: ALPINEUSDT
⁃ Timeframe: 30m
⁃ Fee: 0.075%
⁃ Slippage: 1
- Initial Capital: 10000 USDT
- Position sizing: 10% of Equity
- Start: 2022-02-28 (Out Of Sample from 2022-12-23)
- Bar magnifier: on
Disclaimer : Risk Management is crucial, so adjust stop loss to your comfort level. A tight stop loss can help minimise potential losses. Use at your own risk.
How you or we can improve? Source code is open so share your ideas!
Leave a comment and smash the boost button!
Thanks for your attention, happy to support the TradingView community.
Price Action - Support & Resistance + MACD LONG StrategyUsing "Price Action - Support & Resistance by DGT" and the MACD (Moving Average Convergence Divergence) indicator in TradingView can help develop a trade strategy. Here's a step-by-step approach you can follow:
1. Identifying Support and Resistance Levels: Apply the "Price Action - Support & Resistance by DGT" indicator to your chart. This indicator helps you identify key support and resistance levels based on price action. These levels act as potential areas where the price may reverse or consolidate.
2. Confirming Support and Resistance Levels: Once the indicator has plotted support and resistance levels on your chart, analyze the historical price action around these levels. Look for multiple touches or bounces from the same level, which adds strength to the support or resistance zone.
3. Analyzing the MACD Indicator: Add the MACD indicator to your chart. The MACD consists of two lines: the MACD line and the signal line, along with a histogram representing the difference between the two lines. The MACD helps identify momentum and potential trend reversals.
When the MACD line crosses above the signal line and the histogram turns positive, it suggests bullish momentum.
4. Identifying Trade Opportunities:
Bullish Trade: Look for a bullish setup when the price approaches a strong support level identified by the "Price Action - Support & Resistance by DGT" indicator. Wait for the MACD lines to cross above the signal line and the histogram to turn positive, indicating bullish momentum. Enter a long position with a stop loss below the
support level.
Managing the Trade: Once you enter a trade, consider setting a target based on the distance between your entry point and the nearest significant support or resistance level. You can also use trailing stop losses or other risk management techniques to protect your profits and limit potential losses.
Remember that no trading strategy is guaranteed to be successful, and it's important to practice proper risk management and conduct thorough analysis before making any trading decisions. Additionally, it's recommended to backtest and demo trade this strategy before using it with real money.
Advanced Trend Detection StrategyThe Advanced Trend Detection Strategy is a sophisticated trading algorithm based on the indicator "Percent Levels From Previous Close".
This strategy is based on calculating the Pearson's correlation coefficient of logarithmic-scale linear regression channels across a range of lengths from 50 to 1000. It then selects the highest value to determine the length for the channel used in the strategy, as well as for the computation of the Simple Moving Average (SMA) that is incorporated into the strategy.
In this methodology, a script is applied to an equity in which multiple length inputs are taken into consideration. For each of these lengths, the slope, average, and intercept are calculated using logarithmic values. Deviation, the Pearson's correlation coefficient, and upper and lower deviations are also computed for each length.
The strategy then selects the length with the highest Pearson's correlation coefficient. This selected length is used in the channel of the strategy and also for the calculation of the SMA. The chosen length is ultimately the one that best fits the logarithmic regression line, as indicated by the highest Pearson's correlation coefficient.
In short, this strategy leverages the power of Pearson's correlation coefficient in a logarithmic scale linear regression framework to identify optimal trend channels across a broad range of lengths, assisting traders in making more informed decisions.
MACD TrueLevel StrategyThis strategy uses the MACD indicator to determine buy and sell signals. In addition, the strategy employs the use of "TrueLevel Bands," which are essentially envelope bands that are calculated based on the linear regression and standard deviation of the price data over various lengths.
The TrueLevel Bands are calculated for 14 different lengths and are plotted on the chart as lines. The bands are filled with a specified color to make them more visible. The highest upper band and lowest lower band values are stored in variables for easy access.
The user can input the lengths for the TrueLevel Bands and adjust the multiplier for the standard deviation. They can also select the bands they want to use for entry and exit, and enable long and short positions.
The entry conditions for a long position are either a crossover of the MACD line over the signal line or a crossover of the price over the selected entry lower band. The entry conditions for a short position are either a crossunder of the MACD line under the signal line or a crossunder of the price under the selected exit upper band.
The exit conditions for both long and short positions are not specified in the code and are left to the user to define.
Overall, the strategy aims to capture trends by entering long or short positions based on the MACD and TrueLevel Bands, and exiting those positions when the trend reverses.
RSI TrueLevel StrategyThis strategy is a momentum-based strategy that uses the Relative Strength Index (RSI) indicator and a TrueLevel envelope to generate trade signals.
The strategy uses user-defined input parameters to calculate TrueLevel envelopes for 14 different lengths. The TrueLevel envelope is a volatility-based technical indicator that consists of upper and lower bands. The upper band is calculated by adding a multiple of the standard deviation to a linear regression line of the price data, while the lower band is calculated by subtracting a multiple of the standard deviation from the same regression line.
The strategy generates long signals when the RSI crosses above the oversold level or when the price crosses above the selected lower band of the TrueLevel envelope. It generates short signals when the RSI crosses below the overbought level or when the price crosses below the selected upper band of the TrueLevel envelope.
The strategy allows for long and short trades and sets the trade size as a percentage of the account equity. The colors of the bands and fills are also customizable through user-defined input parameters.
In this strategy, the 12th TrueLevel band was chosen due to its ability to capture significant price movements while still providing a reasonable level of noise reduction. The strategy utilizes a total of 14 TrueLevel bands, each with varying lengths. The 12th band, with a length of 2646, strikes a balance between sensitivity to market changes and reducing false signals, making it a suitable choice for this strategy.
RSI Parameters:
In this strategy, the RSI overbought and oversold levels are set at 65 and 40, respectively. These values were chosen to filter out more noise in the market and focus on stronger trends. Traditional RSI overbought and oversold levels are set at 70 and 30, respectively. By raising the oversold level and lowering the overbought level, the strategy aims to identify more significant trend reversals and potential trade opportunities.
Of course, the parameters can be adjusted to suit individual preferences.
SuperTrend Long Strategy +TrendFilterThis strategy aims to identify long (buy) opportunities in the market using the SuperTrend indicator. It utilizes the Average True Range (ATR) and a multiplier to determine the dynamic support levels for entering long positions. This presentation will provide an overview of the strategy's components, explain its usage, and highlight that it focuses on long trades.
Components of the Strategy:
1. ATR Period: This input determines the period used for calculating the Average True Range (ATR). A higher value may result in smoother trend lines but may lag behind recent price changes.
2. Source (src): This input determines the price source used for calculations, with "hl2" (the average of high and low prices) set as the default.
3. ATR Multiplier: This input specifies the multiplier applied to the ATR value to determine the distance of the support levels from the source.
4. Change ATR Calculation Method: This input allows toggling between two methods of ATR calculation: the default method using atr() or a simple moving average (SMA) of ATR values (sma(tr, Periods)).
5. Show Buy/Sell Signals: This input enables or disables the display of buy and sell signals on the chart.
6. Highlighter On/Off: This input controls whether highlighting of up and down trends is displayed on the chart.
7. Bar Coloring On/Off: This input determines whether the bars on the chart are colored based on the trend direction.
8. The "SuperTrend Long STRATEGY" has been enhanced by incorporating a trend filter. A moving average is used as the filter to confirm the prevailing trend before executing trades. This addition effectively reduces false signals and improves the strategy's reliability, all while maintaining its original name.
Strategy Logic:
1. The strategy calculates the upper (up) and lower (dn) trend lines based on the ATR value and the chosen multiplier.
2. The trend variable keeps track of the current trend, with 1 indicating an uptrend and -1 indicating a downtrend.
3. Buy and sell signals are generated based on the change in trend direction.
4. The strategy includes an optional highlighting feature that colors the chart background based on the current trend.
5. Additionally, the bar coloring feature colors the bars based on the direction of the last trend change.
Usage:
1. ATR Period and ATR Multiplier can be adjusted based on the desired sensitivity and risk tolerance.
2. Buy and sell signals can be displayed using the Show Buy/Sell Signals input, providing clear indications of entry and exit points.
3. The Highlighter On/Off input allows users to visually identify the prevailing trend by coloring the chart background.
4. The Bar Coloring On/Off input offers a quick visual reference for the most recent trend change.
Long Strategy:
The SuperTrend Long Strategy is specifically designed to identify long (buy) opportunities. It generates buy signals when the current trend changes from a downtrend to an uptrend, indicating a potential entry point for long positions. The strategy aims to capture upward price movements and maximize profits during bullish market conditions.
The SuperTrend Long Strategy provides traders with a systematic approach to identifying long trade opportunities. By leveraging the SuperTrend indicator and dynamic support levels, this strategy aims to generate buy signals in uptrending markets. Traders can customize the inputs and utilize the visual features to adapt the strategy to their specific trading preferences.
The modification adds a trend filter to the "SuperTrend Long STRATEGY" to improve its effectiveness. The trend filter uses a moving average to confirm the prevailing trend before taking trades. This addition helps filter out false signals and enhances the strategy's reliability without changing its name.
Slight Swing Momentum Strategy.Introduction:
The Swing Momentum Strategy is a quantitative trading strategy designed to capture mid-term opportunities in the financial markets by combining swing trading principles with momentum indicators. It utilizes a combination of technical indicators, including moving averages, crossover signals, and volume analysis, to generate buy and sell signals. The strategy aims to identify market trends and capitalize on price momentum for profit generation.
Highlights:
The strategy offers several key highlights that make it unique and potentially attractive to traders:
Swing Trading with Momentum: The strategy combines the principles of swing trading, which aim to capture short-to-medium-term price swings, with momentum indicators that help identify strong price trends and potential breakout opportunities.
Technical Indicator Optimization: The strategy utilizes a selection of optimized technical indicators, including moving averages and crossover signals, to filter out the noise and focus on high-probability trading setups. This optimization enhances the strategy's ability to identify favourable entry and exit points.
Risk Management: The strategy incorporates risk management techniques, such as position sizing based on equity and dynamic stop loss levels, to manage risk exposure and protect capital. This helps to minimize drawdowns and preserve profits.
Buy Condition:
The buy condition in the strategy is determined by a combination of factors, including A1, A2, A3, XG, and weeklySlope. Let's break it down:
A1 Condition: The A1 condition checks for specific price relationships. It verifies that the ratio of the highest price to the closing price is less than 1.03, the ratio of the opening price to the lowest price is less than 1.03, and the ratio of the highest price to the previous day's closing price is greater than 1.06. This condition looks for a specific pattern indicating potential bullish momentum.
A2 Condition: The A2 condition checks for price relationships related to the closing price. It verifies that the ratio of the closing price to the opening price is greater than 1.05 or that the ratio of the closing price to the previous day's closing price is greater than 1.05. This condition looks for signs of upward price movement and momentum.
A3 Condition: The A3 condition focuses on volume. It checks if the current volume crosses above the highest volume over the last 60 periods. This condition aims to identify increased buying interest and potentially confirms the strength of the potential upward price movement.
XG Condition: The XG condition combines the A1 and A2 conditions and checks if they are true for both the current and previous bars. It also verifies that the ratio of the closing price to the 5-period EMA crosses above the 9-period SMA of the same ratio. This condition helps identify potential buy signals when multiple factors align, indicating a strong bullish momentum and potential entry point.
Weekly Trend Factor: The weekly slope condition calculates the slope of the 50-period SMA over a weekly timeframe. It checks if the slope is positive, indicating an overall upward trend on a weekly basis. This condition provides additional confirmation that the stock is in an upward trend.
When all of these conditions align, the buy condition is triggered, indicating a favourable time to enter a long position.
Sell Condition:
The sell condition is relatively straightforward in the strategy:
Sell Signal: The sell condition simply checks if the closing price crosses below the 10-period EMA. When this condition is met, it indicates a potential reversal or weakening of the upward price momentum, and a sell signal is generated.
Backtest Outcome:
The strategy was backtested over the period from January 22nd, 1999 to May 3rd, 2023, using daily candlestick charts for the NASDAQ: NVDA. The strategy used an initial capital of 1,000,000 USD, The order quantity is defined as 10% of the equity. The strategy allows for pyramiding with 1 order, and the transaction fee is set at 0.03% per trade. Here are the key outcomes of the backtest:
Net Profit: 539,595.84 USD, representing a return of 53.96%.
Percent Profitable: 48.82%
Total Closed Trades: 127
Profit Factor: 2.331
Max Drawdown: 68,422.70 USD
Average Trade: 4,248.79 USD
Average Number of Bars in Trades: 11, indicating the average duration of the trades.
Conclusion:
In conclusion, the Swing Momentum Strategy is a quantitative trading approach that combines swing trading principles with momentum indicators to identify and capture mid term trading opportunities. The strategy has demonstrated promising results during backtesting, including a significant net profit and a favourable profit factor.
Adaptive Price Channel StrategyThis strategy is an adaptive price channel strategy based on the Average True Range (ATR) indicator and the Average Directional Index (ADX). It aims to identify sideways markets and trends in the price movements and make trades accordingly.
The strategy uses a length parameter for the ATR and ADX indicators, which determines the length of the calculation for these indicators. The strategy also uses an ATR multiplier, which is multiplied by the ATR to determine the upper and lower bounds of the price channel.
The first step of the strategy is to calculate the highest high (HH) and lowest low (LL) over the specified length. The ATR is also calculated over the same length. Then the strategy calculates the positive directional indicator (+DI) and negative directional indicator (-DI) based on the up and down moves in the price, and uses these to calculate the ADX.
If the ADX is less than 25, the market is considered to be in a sideways phase. In this case, if the price closes above the upper bound of the price channel (HH - ATR multiplier * ATR), the strategy enters a long position, and if the price closes below the lower bound of the price channel (LL + ATR multiplier * ATR), the strategy enters a short position.
If the ADX is greater than or equal to 25 and the +DI is greater than the -DI, the market is considered to be in a bullish phase. In this case, if the price closes above the upper bound of the price channel, the strategy enters a long position. If the ADX is greater than or equal to 25 and the +DI is less than the -DI, the market is considered to be in a bearish phase. In this case, if the price closes below the lower bound of the price channel, the strategy enters a short position.
The strategy exits a position after a certain number of bars have passed since the entry, as specified by the exit_length input.
In summary, this strategy attempts to trade in accordance with the prevailing market conditions by identifying sideways markets and trends and making trades based on price movements within a dynamically-adjusted price channel.
This strategy takes a read on the market and either takes a channel strategy or trades volatility based on current trend. Works well on 2, 3 ,4, 12 hour for BTC. It’s my first attempt and creating a strategy. I am very interested in constructive criticism. I will look into better risk management, maybe a trailing stop loss. Other suggestions welcome. This is my first attempt at a strategy.
Here are the settings I used.
Inputs
Length 20
Exit 10
ATR 3.2
Dates I picked when I got into Crypto
Properties
Capital 1000
Order size 2 Contracts
Pyramiding 1
Commission .05
SPY 4 Hour Swing TraderThe purpose of this script is to spot 4 hour pivots that indicate ~30 trading day swings. As VIX starts to drop options trading will get more boring and as we get back on the bull and can benefit from swing trading strategy. Swing trading doesn't make a whole lot of sense when VIX is above 28. Seems to get best results on 4 hour chart for this one. This indicator spots a go long opportunity when the 5 ema crosses the 13 ema on the 4 hour along with the RSI > 50 and the ADX > 20 and Stoichastic values (smoothed line < 80 or line < 90) and close > last candle close and the True Range < 6. It also spots uses a couple different means to determine when to exit the trade. Sell condition is primarily when the 13 ema crosses the 5 ema and the MACD line crosses below the signal line and the smoothed Stoichastic appears oversold (greater than 60) and slop of RSI < -.2. Stop Losses and Take Profits are configurable in Inputs along with ability to include short trades plus other MACD and Stoichastic settings. If a stop loss is encountered the trade will close. Also once twice the expected move is encountered partial profits will taken and stop losses and take profits will be re-established based on most recent close. Also a VIX above 28 will trigger any open positions to close. If trying to use this for something other than SPXL it is best to update stop losses and take profit percentages and check backtest results to ensure proper levels have been selected and the script gives satisfactory results.
SPY 1 Hour Swing TraderThe purpose of this script is to spot 1 hour pivots that indicate ~5 to 6 trading day swings. Results indicate that swings are held approximately 5 to 6 trading days on average, over the last 6 years. This indicator spots a go long opportunity when the 5 ema crosses the 13 ema on the 1 hour along with the RSI > 50. It also spots uses a couple different means to determine when to exit the trade. Sell condition is primarily when the 13 ema crosses the 5 ema and the MACD line crosses below the signal line and the smoothed Stoichastic appears oversold (greater than 60). Stop Losses and Take Profits are configurable in Inputs along with ability to include short trades plus other MACD and Stoichastic settings. If a stop loss is encountered the trade will close. Also once twice the expected move is encountered partial profits will taken and stop losses and take profits will be re-established based on most recent close. Once long trades are exited, short trades will be initiated if recent conditions appeared oversold and input option for short trading is enabled. If trying to use this for something other than SPXL it is best to update stop losses and take profit percentages and check backtest results to ensure proper levels have been selected and the script gives satisfactory results.
MACD/RSI - editedThis strategy checks MACDcrossover and RSI crossover. When MACD crosses up or down the signal line, it checks if RSI is crossing back OverSold or OverBought lines, respectively, over the past few candles. The period can be changed by the parameter "RSI lookback".
The strategy seems to work better for reversal—still a work in progress.
Optimized Zhaocaijinbao strategyIntroduction:
The Optimized Zhaocaijinbao strategy is a mid and long-term quantitative trading strategy that combines momentum and trend factors. It generates buy and sell signals by using a combination of exponential moving averages, moving averages, volume and slope indicators. It generates buy signals when the stock is above the 35-day moving average, the trading volume is higher than the 20-day moving average, and the stock is in an upward trend on a weekly timeframe."招财进宝" is a Chinese phrase that can be translated to "Attract Wealth and Bring in Treasure" in English. It is a common expression used to wish for good luck and prosperity in various contexts, such as in business or personal finances.
Highlights:
The strategy has several special optimizations that make it unique.
Firstly, the strategy is optimized for T+1 trading in the Chinese stock market and is only suitable for long positions. The optimizations are also applicable to international stock markets.
Secondly, the trend strategy is optimized to only show indicators on the right side and oscillations. This helps to prevent false signals in choppy markets.
Thirdly, the strategy uses a risk factor for dynamic position sizing to ensure position sizes are adjusted according to the current net asset value and risk preferences. This helps to lower drawdown risks.
The strategy has good resilience even without using stop loss modules in backtesting, making it suitable for trading hourly, 2-hourly, and daily K-line charts (depending on the stock being traded). We recommend experimenting with backtesting using SSE 1-hour or 2-hour or daily Kline charts.
Backtesting outcomes:
The strategy was backtested over the period from October 13th, 2005 to April 14th, 2023, using daily candlestick charts for the commodity code SSE:600763, with a currency of CNY and tick size of 0.01. The strategy used an initial capital of 1,000,000 CNY, with order sizes set to 10% equity and a pyramid of 1 order. The strategy also had a Max Position Size of 0.01 and a Risk Factor of 2.
Here is a summary of the performance of the trading strategy:
Total net profit: 288,577.32 CNY, representing a return of 128.86%
Total number of closed trades: 61
Winning trades: 37, representing a win rate of 60.66%
Profit factor: 2.415
Largest losing trade: 222,021.46 CNY, representing a loss of 14.08%
Average trade: 21,124.22 CNY, representing a return of 3.1%
Average holding period for all trades: 12 days
Conclusion:
In conclusion, the Optimized Zhaocaijinbao strategy is a mid and long-term quantitative trading strategy that combines momentum and trend factors. It is suitable for both Chinese stocks and global stocks. While the Optimized Zhaocaijinbao strategy has performed well in backtesting, it is important to note that past performance is not a guarantee of future results. Traders should conduct their own research and analysis and exercise caution when using any trading strategy.
Boftei's StrategyI wrote this strategy about a year ago, but decided to publish it just now. I have not been able to implement this strategy in the market. If you can, then I will be happy for you.
This strategy is based on my "Botvenko Script". (It finds the difference between the logarithms of closing prices from different days.) (Check this script in my profile)
Then the strategy makes trades when the "Botvenko Script" indicator crosses the levels set earlier and manually selected for each currency pair/shares: long/short opening/closing levels, long/short re-entry levels. (They are drawn with horizontal dotted lines.) The names of these lines are: buy/sell level, long/short retry - too low/high, long close up/down, dead - close the short. Manual selection of each of the parameters provides a qualitative entry of the strategy into the deal. However, without restraining mechanisms, the strategy enters into rather controversial deals. In order to avoid going long/short during bear/bull markets, which is unacceptable, I added a fan of EMA lines.
The fan consists of several EMA lines, which are set according to Fibonacci numbers (21, 55, 89, 144). If the lines in the fan are arranged in ascending order (ema_21>ema_55 and ema_55>ema_89 and ema_89>ema_144), then this indicates a bull market, during which I banned shorting. And vice versa: during the bear market (ema_21<ema_55 and ema_55<ema_89 and ema_89<ema_144) I banned long trading. If these two inequalities are not met, then this indicates that the market is flat, and during it it is allowed to enter any transactions, because a flat is a good moment to catch massive movements in the future by entering a transaction. (This is all visualized using semi-transparent thick lines of green, yellow and red colors.)
By default, all parameters are adjusted for the btc/usd (bitstamp) pair. Best of all, the strategy shows itself if 1 candle = 1 day.
At the time of writing, on the pair btcusd (bitstamp) (1d) with pyramiding = 1, the strategy shows a profit of 64728896%. If pyramiding is increased by 1, then the profit will be greater, but I still prefer pyramiding = 1.
There is a possibility that my strategy is doing complete nonsense. I don't vouch for her.
If you select parameters for other pairs of currencies/stocks, then you should not change anything in the fan of lines.
That's all, probably.
The Flash-Strategy (Momentum-RSI, EMA-crossover, ATR)The Flash-Strategy (Momentum-RSI, EMA-crossover, ATR)
Are you tired of manually analyzing charts and trying to find profitable trading opportunities? Look no further! Our algorithmic trading strategy, "Flash," is here to simplify your trading process and maximize your profits.
Flash is an advanced trading algorithm that combines three powerful indicators to generate highly selective and accurate trading signals. The Momentum-RSI, Super-Trend Analysis and EMA-Strategy indicators are used to identify the strength and direction of the underlying trend.
The Momentum-RSI signals the strength of the trend and only generates trading signals in confirmed upward or downward trends. The Super-Trend Analysis confirms the trend direction and generates signals when the price breaks through the super-trend line. The EMA-Strategy is used as a qualifier for the generation of trading signals, where buy signals are generated when the EMA crosses relevant trend lines.
Flash is highly selective, as it only generates trading signals when all three indicators align. This ensures that only the highest probability trades are taken, resulting in maximum profits.
Our trading strategy also comes with two profit management options. Option 1 uses the so-called supertrend-indicator which uses the dynamic ATR as a key input, while option 2 applies pre-defined, fixed SL and TP levels.
The settings for each indicator can be customized, allowing you to adjust the length, limit value, factor, and source value to suit your preferences. You can also set the time period in which you want to run the backtest and how many dollar trades you want to open in each position for fully automated trading.
Choose your preferred trade direction and stop-loss/take-profit settings, and let Flash do the rest. Say goodbye to manual chart analysis and hello to consistent profits with Flash. Try it now!
General Comments
This Flash Strategy has been developed in cooperation between Baby_whale_to_moon and JS-TechTrading. Cudos to Baby_whale_to_moon for doing a great job in transforming sophisticated trading ideas into pine scripts.
Detailed Description
The “Flash” script considers the following indicators for the generation of trading signals:
1. Momentum-RSI
2. ‘Super-Trend’-Analysis
3. EMA-Strategy
1. Momentum-RSI
• This indicator signals the strength of the underlying upward- or downward-trend.
• The signal range of this indicator is from 0 to 100. Values > 60 indicate a confirmed upward- or downward-trend.
• The strategy will only generate trading signals in case the stock (or any other financial security) is in a confirmed upward- (long entry signals) or downward-trend (short entry signals).
• This indicator provides information with regards to the strength of the underlying trend and it does not give any insight with regard to the direction of the trend. Therefore, this strategy also considers other indicators which provide technical confirmation with regards to the direction of the underlying trend.
Graph 1 shows this concept:
• The Momentum-RSI indicator gives lower readings during consolidation phases and no trading signals are generated during these periods.
Example (graph 2):
2. Super-Trend Analysis
• The red line in the graph below represents the so-called super-trend-line. Trading signals are only generated in case the price action breaks through this super-trend-line indicating a new confirmed upward-trend (or downward-trend, respectively).
• If that happens, the super trend-line changes its color from red to green, giving confirmation that the trend changed from bearish to bullish and long-entries can be considered.
• The vice-versa approach can be considered for short entries.
Graph 3 explains this concept:
3. Exponential Moving Average / EMA-Strategy
The functionality of this EMA-element of the strategy has been programmed as follows:
• The exponential moving average and two other trend lines are being used as qualifiers for the generation of trading-signals.
• Buy-signals for long-entries are only considered in case the EMA (yellow line in the graph below) crosses the red line.
• Sell-signals for short-entries are only considered in case the EMA (yellow line in the graph below) crosses the green line.
An example is shown in graph 4 below:
We use this indicator to determine the new trend direction that may occur by using the data of the price's past movement.
4. Bringing it all together
This section describes in detail, how this strategy combines the Momentum-RSI, the super-trend analysis and the EMA-strategy.
The strategy only generates trading-signals in case all of the following conditions and qualifiers are being met:
1. Momentum-RSI is higher than the set value of this strategy. The standard and recommended value is 60 (graph 5):
2. The super-trend analysis needs to indicate a confirmed upward-trend (for long-entry signals) or a confirmed downward-trend (for short-entry signals), respectively.
3. The EMA-strategy needs to indicate that the stock or financial security is in a confirmed upward-trend (long-entries) or downward-trend (short-entries), respectively.
The strategy will only generate trading signals if all three qualifiers are being met. This makes this strategy highly selective and is the key secret for its success.
Example for Long-Entry (graph 6):
When these conditions are met, our Long position is opened.
Example for Short-Entry (graph 7):
Trade Management Options (graph 8)
Option 1
In this dynamic version, the so-called supertrend-indicator is being used for the trade exit management. This supertrend-indicator is a sophisticated and optimized methodology which uses the dynamic ATR as one of its key input parameters.
The following settings of the supertrend-indicator can be changed and optimized (graph 9):
The dynamic SL/TP-lines of the supertrend-indicator are shown in the charts. The ATR-length and the supertrend-factor result in a multiplier value which can be used to fine-tune and optimize this strategy based on the financial security, timeframe and overall market environment.
Option 2 (graph 10):
Option 2 applies pre-defined, fixed SL and TP levels which will appear as straight horizontal lines in the chart.
Settings options (graph 11):
The following settings can be changed for the three elements of this strategy:
1. (Length Mom-Rsi): Length of our Mom-RSI indicator.
2. Mom-RSI Limit Val: the higher this number, the more momentum of the underlying trend is required before the strategy will start creating trading signals.
3. The length and factor values of the super trend indicator can be adjusted:ATR Length SuperTrend and Factor Super Trend
4. You can set the source value used by the ema trend indicator to determine the ema line: Source Ema Ind
5. You can set the EMA length and the percentage value to follow the price: Length Ema Ind and Percent Ema Ind
6. The backtesting period can be adjusted: Start and End time of BackTest
7. Dollar cost per position: this is relevant for 100% fully automated trading.
8. Trade direction can be adjusted: LONG, SHORT or BOTH
9. As we explained above, we can determine our stop-loss and take-profit levels dynamically or statically. (Version 1 or Version 2 )
Display options on the charts graph 12):
1. Show horizontal lines for the Stop-Loss and Take-profit levels on the charts.
2. Display relevant Trend Lines, including color setting options for the supertrend functionality. In the example below, green lines indicate a confirmed uptrend, red lines indicate a confirmed downtrend.
Other comments
• This indicator has been optimized to be applied for 1 hour-charts. However, the underlying principles of this strategy are supply and demand in the financial markets and the strategy can be applied to all timeframes. Daytraders can use the 1min- or 5min charts, swing-traders can use the daily charts.
• This strategy has been designed to identify the most promising, highest probability entries and trades for each stock or other financial security.
• The combination of the qualifiers results in a highly selective strategy which only considers the most promising swing-trading entries. As a result, you will normally only find a low number of trades for each stock or other financial security per year in case you apply this strategy for the daily charts. Shorter timeframes will result in a higher number of trades / year.
• Consequently, traders need to apply this strategy for a full watchlist rather than just one financial security.