Symbols Correlation, built for pair tradingOverview:
This script is designed for pairs trading. If you are not familiar with pairs trading, I suggest learning about it, as it can be a profitable strategy in neutral markets (or neutral trends between two assets). The correlation between two assets is the foundation of pairs trading, and without it, the chances of making a profit are low.
Correlation can be described in two opposite ways:
1: Absolute positive correlation (meaning the asset prices move together).
-1: Absolute negative correlation (meaning the asset prices move in opposite directions).
Any value between 1 and -1 indicates some degree of correlation, but generally, values higher than 0.7 or lower than -0.7 are considered significant.
Features:
Typically, correlation is measured using the closing prices. This script adds three more correlation studies based on open, high, and low prices. By using all four lines, we can get a better understanding of the pair's correlation.
How to Read This Indicator:
To use this indicator effectively, you need to input your pair as a ratio. For example, if your pair is TSN and ZBH, enter it in the symbol search as: TSN/ZBH
Gray Area : This area indicates "no high correlation" (default is between -0.8 and 0.8, adjustable in the settings).
Gray Line : This represents the close correlation within the "no high correlation" range.
Green Line : This represents the close correlation within the "high correlation" range.
Dot Lines : These represent the open, high, and low correlations.
Example Interpretations:
A : All four lines are close together & the line is green – very good correlation!
B : The line is gray, and the dot lines are apart – not a strong correlation.
C : When the close correlation remains green for a long time, it signals a strong correlation.
Application in Pairs Trading:
In pairs trading, aim for the highest possible correlation, and it is important to have a sustained correlation over a long period. Pairs that correlate only part of the year but not consistently are less reliable for pairs trading.
This is an example for good correlation for pairs trading:
This is an example for bad correlation for pairs trading:
Here is a view of my full indicators when doing pairs trading:
Pairs-trading
Trend Momentum Strength Indicator, Built for Pairs TradingOverview:
This script combines multiple indicators to provide a comprehensive analysis of both trend strength and trend momentum. It is tailored specifically for pairs trading strategies but can also be used for other trading strategies.
Benefit of Comprehensive Analysis:
Having an indicator that evaluates both trend strength and trend momentum is crucial for traders looking to make informed decisions. It allows traders to not only identify the direction and intensity of a trend but also gauge the momentum behind it. This dual capability helps in confirming potential trade opportunities, whether for entering trades with strong trends or considering reversals during overbought or oversold conditions. By integrating both aspects into one tool, traders can gain a holistic view of market dynamics, enhancing their ability to time entries and manage risk effectively.
Features:
* Trend Strength:
Enhanced ADX Formula: The script includes modifications to the standard ADX formula along with DI+ and DI- to provide more responsive trend strength readings.
Directional Indicators: DI+ (green line) indicates positive directional movement, while DI- (red line) indicates negative directional movement.
Trend Momentum:
Modified Stochastic Indicators: The script uses %K and %D indicators, modified and combined with ADX to give a clear indication of trend momentum.
Momentum Strength: This helps determine the strength and direction of the momentum.
Trading Signals:
Combining Indicators: The script combines ADX, DI+, DI-, %K, and %D to generate comprehensive trading signals.
Optimal Entry Points: Designed to identify optimal entry points for trades, particularly in pairs trading.
Colored Area at Bottom:
This area provides two easy-to-read functions:
Color:
Green: Upward momentum (ratio above 1)
Red: Downward momentum (ratio below 1)
Height:
Higher in green: Stronger upward momentum
Lower in red: Stronger downward momentum
Legend:
Green Line: DI+ (Positive)
Red Line: DI- (Negative)
Black Line: ADX
How to Read This Indicator:
1) Trend Direction:
DI+ above DI-: Indicates an upward trend.
DI- above DI+: Indicates a downward trend.
2) Trend Strength:
ADX below 20: Indicates a neutral trend.
ADX between 20 and 25: Indicates a weak trend.
ADX above 25: Indicates a strong trend.
Trading Signals in Pairs Trading:
Neutral Trend: Ideal for pairs trading when no strong trend is detected.
Overbought/Oversold: Uses %K and %D to identify overbought/oversold conditions that support trade decisions.
Entry Signals: Green signals for long positions, red signals for short positions, based on combined criteria of neutral trend strength and supportive momentum.
Application in Pairs Trading:
Neutral trend: In pairs trading strategies, where neutral movement is often sought, this indicator provides signals that are especially relevant during periods of neutral trend strength and supportive momentum, aiding traders in identifying optimal entry
Risk Management: Combining signals from ADX, DI+, DI-, %K, and %D helps traders make more informed decisions regarding entry points, enhancing risk management.
Example Chart (The indicator is on the upper right corner):
Clean Presentation: The chart only includes the necessary elements to demonstrate the indicator’s functionality.
Demonstrates: Overbought/oversold conditions, upward/downward/no momentum, and trading signals with/without specific scenarios.
Bollinger Pair TradeNYSE:MA-1.6*NYSE:V
Revision: 1
Author: @ozdemirtrading
Revision 2 Considerations :
- Simplify and clean up plotting
Disclaimer: This strategy is currently working on the 5M chart. Change the length input to accommodate your needs.
For the backtesting of more than 3 months, you may need to upgrade your membership.
Description:
The general idea of the strategy is very straightforward: it takes positions according to the lower and upper Bollinger bands.
But I am mainly using this strategy for pair trading stocks. Do not forget that you will get better results if you trade with cointegrated pairs.
Bollinger band: Moving average & standard deviation are calculated based on 20 bars on the 1H chart (approx 240 bars on a 5m chart). X-day moving averages (20 days as default) are also used in the background in some of the exit strategy choices.
You can define position entry levels as the multipliers of standard deviation (for exp: mult2 as 2 * standard deviation).
There are 4 choices for the exit strategy:
SMA: Exit when touches simple moving average (SMA)
SKP: Skip SMA and do not stop if moving towards 20D SMA, and exit if it touches the other side of the band
SKPXDSMA: Skip SMA if moving towards 20D SMA, and exit if it touches 20D SMA
NoExit: Exit if it touches the upper & lower band only.
Options:
- Strategy hard stop: if trade loss reaches a point defined as a percent of the initial capital. Stop taking new positions. (not recommended for pair trade)
- Loss per trade: close position if the loss is at a defined level but keeps watching for new positions.
- Enable expected profit for trade (expected profit is calculated as the distance to SMA) (recommended for pair trade)
- Enable VIX threshold for the following options: (recommended for volatile periods)
- Stop trading if VIX for the previous day closes above the threshold
- Reverse active trade direction if VIX for the previous day is above the threshold
- Take reverse positions (assuming the Bollinger band is going to expand) for all trades
Backtesting:
Close positions after a defined interval: mark this if you want the close the final trade for backtesting purposes. Unmark it to get live signals.
Use custom interval: Backtest specific time periods.
Other Options:
- Use EMA: use an exponential moving average for the calculations instead of simple moving average
- Not against XDSMA: do not take a position against 20D SMA (if X is selected as 20) (recommended for pairs with a clear trend)
- Not in XDSMA 1 DEV: do not take a position in 20D SMA 1*standart deviation band (recommended if you need to decrease # of trades and increase profit for trade)
- Not in XDSMA 2 DEV: do not take a position in 20D SMA 2*standart deviation band
Session management:
- Not in session: Session start and end times can be defined here. If you do not want to trade in certain time intervals, mark that session.(helps to reduce slippage and get more realistic backtest results)