NexusFi: Find Your Edge


Home Menu

 





Help - Indicator to calculate basis between spot index value and future price


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one shansen with 6 posts (2 thanks)
    2. looks_two ratfink with 3 posts (1 thanks)
    3. looks_3 rleplae with 2 posts (0 thanks)
    4. looks_4 zmaj with 1 posts (0 thanks)
    1. trending_up 3,760 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 11 posts
    2. attach_file 7 attachments




 
Search this Thread

Help - Indicator to calculate basis between spot index value and future price

  #1 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5

Forum,

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 -6 points.
  • 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).

This conversation is also at the NT Forum.

As always, thanks
Shannon

Attached Thumbnails
Click image for larger version

Name:	ESZ5 - SPX.PNG
Views:	210
Size:	353.9 KB
ID:	201064   Click image for larger version

Name:	ESH6 - SPX.PNG
Views:	203
Size:	282.3 KB
ID:	201065   Click image for larger version

Name:	NT - TestSyncSeries.png
Views:	238
Size:	61.6 KB
ID:	201066  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


shansen View Post
Forum,

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 -6 points.
  • 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).

This conversation is also at the NT Forum.

As always, thanks
Shannon


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)

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5


rleplae,

Thank you for your response. I agree:
  • the result shown in NT8 is most likely not correctly handling the fact that both series don't align.
  • it is be possible to manually calculate.

However, I require the calculation to be automated.
Any ideas / experience in automating the calculation would be greatly appreciated.

Thanks again
Shannon

Started this thread Reply With Quote
  #4 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


shansen View Post
rleplae,

Thank you for your response. I agree:
  • the result shown in NT8 is most likely not correctly handling the fact that both series don't align.
  • it is be possible to manually calculate.

However, I require the calculation to be automated.
Any ideas / experience in automating the calculation would be greatly appreciated.

Thanks again
Shannon

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

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5


rleplae View Post
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

Rleplae,

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.

Started this thread Reply With Quote
  #6 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5

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.


Any suggestions are welcome.

Regards
Shannon

Attached Files
Elite Membership required to download: TestSyncSeries.zip
Started this thread Reply With Quote
  #7 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


shansen View Post
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.

Any suggestions are welcome.

Regards
Shannon

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.


Cheers

Travel Well
Attached Thumbnails
Click image for larger version

Name:	^DAX 30 Min 14h37m53s.png
Views:	238
Size:	47.3 KB
ID:	201159  
Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5

ratfink,

Thanks to your response.

I am happy to see it is just me experiencing this problem.
Could I press you for a copy of your old NT7 difference indicator via the forum (or PM).

Again, thank you
Shannon

Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
 
zmaj's Avatar
 zmaj 
Ojai, USA
 
Experience: Advanced
Platform: Abdominal Plank
Trading: Energy
Posts: 770 since Jan 2016
Thanks Given: 472
Thanks Received: 1,083

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.

Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


Hi @shansen,

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.

Cheers

Travel Well
Attached Files
Elite Membership required to download: PlotDiff.zip
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on January 20, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts