SpreadTrade - CorrelationCorrelation Based Pair Trading Strategy (Trading the spread)
There are three popular styles of Pair trading:
* Distance based pair trading
* Correlation based pair trading
* Cointegration based pair trading
The correlation based strategy is to short the outperforming instrument and go long on the underperforming one
whenever the temporary correlation weakens which means one instrument going up and another going down.
Here, instead of two different instruments two timeframes of the same instrument are used, lower and higher.
In order to calculate the trade size, we would need to calculate hedge_ratio,
which is simply the ratio of the closing price of the instrument in the current tf to the higher tf.
So whenever we want to go short on spread we’ll short 1 unit of current tf and go long on hedge ratio times units of higher tf.
In order to generate trading signals, we need to define our trading logic.
So, we’ll go long on the spread when the hedge ratio goes below its p rolling mean by mult times of its
rolling standard deviation and vice versa.
Note that both p and mult can be changed as per your selection of instruments.
See: analyticsprofile.com
NOTE:
There is a minor problem to it in Pinescript. After a while the signal line goes horizontal and the two bounds, upper and lower, converge unless you update the time frame.
Kepp me in the know if you find a solution to this problem)
Spread
Price SpreadIncludes logarithmic and linear plotting of price spread (high-low).
See comments for more information.
Thanks to @GravitasProblem for the inspiration.
Relative Spread StrengthRelative Spread Strength indicator script. This indicator was originally developed by Ian Copsey (Stocks & Commodities V. 24:10 (16-23): Forex Focus).
Simple Spread Indicator + EMASimple indicator to see the spread between high and low, great to spot volatile moves. Put an exponential moving average of the spread in there too, adjustable to ones preferences.
EMA Spread OscillatorEMA Spread Oscillator
Quickly see past levels where diff maxed out. Momentum and price can only keep going up for so long. This obviously differs per underlying asset. So that is where this oscillator comes in handy.
Of course you can see on the chart how far apart the moving averages are, but it is easier to spot on an oscillator.
Simple Spread Simple spread between two tickers. Click format to set inputs for tickers. ex: "COINBASE:BTC:USD"
EMA and SMA SpreadI had hard time to find a simple script to show EMA and SMA spread.
Bonus add for PT users :)
Set "buy_value" as you have in PAIRS.properties to show you when your buys will become potential.
Price relation viewer - add percent change of two symbols (BETA)This script is very much beta!
This is a simple script to visualize how two symbols move in relation to each other. For example if the underlying symbol is a 2x Gold ETF (meaning the ticker moves at 2x the spot price of gold---if gold goes up 3% this ticker should go up 6%) and the comparison symbol is an 2x inverse gold ETF (at gold up 3% this should move down 6%). If these ETFs were 100% accurate at tracking the price of gold then this tool would report a value of zero at all times.
Day 1
Ticker - $10
Comparison - $10
Day 2
Ticker - $12
Comp - $11
This tool value - |20%| + -|10%| = 10%
It uses a short simple moving average to smooth things out a bit (see inputs). It is important to keep your axis scale in mind when using this! Two symbols that are always near zero mean they are offsetting each other very well but the value displayed might range from 0 to 0.005, but the graphed area can make it look extreme if autoscaled.
This is a tool with very specific uses : comparing how one digital currency moves in relation to bitcoin's price, comparing how gold moves in relation to silver, etc.
Spread Close & SMA200 & Less EMA200Simple Oscillator showing Price relative to a 200-Day SMA and 200-Day EMA
Bitcoin SpreadIt selects the min/max price for btc/usd from a set of exchanges and shows them on the chart. It is possible to add or remove exchanges by editing the source code
Tarzan's spread ratio indicator - DeLuxeThis indicator plots any two securities as a spread ratio using either +,-,/, or *.
It also allows you to use a simple moving average of length 1 to n for your spread ratio.
If you know what you want to do but don't know how to code it, we can work it out, you can float me some cheese on paypal and I'll do a nice job. This indicator is yours for free.
Tarzan = noprism@hushmail.com
Peace
Indicator Integrator Strat <<<<<< Updated again, second2nd patch
Found an error in the orders. Script was making double orders at times. I fixed it. It is tuned as such:
NZDUSD
15 min chart
starting $USD to show 1000 contracts for minicontract with FXCM (start date 3-18 $633 ** see note)
Indicator plots Starting equity-trade gain and loses-number of trades time spread = net money
** with 1:50 leverage it requires $16 for one 1,000 contract.
$84 net vs $16 initial balance is 456% in 109 days.
* If you find errors please comment.