OPEN-SOURCE SCRIPT
تم تحديثه

Celestial Pair Spread

352
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.

لقطة

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.

لقطة

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!
ملاحظات الأخبار
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.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.