Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Help - Indicator to calculate basis between spot index value and future price
In NinjaTrader 8 (B8), I am hoping to create an Indicator (or AddOn) which will return the basis between a spot index value and its associated front month future contract (where basis = future price - spot index value). I hope to use the basis in recent history to approximate the fair value of the future price (i.e. Spot index value + basis). Thus allowing me to execute a limit order futures trade (e.g. ES 03-16) from the index (e.g. ^SP500). For this application, the basis calculation must be correct (accepting that it is approximate)
Please find attached a spread chart of ES 12-15 vs ^SP500 (i.e. ESZ5 vs SPX).
The x-axis covers the period when ESZ5 was the front month futures contract (18 September - 17 December 2015).
The top frame shows the close prices of ESZ5 and SPX during NYSE trading hours ( 9:30am - 4:00pm ET) (1:30am - 8:00am Australia time) with a period of 30mins.
The bottom frame shows the basis (i.e. ESZ5 - SPX).
As you can see, basis converges to zero at contract expiry. While not required for this discussion, the reasons can be found in CME - Understanding stock index futures.
Please find attached
The spread chart for the current contract ES 03-16 (ESH6) over the period when it is the front month contract (18 December - current). It shows basis has ranged between -11 and -6points.
The output from the TestSyncSeries Indicator, which aims to replicate this analysis (noting the only data of interest is on/after 18 December). It shows basis has ranged from -150 to 0 points.
Thus, I believe the two series ES 03-16 and ^SP500 are not aligned.
Any ideas on how to correctly calculate basis in NT8 would be greatly appreciated. If it is of help, the NT data provider is Interactive Brokers (IB).
You are looking at the contango and backwardation values.
These values are fundamentally driven by :
- time (period left up to the expiry of the future)
- volatility
In a correct situation, the indicator most likely will calculate the spread between the two instruments based on a tick basis.
During the cash market, that should not be an issue
however the future trades 23/24 and 5/7 while the cash market does not
Outside the cash market, you will see the spread widening and going back
to normal at the opening of the cash market
The result shown in NT8 is most likely not correctly handling the fact that both series don't align...
The easiest way is to manually calculate a few points (draw both charts seperate)
This is not too difficult, when the cash market is closed, you just need to take the last available price
knowing that this is not correct, the spread will be correct when cash market is open
Again, thank you. I understand the mechanics of calculating basis, I understand the implications outside of cash hours.
I am looking for help in calculating it in NT8 via an Indicator (or AddOn). While it should simple, one DataSeries (future) minus another DataSeries (index), there appears to be an issue with the DataSeries being out of sync.
I imagine I am not the first to have encountered this problem and am looking for help.
I believe the below chart will help explain the issue I am looking to resolve.
The top frame shows the close prices for ^SP500 and ES 03-16 during cash hours.
The bottom frame shows TesSyncSeries which is calculated as ES 03-16 minus ^SP500 (attached).
At noted on the chart with two example points, TestSyncSeries returns something very different to ES 03-16 minus ^SP500.
Looks like the second series you are adding in the indicator code is for a 1 minute period, this will not synchronise with a 30 minute base chart as Ninja infuriatingly uses end of bar timestamps not start of bar. (In NT7 and I'm assuming they have carried it over to NT8).
I correct for this in some of my stuff, but you would be simpler/better to ensure you use all same data series periods.
edit: I'm not sure this is what's happening as you aren't using Time[0] in the calculation, so I'm probably just as puzzled, but I know it's a general issue to avoid.
edit2: In fact so puzzled that I just found an old difference indicator I had for NT7 and it works fine with 30 minute or 1 minute secondary series, maybe ask Ninja.
2nd weWow! This place is truly overwhelming. Information overload!!
Pardon my ignorance, would anyone be kind enough to point me in the direction of an indicator for Sierra charts platform that is calculating and indicating the fibonacci candle levels please ?
Or provide an input if such an indicator exists for the Sierra platform or Ninja or Trade Station or TOS.
A humble thank you for your time responding to this query.
Oops, just realised my mistake in posting this query in here. Sincere apologies.
My NT7 PlotDiff attached, it's pretty basic. I still don't really understand what you are seeing in NT8 unless it is the end of bar timestamps, but they're not used in the code you posted so I remain puzzled.