NexusFi: Find Your Edge


Home Menu

 





Adding a wide range of contracts for backtesting


Discussion in NinjaTrader

Updated
    1. trending_up 1,304 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Adding a wide range of contracts for backtesting

  #1 (permalink)
 vhanded 
Kuala Lumpur Malaysia
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 8 since Nov 2014
Thanks Given: 3
Thanks Received: 1

Hi, I am currently backtesting calendar spread using NinjaTrader 7, and I am adding a list of CL contracts in Initialize(), like this:

 
Code
Add("CL 03-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 04-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 05-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 06-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 07-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 08-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 09-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 10-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 11-10", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 12-10", BarsPeriod.Id, BarsPeriod.Value);
			
			
			Add("CL 01-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 02-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 03-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 04-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 05-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 06-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 07-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 08-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 09-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 10-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 11-11", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 12-11", BarsPeriod.Id, BarsPeriod.Value);
			
			
			Add("CL 01-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 02-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 03-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 04-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 05-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 06-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 07-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 08-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 09-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 10-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 11-12", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 12-12", BarsPeriod.Id, BarsPeriod.Value);
			
			
			Add("CL 01-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 02-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 03-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 04-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 05-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 06-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 07-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 08-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 09-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 10-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 11-13", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 12-13", BarsPeriod.Id, BarsPeriod.Value);
			
			
			
			Add("CL 01-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 02-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 03-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 04-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 05-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 06-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 07-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 08-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 09-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 10-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 11-14", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 12-14", BarsPeriod.Id, BarsPeriod.Value);
			
			
			Add("CL 01-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 02-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 03-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 04-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 05-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 06-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 07-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 08-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 09-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 10-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 11-15", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 12-15", BarsPeriod.Id, BarsPeriod.Value);
			
			
			Add("CL 01-16", BarsPeriod.Id, BarsPeriod.Value);
			Add("CL 02-16", BarsPeriod.Id, BarsPeriod.Value);

And in my OnBarUpdate(), for demonstration purpose, I will just have:
 
Code
Print("Hello World");
The backtest period is from 1/1/2010 till 19/3/2015, using daily bar, and BarRequired = 0;


Th expected behavior is a list of "Hello World" in console output, but, I am not getting even 1. Seems like OnBarUpdate is not running at all.

However, remove CL 01-16 and CL 02-16 then "Hello World" will be printed. Why is this happening?

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
22 thanks
What is Markets Chat (markets.chat) real-time trading ro …
19 thanks
ApexTraderFunding.com experience and review
15 thanks
GFIs1 1 DAX trade per day journal
15 thanks
EG Indicators
11 thanks
  #2 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,710

Check the "Log" tab in the Control Center to see if there are any error messages, you may have some error messages that occurred in the Initialize() method.


vhanded View Post
Th expected behavior is a list of "Hello World" in console output, but, I am not getting even 1. Seems like OnBarUpdate is not running at all.

However, remove CL 01-16 and CL 02-16 then "Hello World" will be printed. Why is this happening?


Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,471 since Jun 2009
Thanks Given: 33,250
Thanks Received: 101,674


Can you actually chart 01-16 and 02-16? May be a data problem

Sent from my phone



Join the free Markets Chat beta: one platform, all the trade rooms!

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 vhanded 
Kuala Lumpur Malaysia
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 8 since Nov 2014
Thanks Given: 3
Thanks Received: 1


Big Mike View Post
Can you actually chart 01-16 and 02-16? May be a data problem

Sent from my phone

Hi Big Mike, yes, I can add just CL 01-16 and CL 02-16, and "Hello World" is printing. No problem.

Started this thread Reply With Quote
  #5 (permalink)
 vhanded 
Kuala Lumpur Malaysia
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 8 since Nov 2014
Thanks Given: 3
Thanks Received: 1


shodson View Post
Check the "Log" tab in the Control Center to see if there are any error messages, you may have some error messages that occurred in the Initialize() method.

Nothing is printing in Log...

Started this thread Reply With Quote
  #6 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,710


vhanded View Post
Hi Big Mike, yes, I can add just CL 01-16 and CL 02-16, and "Hello World" is printing. No problem.

Daily bars or intraday bars?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 vhanded 
Kuala Lumpur Malaysia
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 8 since Nov 2014
Thanks Given: 3
Thanks Received: 1


shodson View Post
Daily bars or intraday bars?

This is daily bar.

Started this thread Reply With Quote




Last Updated on March 30, 2015


© 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