OPEN-SOURCE SCRIPT
Telah dikemas kini

Celestial Pair Spread

1 383
Hello friends, after a very long time!
Today, I tried to put into code an idea that came to my mind spontaneously and suddenly.
Note :
This script is experimental and improvable.
I haven't had a chance to try it yet.
TIMEFRAME : 1D (Daily Bars)

CELESTIAL SPREAD
The spread moves in a very limited area and is consistent within itself, especially on days far from the end of the contract.
That's why there is a reassuring sky atmosphere. That's why this name was given completely improvised.
Basic logic of the script
We enter the name of the CME Futures contract we want to enter:
Ex : CL1! , ES1! , ZC1! , NQ1!
The script creates us a pair trade parity divided into secondary contracts.
Example : ES1!/ES2!
What is pair trading?
I will explain briefly here.
For users who are wondering:
investopedia.com/terms/p/pairstrade.asp
Let's get back to our topic.
Now we have created a parity that does not actually exist.
This parity is the manifestation of the relative movements of two contracts.
When the parity rises, ES1! increased,ES2! has fallen.
In the opposite case, We can say: ES1! Contract has been dropped ES2! has increased.

Pair trading is generally a trade that needs to be kept in mind from time to time.
It is a method preferred by professionals who can process very quickly.
Market risk is minimal, but since 2 contracts are purchased, more money is paid and very low percentage profits are made.
It is very expensive to do pair trading, especially with oil and its derivatives and interest security derivatives.
The contract we are considering has micros. (small-item contracts tied to the same value)
So when we switch to our broker MES1!/MES2! We will trade.
For all CME futures :
cmegroup.com/

Anyway, let's continue:
The script created the parity showing its relationship with the next contract and plotted it as bars.
Celestial bands are just like Bollinger bands, but they consist of 3 bands based on percentage changes rather than standard deviation.
The middle band is obtained from moving averages.
The upper and lower bands are the middle band subjected to a threshold value.
The threshold value can be changed.
0.15 percent was charged for this script.

CAUTION :
As can be seen in the example below;
The most important thing is not to make any transactions when the contract switch dates are approaching.
Therefore, it is recommended to use it just below the main chart.

syot kilat

The blue bars in the parity are
Values ​​that outside the upper and lower threshold values ​​are colored blue.
For this condition
Alerts has been added.
Don't forget to add alert and edit.

MAIN PURPOSE
It is aimed to start a pair trade when such conditions come and to quickly close the trades when the parity basis reaches the value.

syot kilat

OTHER IMPORTANT POINTS

Other issues are broker related issues.
Difference between initial margins and maintanence margins of contracts (between 1! and 2!)
It shouldn't be too high.
The commission should not be too high.
Leverage must be high because the profit percentage is very low.
To calculate leverage you must divide your contract size by the relevant margin requirement.

Sample margin requirement table:
interactivebrokers.com/en/trading/margin-requirements.php

RISKS
It is an experimental and intellectual script,
the risk of contract price differences (maybe it will not leave a profit except for very extreme values)
I remind you of the quickness risk that comes from a two-legged trade.
Alerts definitely synchronized with an audible alert sent to a smartphone as an e-mail notification and displayed on the locked screen for quick action.
Best regards!
Nota Keluaran
First Update :
Celestial Spread Thresolds have been changed for some pairs (percent):
ES1! = 0.15
YM1! = 0.27
GC1! = 0.3
HG1! = 0.4
NQ1! = 0.18
RTY1! = 0.3
M6E1!=0.25
6E1! = 0.25

The fixed value for those that are not among the 1st and 2nd contracts included in these symbols is 0.15.

Agricultural contracts were removed because they were renewed once a month.
Crypto contracts are not included.
Nota Keluaran
All Future contracts with script enabled with last update :

MES : MICRO E-MINI S&P 500 STOCK PRICE INDEX FUTURES
ES : MICRO E-MINI S&P 500 STOCK PRICE INDEX FUTURES
MYM : MICRO E-MINI DOW JONES INDUSTRIAL AVERAGE INDEX FUTURES
YM : E-MINI DOW JONES INDUSTRIAL AVERAGE INDEX FUTURES
MGC : E-MICRO GOLD FUTURES
GC : GOLD FUTURES
MNQ : MICRO E-MINI NASDAQ-100 INDEX FUTURES
NQ : E-MINI NASDAQ-100 INDEX FUTURES
M2K : MICRO E-MINI RUSSELL 2000 INDEX FUTURES
RTY : E-MINI RUSSELL 2000 INDEX FUTURES
M6E : MICRO EUROPEAN MONETARY UNION EURO FUTURES
6E : EUROPEAN MONETARY UNION EURO FUTURES
10Y : 10 YEAR MICRO TREASURY YIELD FUTURES
2YY : 2 YEAR MICRO TREASURY YIELD FUTURES
ZB : US TREASURY BOND FUTURES
ZF : 5 YEAR US TREASURY NOTE FUTURES
ZN : 10 YEAR US TREASURY NOTE FUTURES

NOTE : Timeframe valid for all security: 1D
Nota Keluaran
First of all, this method is called :Calendar Spread.
I previously called it celestial spread, thinking of using the Storm Trading System as a name and giving it a similar name, but this method has actually been around for a long time. It's also much more commonly used in U.S Options.

It's usually executed using the current contract and the highest-volume futures contract of the same product.
The a1! - a2!
form is generally preferred. (not a1!/b1!)
Even in the most liquid futures, it's very misleading and difficult because trading doesn't occur simultaneously in each leg.
In other words, such pricing doesn't actually exist.
Spreads have very low depth and are very risky.
Don't trust low and high levels here. (mostly low timeframes)
The real dynamics are very different.
While it may seem safe, it's a completely unreliable method.
Suggestion :
By extending the trading period by a few hours, days, etc., you can risk contango and backwardation.
Summary :
This script remains only as a theoretical examination item.
Regards.

Penafian

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