Spread-Backtesting - NinjaTrader Programming | futures io social day trading
futures io futures trading


Spread-Backtesting
Updated: Views / Replies:1,009 / 4
Created: by asddsa Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Spread-Backtesting

  #1 (permalink)
Trading Apprentice
Malaysia
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: Forex
 
Posts: 2 since Oct 2013
Thanks: 2 given, 0 received

Spread-Backtesting

Hi All, I am new here, trying to create an indicator of spread (eg: mini NQ vs mini S&P) and looking for way to backtest it (if possible) in strategy analyzer, does any one here has similar experience before?

My code as below, so when spread (NQ points level - ES points level) / (Sum of both) is crossing the SMA, i will LONG NQ and Short ES with the proportionality around (137 NQ vs 100 ES). Indicator coding as below:



protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "SPREAD1"));
Add(new Plot(Color.FromKnownColor(KnownColor.ForestGreen), PlotStyle.Line, "SMASPREAD"));
Overlay = false;
Add(FirstInstrument,PeriodType.Day,1);
Add(SecondInstrument,PeriodType.Day,1);
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
// try
// {
if (CurrentBars[0] < 1)
return;

if (BarsInProgress >= 1);
double FirstValue = (Closes[1][0]*Instruments[1].MasterInstrument.PointValue);
double SecondValue = (Closes[2][0]*Instruments[2].MasterInstrument.PointValue);
SPREAD1.Set(((SecondValue-FirstValue)*100)/(SecondValue+FirstValue));
SMASPREAD.Set(SMA(SPREAD1,SMAPERIOD)[0]);
// }
}


Thanks a lot in advance.
Ryan

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,859 since Jun 2009
Thanks: 480 given, 3,255 received


I've done some spread arb stuff, mainly different months of futures contracts. I would have as a baseline a ratio of one instrument over the other. Then I would track the changes in that ratio and the number of standard deviations from the mean. If ratio was higher than "normal" then 1 of 2 things are happening

1) Instrument ONE is rising faster than TWO
2) Instrument TWO is dropping faster than ONE

Your approach is different. I don't know if it's better or worse than what I was doing. I eventually didn't do much more as I could see on the price charts on the back of the board rapidly adjust during these conditions, so I must not have been the only one with that idea. It might be something to consider if you are curious.


asddsa View Post
Hi All, I am new here, trying to create an indicator of spread (eg: mini NQ vs mini S&P) and looking for way to backtest it (if possible) in strategy analyzer, does any one here has similar experience before?

My code as below, so when spread (NQ points level - ES points level) / (Sum of both) is crossing the SMA, i will LONG NQ and Short ES with the proportionality around (137 NQ vs 100 ES). Indicator coding as below:



protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "SPREAD1"));
Add(new Plot(Color.FromKnownColor(KnownColor.ForestGreen), PlotStyle.Line, "SMASPREAD"));
Overlay = false;
Add(FirstInstrument,PeriodType.Day,1);
Add(SecondInstrument,PeriodType.Day,1);
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
// try
// {
if (CurrentBars[0] < 1)
return;

if (BarsInProgress >= 1);
double FirstValue = (Closes[1][0]*Instruments[1].MasterInstrument.PointValue);
double SecondValue = (Closes[2][0]*Instruments[2].MasterInstrument.PointValue);
SPREAD1.Set(((SecondValue-FirstValue)*100)/(SecondValue+FirstValue));
SMASPREAD.Set(SMA(SPREAD1,SMAPERIOD)[0]);
// }
}


Thanks a lot in advance.
Ryan


Reply With Quote
 
  #4 (permalink)
Elite Member
Charlottetown, Prince Edward Island
 
Futures Experience: Advanced
Platform: Ninja
Broker/Data: Optimus - Rithmic
Favorite Futures: GC
 
WolfieWolf's Avatar
 
Posts: 232 since Jul 2010
Thanks: 100 given, 273 received

Once upon a time I played with spreads a lot in NT. I even had a spreader, like the commercial ones, except written for NT but abandoned it. There is an indicator in the Elite section called T4SpreadSym that will allow you calculate and plot the spread of two instruments, you might need to modify the formula a little but that part is trivial compared to the backtesting. When I attempted to backtest using the indicator as a plot I ended up with one side or the other but never the positions from both instruments. In the end I created two strategies, one inverse of the other, ran them both, and manually aggregated the results. It was a real pain in the butt. Ninja is not designed for spreading, even though it can be taught to execute them, plotting them is a whole different thing. The last idea I had was to create a custom bar type that would calculate the spread and then allow standard ninja charts to plot it but I never took it this far. I did, however, find a developer who was willing to do the work. If you are interested I could give you his contact details, I'm sure he would do the same for you but it was pricey.

/W

Reply With Quote
The following user says Thank You to WolfieWolf for this post:
 
  #5 (permalink)
Trading Apprentice
Malaysia
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: Forex
 
Posts: 2 since Oct 2013
Thanks: 2 given, 0 received

Thanks wolf, guess I shall move on first as just curious on how to backtest spread in Ninjatrader. Costing is a big concern for me at the moment, interesting on the spread you tested on different month. Look forward to talk to you again. cheers. Ryan

Reply With Quote

Reply



futures io > > > > > Spread-Backtesting

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
spread trading parsamkk Elite Automated Trading 13 January 28th, 2014 01:37 AM
futures option spread versus futures spread leinster Commodities Futures Trading 4 September 7th, 2013 02:25 PM
MultiCharts backtesting and spread arjfca The Elite Circle 3 September 26th, 2010 09:06 AM
Spread LukeGeniol Terms (Glossary) 0 July 14th, 2010 05:19 PM
spread on Ninjatrader siscop NinjaTrader Programming 1 September 5th, 2009 07:17 PM


All times are GMT -4. The time now is 01:56 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-15 in 0.10 seconds with 19 queries on phoenix via your IP 54.82.56.95