Go Back   NinjaTrader Support Forum > NinjaTrader 7 > Platform Technical Support

Platform Technical Support General platform technical support for NinjaTrader 7.

Reply
 
Thread Tools Display Modes
Old 05-04-2012, 08:33 AM   #1
norsay
Junior Member
 
Join Date: Apr 2012
Posts: 9
Thanks: 1
Thanked 1 time in 1 post
Default Historical flag false after adding 2nd time-frame

Hi,

We have a strategy which needs a 2nd time-frame. Adding the first time-frame works fine and the feature "days to load" works as expected. The strategy indicates these data as "historical" (by setting the flag named Historical). As soon as we add the 2nd time-frame the flag is immediately set to false, even for historical data.

Is this behavior as expected? Or what can we do to correctly load historical data for multi time-frame strategies?

Best regards
norsay is offline  
Reply With Quote
Old 05-04-2012, 08:58 AM   #2
NinjaTrader_Matthew
NinjaTrader Product Management
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 6,957
Thanks: 268
Thanked 1,331 times in 1,132 posts
Default

Hello,

The second data series should load the same amount of historical data as the primary input source.

Would you be able to provide me with a snippet of your code which demonstrates this behavior?
NinjaTrader_Matthew is offline  
Reply With Quote
Old 05-06-2012, 11:36 PM   #3
norsay
Junior Member
 
Join Date: Apr 2012
Posts: 9
Thanks: 1
Thanked 1 time in 1 post
Default

Hi Matthew

Here are the code samples you asked for. "Wait until flat" is set for real time strategies. The time frame is set to 2 "days to load".

Code:
protected override void Initialize() {
	...	
	Add(ADX(14));
	...
	CalculateOnBarClose = true;
	...
}

protected override void OnBarUpdate() {
	...
	Print("DEBUG: OnBarUpdate() - Historical Data: " + Historical + "Time = " + Time[0]);
	...
}
The sample above works as expected in live trading. The historical data for 2 days in the past are processed for the defined time interval immediatly after starting the live strategy. The Historical flag returns true until we reach the actual live data. That is ok so far.

However as soon as I add a 2nd time frame like in the following example. All data are flaged as Historical false (historical and live data).

Code:
protected override void Initialize() {
	...	
	Add(ADX(14));
	Add(PeriodType.Day, 1);
	...
	CalculateOnBarClose = true;
	...
}

protected override void OnBarUpdate() {
	...
	Print("DEBUG: OnBarUpdate() - Historical Data: " + Historical + "Time = " + Time[0]);
	...
}
Is this a bug? Or is there an other way the see if we are processing historical data or live date?

Best regards
norsay is offline  
Reply With Quote
Old 05-07-2012, 07:30 AM   #4
NinjaTrader_Matthew
NinjaTrader Product Management
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 6,957
Thanks: 268
Thanked 1,331 times in 1,132 posts
Default

Hello,

Your strategy is not meeting the minimum bars required when the daily series is added. By default the strategy will need at least 20 bars. To account for weekends, etc please try increasing your days to load to 25.

You can also try setting Initialize() to BarsRequired = 0;
NinjaTrader_Matthew is offline  
Reply With Quote
Old 05-07-2012, 08:00 AM   #5
norsay
Junior Member
 
Join Date: Apr 2012
Posts: 9
Thanks: 1
Thanked 1 time in 1 post
Default

Hello,

Neither increasing the "days to load" value to 25 nor setting the BarsRequired = 0 has changed the behavior... All data processed are still flaged as Historical = false...
norsay is offline  
Reply With Quote
Old 05-07-2012, 08:05 AM   #6
NinjaTrader_Matthew
NinjaTrader Product Management
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 6,957
Thanks: 268
Thanked 1,331 times in 1,132 posts
Default

If you set the days to load to 50, do you get the prints as true? Please try increasing the days to load to see if you can get this to return as true. In my testing, as long as the bars required was fulfilled, it should return as true.
NinjaTrader_Matthew is offline  
Reply With Quote
Old 05-07-2012, 08:39 AM   #7
NinjaTrader_Matthew
NinjaTrader Product Management
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 6,957
Thanks: 268
Thanked 1,331 times in 1,132 posts
Default

Hello,

Another approach would be adding a current bars check to return if the minimum bars required is not met:

Code:
     protected override void Initialize()
        {
            Add(ADX(14));
            Add(PeriodType.Day, 1);
            
            CalculateOnBarClose = true;
            BarsRequired = 0;

        }
        
        protected override void OnBarUpdate()
        {
            
        if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired) return;
            
            
         Print("DEBUG: OnBarUpdate() - Historical Data: " + Historical + "Time = " + Time[0]);
           
         }
Last edited by NinjaTrader_Matthew; 05-07-2012 at 08:42 AM.
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 05-08-2012, 03:11 AM   #8
norsay
Junior Member
 
Join Date: Apr 2012
Posts: 9
Thanks: 1
Thanked 1 time in 1 post
Thumbs up

Hi Matthew

Increasing the "days to load" to at least 50 values did the job! Unfortunately I increased the value only to about 40 during my first test Sorry...

Guess I learned a lot for further implementations

I appreciate you help very much! Thank you!
norsay is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding time frame to drop down menu tpt56 Platform Technical Support 2 12-12-2011 09:13 PM
No Trades when adding a 2nd Timeframe to a Strategy laocoon Strategy Development 13 06-22-2010 07:27 AM
Discretionary adding of a secondary time frame rperez Platform Technical Support 8 11-16-2009 12:47 PM


All times are GMT -6. The time now is 04:13 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.