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.
Indicators and strategies
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.
X48 - Strategy | ADAPTIVE CONSECUTIVE + TP/SL | V.1Thanks For Tradingview Built-in Script :: << Original From Consecutive Strategy Built-in Script >>
================== Read This First Before Use This Strategy ==============
Please be aware that this strategy is not a guarantee of success and may lead to losses.
Trading involves risk and you should always do your own research before making any decisions.
This Strategy Just an Idea For Help Your Decision For Open Position.
You Must Be Search and Make Your Self Understand What You Doing In This Strategy.
Example :: This Strategy and Indicator Find The Consecutive Bars And You, You Are Reading Must Be Decision Up to You !!
For Backtest Show It's That For a Newbie 100$ Portfolio and 16.333$ Per Order Size
>>>> Read Me First !! <<<<<
========== Detailed and meaningful description =========
How It's Work : This Strategy are Following Green or Red Candle :: example 3 Green Candle To OpenLong Position
Can Set TP/SL if you want :: Just Fine The Best Value of Asset as you want
Fast Trend = MA FAST LINE
SLOW Trend = MA SLOW LINE
MID-TERM TREND = MA MID-TERM
LONG-TERM TREND = MA LONG-TERM
=========== Condition And Statement ===========
Long Condition Statement :: Candles Consecutive Bars Up and close > golden_line and fast_line > golden_line
Short Condition Statement :: Candles Consecutive Bars Down and close < golden_line and fast_line < golden_line
AutoCloseLong Condition :: Candles ConsecutiveBarsDownStop and close > golden_line and close < death_line and close < death_line and close < death_line or fastUpdeath
AutoCloseShort Condition :: Candles ConsecutiveBarsUpStop and close < golden_line and close > death_line and close > death_line and close > death_line or fastUpdeath
====== For ADAPTIVE you can customize your ALL MA For Your Statement
/////////For Example Hook Alert Command ////////////
Just Easy Command >> :: {{strategy.order.alert_message}}
Or Other Json You Should Edit Command Like This Example
{"ex":"'bnfuture'","side": "AutoLong", "$16.333", "symbol": "{{ticker}}", "passphrase": "1234","leverage":"10", "tp" : "5", "sl" : "2", "tl" : "2", "callback" : "1"}
{"ex":"'bnfuture'","side": "AutoShort", "$16.333", "symbol": "{{ticker}}", "passphrase": "1234","leverage":"10", "tp" : "5", "sl" : "2", "tl" : "2", "callback" : "1"}
Gold Fair Value Gap Entry(FVG GOLD)This script calculates the fair value of gold, which is set as an input parameter. It then gets the current price of gold and calculates the gap between the price and the fair value. If the gap is positive, it enters a long trade, and if it's negative, it enters a short trade.
The script also uses proper risk management techniques by setting a stop loss and take profit for each trade. The plot() function is used to display the fair value and gap on the chart.
Please note that this is just an example script, and you should customize it based on your specific trading strategy and criteria. It's also important to backtest your strategy and refine it before using it with real money.
Bollinger Bands - Breakout StrategyThe Bollinger Bands - Breakout Strategy is a trend-following optimized for short-term trading in the crypto market. This strategy employs the Bollinger Bands, a widely recognized technical indicator, as its primary instrument for pinpointing potential trades. It is capable of executing both long and short positions, depending on whether the market is in a spot or futures, and is particularly effective in trending markets.
The strategy boasts a high degree of configurability, allowing users to set the Bollinger Bands period and deviation, trend filter, volatility filter, trade direction filter, rate of change filter, and date filter. Furthermore, it offers options for Take Profit, Stop Loss, and Trailing Stop for both long and short positions, ensuring a comprehensive risk management approach. The inclusion of a maximum intraday loss feature adds another layer of protection, making this strategy a valuable tool for traders seeking a professional and adaptable trading system.
Name : Bollinger Bands - Breakout Strategy
Category : Trend Follower based on Bollinger Bands
Operating mode : Long and Short on Futures or Long on Spot
Trade duration : Intraday
Timeframe : 2H, 3H, 4H, 5H
Market : Crypto
Suggested usage : Trending Markets
Entry : When the price crosses above or below the Bollinger Bands
Exit : Opposite Cross or Profit target, Trailing stop or Stop loss
Configuration :
- Bollinger Bands period and deviation
- Trend Filter
- Volatility Filter
- Trade direction filter
- Rate of Change filter
- Date Filter (for backtesting purposes)
- Take Profit, Stop Loss and Trailing Stop for long and short positions
- Risk Management: Max Intraday Loss
Backtesting :
⁃ Exchange: BINANCE
⁃ Pair: BTCUSDT.P
⁃ Timeframe: 4H
⁃ Fee: 0.025%
⁃ Slippage: 1
- Initial Capital: 10000 USDT
- Position sizing: 10% of Equity
- Start : 2019-09-19 (Out Of Sample from 2022-12-23)
- Bar magnifier: on
Credits :
- LucF of Pine Coders for f_security function to avoid repainting using security.
- QuantNomad for Monthly Table.
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.
FRAMA & CPMA Strategy [CSM]The script is an advanced technical analysis tool specifically designed for trading in financial markets, with a particular focus on the BankNifty market. It utilizes two powerful indicators: the Fractal Adaptive Moving Average (FRAMA) and the CPMA (Conceptive Price Moving Average), which is similar to the well-known Chande Momentum Oscillator (CMO) with Center of Gravity (COG) bands.
The FRAMA is a dynamic moving average that adapts to changing market conditions, providing traders with a more precise representation of price movements. The CMO is an oscillator that measures momentum in the market, helping traders identify potential entry and exit points. The COG bands are a technical indicator used to identify potential support and resistance levels in the market.
Custom functions are included in the script to calculate the FRAMA and CSM_CPMA indicators, with the FRAMA function calculating the value of the FRAMA indicator based on user-specified parameters of length and multiplier, while the CSM_CPMA function calculates the value of the CMO with COG bands indicator based on the user-specified parameters of length and various price types.
The script also includes trailing profit and stop loss functions, which while not meeting expectations, have been backtested with a success rate of over 90%, making the script a valuable tool for traders.
Overall, the script provides traders with a comprehensive technical analysis tool for analyzing cryptocurrency markets and making informed trading decisions. Traders can improve their success rate and overall profitability by using smaller targets with trailing profit and minimizing losses. Feedback is always welcome, and the script can be improved for future use. Special thanks go to Tradingview for providing inbuilt functions that are utilized in the script.
Stochastic RSI Strategy (with SMA and VWAP Filters)The strategy is designed to trade on the Stochastic RSI indicator crossover signals.
Below are all of the trading conditions:
-When the Stochastic RSI crosses above 30, a long position is entered.
-When the Stochastic RSI crosses below 70, a short position is entered.
-The strategy also includes two additional conditions for entry:
-Long entries must have a positive spread value between the 9 period simple moving average and the 21 period simple moving average.
-Short entries must have a negative spread value between the 9 period simple moving average and the 21 period simple moving average.
-Long entries must also be below the volume-weighted average price.
-Short entries must also be above the volume-weighted average price.
-The strategy includes stop loss and take profit orders for risk management:
-A stop loss of 20 ticks is placed for both long and short trades.
-A take profit of 25 ticks is placed for both long and short trades.
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
JS-TechTrading: Supertrend-Strategy_Basic versionAre you looking for a reliable and profitable algorithmic trading strategy for TradingView? If so, you might be interested in our Supertrend basic strategy, which is based on three powerful indicators: Supertrend (ATR), RSI and EMA.
Supertrend is a trend-following indicator that helps you identify the direction and strength of the market. It also gives you clear signals for entry and exit points based on price movements.
RSI is a momentum indicator that measures the speed and change of price movements. It helps you filter out false signals and avoid overbought or oversold conditions.
EMA is a moving average indicator that smooths out price fluctuations and shows you the long-term trend of the market. It helps you confirm the validity of your trades and avoid trading against the trend.
Our Supertrend basic strategy combines these three indicators to give you a simple yet effective way to trade any market. Here's how it works:
- For long trades, you enter when the price is above Supertrend and pulls back below it (the low of the candle crosses Supertrend) and then rebounds above it (the high of the next candle goes above the pullback candle). You exit when the price closes below Supertrend or when you reach your target profit or stop loss.
- For short trades, you enter when the price is below Supertrend and pulls back above it (the high of the candle crosses Supertrend) and then drops below it (the low of the next candle goes below the pullback candle). You exit when the price closes above Supertrend or when you reach your target profit or stop loss.
- You can also use RSI and EMA filters to improve your results. For long trades, you only enter if RSI is above 50 and price is above 200 EMA. For short trades, you only enter if RSI is below 50 and price is below 200 EMA.
- You can set your stop loss and target profit as a percentage of your entry price or based on other criteria. You can also adjust the parameters of each indicator according to your preferences and risk tolerance.
Our Supertrend basic strategy is easy to use and has been tested on various markets and time frames. It can help you capture consistent profits while minimizing your losses.
Price Action Trading StrategyIn this strategy, we define the high and low of the previous candle, and then check whether the current candle's high or low is higher or lower than the previous candle's high or low, respectively. If there's a new high, we enter a long position, and if there's a new low, we enter a short position. We also set exit conditions to close the position if the price drops below the previous low or rises above the previous high.
Please note that this is a simple example and should not be used as a standalone trading strategy. It is important to conduct thorough backtesting and consider other factors such as risk management before implementing any trading strategy.
FTR, WMA, OBV & RSI StrategyThis Pine Script code is a trading strategy that uses several indicators such as Fisher Transform (FTR), On-Balance Volume (OBV), Relative Strength Index (RSI), and a Weighted Moving Average (WMA). The strategy generates buy and sell signals based on the conditions of these indicators.
The Fisher Transform function is a technical indicator that uses past prices to determine whether the current market is bullish or bearish. The Fisher Transform function takes in four multipliers and a length parameter. The four multipliers are used to calculate four Fisher Transform values, and these values are used in combination to determine if the market is bullish or bearish.
The Weighted Moving Average (WMA) is a technical indicator that smooths out the price data by giving more weight to the most recent prices.
The Relative Strength Index (RSI) is a momentum indicator that measures the strength of a security's price action. The RSI ranges from 0 to 100 and is typically used to identify overbought or oversold conditions in the market.
The On-Balance Volume (OBV) is a technical indicator that uses volume to predict changes in the stock price. OBV values are calculated by adding volume on up days and subtracting volume on down days.
The strategy uses the Fisher Transform values to generate buy and sell signals when all four Fisher Transform values change color. It also uses the WMA to determine if the trend is bullish or bearish, the OBV to confirm the trend, and the RSI to filter out false signals.
The red and green triangular arrows attempt to indicate that the trend is bullish or bearish and should not be traded against in the opposite direction. This helps with my FOMO :)
All comments welcome!
The script should not be relied upon alone, there are no stop loss or take profit filters. The best results have been back-tested using Tradingview on the 45m - 3 hour timeframes.
Volatility Range Breakout Strategy [wbburgin]The "Volatility Range Breakout Strategy" uses deviations of high-low volatility to determine bullish and bearish breakouts.
HOW IT WORKS
The volatility function uses the high-low range of a lookback period, divided by the average of that range, to determine the likelihood that price will break in a specific direction.
High and low ranges are determined by the relative volatility compared to the current closing price. The high range, for example, is the (volatility * close) added to the close, the low range is this value subtracted by the close.
A volatility-weighted moving average is taken of these high and low ranges to form high and low bands.
Finally, breakouts are identified once the price closes above or below these bands. An upwards breakout (bullish) occurs when the price breaks above the upper band, while a downwards breakout (bearish) occurs when the price breaks below the lower band. Positions can be closed either by when the price falls out of its current band ("Range Crossover" in settings under 'Exit Type') or when the price falls below or above the volatility MA (default because this allows us to catch trends for longer).
INPUTS/SETTINGS
The AVERAGE LENGTH is the period for the volatility MA and the weighted volatility bands.
The VOLATILITY LENGTH is how far the lookback should be for highs/lows for the volatility calculation.
Enjoy! Let me know if you have any questions.
Yesterday’s High Breakout - Trend Following StrategyYesterday’s High Breakout it is a trading system based on the analysis of yesterday's highs, it works in trend-following mode therefore it opens a long position at the breakout of yesterday's highs even if they occur several times in one day.
There are several methods for exiting a trade, each with its own unique strategy. The first method involves setting Take-Profit and Stop-Loss percentages, while the second utilizes a trailing-stop with a specified offset value. The third method calls for a conditional exit when the candle closes below a reference EMA.
Additionally, operational filters can be applied based on the volatility of the currency pair, such as calculating the percentage change from the opening or incorporating a gap to the previous day's high levels. These filters help to anticipate or delay entry into the market, mitigating the risk of false breakouts.
In the specific case of NULS, a 9% Take-Profit and a 3% Stop-Loss were set, with an activated trailing-stop percentage. To postpone entry and avoid false breakouts, a 1% gap was added to the price of yesterday's highs.
Name : Yesterday's High Breakout - Trend Follower Strategy
Author : @tumiza999
Category : Trend Follower, Breakout of Yesterday's High.
Operating mode : Spot or Futures (only long).
Trade duration : Intraday.
Timeframe : 30M, 1H, 2H, 4H
Market : Crypto
Suggested usage : Short-term trading, when the market is in trend and it is showing high volatility.
Entry : When there is a breakout of Yesterday's High.
Exit : Profit target or Trailing stop, Stop loss or Crossunder EMA.
Configuration :
- Gap to anticipate or postpone the entry before or after the identified level
- Rate of Change for Entry Condition
- Take Profit, Stop Loss and Trailing Stop
- EMA length
Backtesting :
⁃ Exchange: BINANCE
⁃ Pair: NULSUSDT
⁃ Timeframe: 2H
⁃ Fee: 0.075%
⁃ Slippage: 1
- Initial Capital: 10000 USDT
- Position sizing: 10% of Equity
- Start : 2018-07-26 (Out Of Sample from 2022-12-23)
- Bar magnifier: on
Credits : LucF for Pine Coders (f_security function to avoid repainting using security)
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.
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.
Risk Reward Calculator [lovealgotrading]
OVERVIEW:
This Risk Reward Calculator strategy can help you maximize your RR value with help of algorithmic trading.
INDICATOR:
I wanted to setup my trades more easier with this indicator, I didn't want to calculate everytime before orders, with help this indicator we can calculate R:R value, avarage price, stoploss price, take-profit price, order prices, all position cost and more ...
Our strategy is a risk revard calculation indicator that is made easy to use by using visualized lines and panels, and also has algorithmic trading support.
With the help of this indicator, we can quickly and easily calculate our risk reward values and enter the positions.
If we want to ensure that our balance grows regularly while trading in the stock market, we need to manage the risks and rewards otherwise we may fall below our initial balance at the end of the day, even if we seem to be winning.
What is the Risk-Reward value ?
This value is a value that shows how many times the amount of risk we take when entering the position is successful, we will earn.
- For example, you risked $100 while entering the trade, so if your trade stops, you will lose 100 $.
Your Risk-Reward(RR) value is 2 means that if your position is successful, you will have 200 $ in your pocket.
A trader's success is determined by the amount of R he earns monthly or yearly, not how much money he makes.
What is different in this indicator ?
I want to say thank you to © EvoCrypto. His Calculator (weighted) – evo indicator helped me when I was developed my indicator.
I want to explain what I have improved:
1-In this strategy, we can determine the time period in which we want to open our positions.
2-We can open a maximum of 4 positions in the same direction and close our positions at a single level. StopLoss or TakeProfit
3-This indicator, which works in the form of a strategy, shows where our positions have been opened or closed. With the help of this, it helps us to determine our strategy in our future positions more accurately.
4-The most important improvement is that we do not miss our positions with the help of alarms (WEB HOOK). if we want, we receive by quickly connecting all these positions to our robot, the software can enter and exit the position while we are busy.
IMPLEMENTATION DETAILS – SETTINGS:
1 - We can set the start and end dates of the positions we will take.
2- We can set our take profit, stoploss levels.
3- If your trade is stopped, we can determine the amount of the trade that we will lose.
4- We can adjust our entry levels to positions and our position sizes at entry levels.
(Sum of positions weight must be 100%)
5- We can receive our positions even if we are busy with the help of algorithmic trading. For this, we must paste our Jshon codes into the fields specified in the settings panel.
6- Finally, we can change the settings we want and don't want to have in our visual elements.
Let's make a LONG side example together
We have determined our positions to enter stoploss, take profit and long positions. We did not forget to set the start time of our strategy
Our strategy appear on the graph as follows.
Our strategy has calculated the total position size, our R-R value, the distance of the current price to the stop and take profit levels, in short, a lot of things we could look visually.
Notes:
If you're going to connect this bot to an automatic Long or Short direction,
Don’t forget! you need to Webhook URL,
Don’t miss paste this code to your message window {{strategy.order.alert_message}}
ALSO:
If you have any ideas what to add to my work to add more sources or make calculations cooler, feel free to write me.
Dynamic Stop Loss DemoWhat does this script do ?
This script is for pine script programmers and explains how to implement a dynamic stop-loss strategy. It is different from trailing stop-loss. Trailing stop-loss can only set the retracement value, but this script can take profit on part of the position at a fixed price and allows users to decide whether to take profit on all positions based on whether a certain track is breached or other conditions author want. In this demo, it use rsi crossover and crossunder to decide the strategy condition, and use close price as open price, and use lowest low / highest high as stop price, and use 1.5 risk ratio to calculate the fixed first profit price. It will take 50% position size when the first profit price was reached. Then it will close all rest positions when the inverse condition come out or the dynamic stop(calculated by ATR) breached or when the price back to the open price or the stop price.
How is this script implemented
When start strategy by strategy.entry , it gives a custom id which contains direction, openPrice, stopPrice, profitPrice, qty, etc. It can be get from the global variable strategy.posiition_entry_name .
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.
VIX Futures Spread StrategyThis script was an exercise in learning Pinescript and exploring the futures curve of the VIX in relation to SPY. Was deleted by TV, trying to republish it now with updated parameters for slippage and commission and a more detailed description.
"VIX Futures Spread Strategy" is a trading strategy that capitalizes on the spread between the 3-month VIX futures (VIX3M) and the spot VIX index. This strategy is based on the idea that the VIX futures spread can serve as a contrarian indicator of market sentiment, with extreme negative spreads potentially signaling oversold conditions and opportunities for long positions.
Ordinarily the VIX curve is in contango as futures contracts are priced at a premium to the current spot price and are used to hedge future uncertainty in the market. When the spot price of VIX spikes the curve can invert and enter backwardation; this strategy detects this condition and uses it as a trigger to open a long position in SPY. The spread going negative tends to correlate with excessive fear and uncertainty in the short term while expecting lower volatility in the long term, in this case 3 months out.
The strategy is designed to enter a long position when the VIX futures spread is negative and to exit the position when the spread rises above 3 -- when the curve is in contango again. The strategy employs a pyramiding approach, allowing up to 10 additional orders to be placed while the entry condition is met, with each order consisting of 10 contracts. This approach aims to maximize potential profits during periods of favorable market conditions.
In this strategy, the VIX futures spread is calculated as the difference between the 3-month VIX futures (VIX3M) and the spot VIX index. The spread is plotted as a histogram on the chart, with the zero line representing no spread, and horizontal lines at 0 and 3 indicating the entry and exit thresholds, respectively.
The strategy's backtesting settings use an initial capital of HKEX:10 ,000, a commission of 0.5% per trade, and a maximum of 10 pyramiding orders, and a slippage of 2 ticks.
Please note that this strategy is intended for educational purposes and should not be considered as financial advice. Before using this strategy in live trading, make sure to thoroughly test and optimize its parameters to suit your risk tolerance and specific trading conditions.
Strategy DesignerHello traders.
Thanks to the tool I have published, everyone who knows or does not know coding will be able to create strategies and see the results instantly on the screen. Yes it looks very nice :)
What does this script do?
Thanks to this tool, even if you don't know any coding, you will be able to create your own strategies. You can add and remove indicators.
Entrance
The first thing you need to do is to set a strategy in your mind.
Then you need to adjust the settings of the indicators installed in the system. Please set the indicators first, because later they are forgotten.
The screen for entering the parameters of the indicators will be as follows.
After entering the parameters there is an important part . In this section, we can adjust the strategy settings.
First we choose between which dates we want the strategy to run. We then choose whether we want the strategy results to be displayed in a table or not.
We choose how the Terms should be linked together. For example, if you have a condition that is expected to produce more than one receive signal, select whether these conditions are connected to each other with and or with the connector.
In this way, you can determine whether all or any of the rules in your strategy should apply.
Next, we choose whether our strategy will work in the spot market or in a bidirectional market. Yes, you can design a strategy for both spot and bidirectional trades :)
At the bottom of the above image, we see a screen where we can adjust the stop level and tp level. As a standard, adjustments are made according to the percentage level you enter. However, if you remove the tick next to the percent sign, the previous stop level and the next profit level are determined as much as the value you entered.
At the bottom is the trailing stop. When you open the trailing stop, the trailing stop becomes active in your strategy.
Very important, when the trailing stop and the stop are active at the same time, the trailing stop value is valid.
It's time to design our strategy. Each chapter that begins with an exclamation point is a separate fiction.
If you do not mark the Active button, that condition will not be included in the calculation.
Direction = It is the direction for which the fiction in this region is valid.
We came to the indicator setting screen. Here, there is a screen where we can select two different indicators on the right and left.
We choose the first indicator starting with 1.
Then we choose from the middle region how we want these two indicators to interact.
We choose our second indicator from the place starting with 2.
If you want an indicator to interact with any value, tick the box where it says Value and fill in the value in the blank. When Value is ticked, the second indicator does not work.
Educational Strategy : TRIPLE DRAG-ON SYSTEM V.1The Triple Dragon System is a technical trading strategy that uses a combination of three different indicators to identify potential buy and sell signals in the market. The three indicators used in this strategy are the Extended Price Volume Trend (EPVT), the Donchian Channels, and the Parabolic SAR. Each of these indicators provides different types of information about the market, and by combining them, we can create a more comprehensive trading system.
The EPVT is used to identify potential trend changes and measure the strength of a trend. The Donchian Channels are used to identify the direction of the trend, while the Parabolic SAR is used to provide additional confirmation of trend changes and help determine potential entry and exit points.
In this strategy, we first use the EPVT and Donchian Channels to identify the direction of the trend. When the EPVT is above its baseline and the price is above the upper Donchian Channel, it suggests an uptrend. Conversely, when the EPVT is below its baseline and the price is below the lower Donchian Channel, it suggests a downtrend.
Once we have identified the trend direction, we use the Parabolic SAR to help determine potential entry and exit points. When the Parabolic SAR is below the price and flips to above the price, it suggests a potential buy signal. Conversely, when the Parabolic SAR is above the price and flips to below the price, it suggests a potential sell signal.
To further refine our trading signals, we use multiple timeframes to confirm the trend direction and ensure that we are not entering the market during a period of high volatility. We also use multiple take-profit levels to lock in profits and manage risk.
Overall, the Triple Dragon System is a comprehensive technical trading strategy that combines multiple indicators to provide clear entry and exit signals. By using a combination of trend-following and momentum indicators, we can identify potential trading opportunities while minimizing risk. Please note that this strategy is for educational purposes only and should not be taken as financial advice.
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.
LowFinder_PyraMider_V2This strategy is a result of an exploration to experiment with other ways to detect lows / dips in the price movement, to try out alternative ways to exit and stop positions and a dive into risk management. It uses a combination of different indicators to detect and filter the potential lows and opens multiple positions to spread the risk and opportunities for unrealized losses or profits. This script combines code developed by fellow Tradingview community_members.
LowFinder
The lows in the price movement are detected by the Low finder script by RafaelZioni . It finds the potential lows based on the difference between RSI and EMA RSI. The MTF RSI formula is part of the MTFindicators library developed by Peter_O and is integrated in the Low finder code to give the option to use the RSI of higher timeframes. The sensitivity of the LowFinder is controlled by the MA length. When potential lows are detected, a Moving Average, a MTF Stochastic (based the the MTFindiicators by Peter_O) and the average price level filter out the weak lows. In the settings the minimal percentage needed for a low to be detected below the average price can be specified.
Order Sizing and Pyramiding
Pyramiding, or spreading multiple positions, is at the heart of this strategy and what makes it so powerful. The order size is calculated based on the max number of orders and portfolio percentage specified in the input settings. There are two order size modes. The ‘base’ mode uses the same base quantity for each order it opens, the ‘multiply’ mode multiplies the quantity with each order number. For example, when Long 3 is opened, the quantity is multiplied by 3. So, the more orders the bigger the consecutive order sizes. When using ‘multiply’ mode the sizes of the first orders are considerably lower to make up for the later bigger order sizes. There is an option to manually set a fixed order size but use this with caution as it bypasses all the risk calculations.
Stop Level, Take Profit, Trailing Stop
The one indicator that controls the exits is the Stop Level. When close crosses over the Stop Level, the complete position is closed and all orders are exited. The Stop Level is calculated based on the highest high given a specified candle lookback (settings). There is an option to deviate above this level with a specified percentage to tweak for better results. You can activate a Take Profit / Trailing Stop. When activated and close crosses the specified percentage, the Stop Level logic changes to a trailing stop to gain more profits. Another option is to use the percentage as a take profit, either when the stop level crosses over the take profit or close. With this option active, you can make this strategy more conservative. It is active by default.
And finally there is an option to Take Profit per open order. If hit, the separate orders close. In the current settings this option is not used as the percentage is 10%.
Stop Loss
I published an earlier version of this script a couple of weeks ago, but it got hidden by the moderators. Looking back, it makes sense because I didn’t pay any attention to risk management and save order sizing. This resulted in unrealistic results. So, in this script update I added a Stop Loss option. There are two modes. The ‘average price’ mode calculates the stop loss level based on a given percentage below the average price of the total position. The ‘equity’ mode calculates the stop loss level based on a given percentage of your equity you want to lose. By default, the ‘equity’ mode is active. By tweaking the percentage of the portfolio size and the stop loss equity mode, you can achieve a quite low risk strategy set up.
Variables in comments
To sent alerts to my exchange I use a webhook server. This works with a sending the information in the form of a comment. To be able to send messages with different quantities, a variable is added to the comment. This makes it possible to open different positions on the exchange with increasing quantities. To test this the quantities are printed in the comment and the quantities are switched off in the style settings.
This code is a result of a study and not intended for use as a worked out and full functioning strategy. Use it at your own risk. To make the code understandable for users that are not so much introduced into pine script (like me), every step in the code is commented to explain what it does. Hopefully it helps.
Enjoy!