Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 08-03-2017, 02:49 PM   #1
suroot
Member
 
Join Date: Feb 2017
Posts: 71
Thanks: 29
Thanked 10 times in 7 posts
Default Strategy output error: A hosted indicator tried to load additional data.

Hi,

This is a low importance error/issue (for now). I got the following error when trying to check if the current close is below/above a pivot point (R1/S1) before entry. When I run backtest, I get no executions but following error:

Code:
A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.
1) What does the error mean?
2) Can pivot point indicator be used in a strategy (to check if close is less or greater than R1/S1 etc.)?

br,
Chris
suroot is offline  
Reply With Quote
Old 08-03-2017, 02:53 PM   #2
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,452
Thanks: 125
Thanked 1,870 times in 1,746 posts
Default

Hello Chris,

The error indicates that an indicator added a dataseries with AddDataSeries() but the host strategy or calling indicator did not.

From the help guide:
"Should your script be the host for other scripts that are creating indicators and series dependent resources in State.DataLoaded, please make sure that the host is doing the same AddDataSeries() calls as those hosted scripts would. For further reference, please also review the 2nd example below and the 'Adding additional Bars Objects to NinjaScript' section in Multi-Time Frame & Instruments"
http://ninjatrader.com/support/helpG...dataseries.htm

"To maximize data loading performance, any NinjaScript object (indicator or strategy as host) which references a multi-series indicator which calls AddDataSeries must include it's own calls to AddDataSeries(). For example, if the code above was included in an indicator, and that indicator was referenced in a NinjaScript strategy, then the hosting strategy will need to include the same calls to AddDataSeries(). When the strategy adds the additional Bars objects, the calls to AddDataSeries() within the indicator will be ignored. If the Bars objects are not added by the strategy in such cases, and error will be thrown in the Log tab of the Control Center that would read - "A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.""
http://ninjatrader.com/support/helpG...tToninjascript
NinjaTrader_ChelseaB is offline  
Reply With Quote
Old 08-07-2017, 07:07 PM   #3
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 287
Thanks: 13
Thanked 7 times in 7 posts
Default

Hi Chelsea,
there is a bug somewhere in this regard. I was having trouble with a custom strategy, but could not see any error in programming. Then, I was able to produce the error with the built-in "SampleMACrossOver" strategy.
I had cloned a Session Template and changed its hours, because I needed to test something starting up on time. When this Session Template is used, the error occurs.

"A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state."

I've attached a pic of the session template. I tried trashing charts and creating new ones, different instruments etc, but the problem remained persistent.
This is v8.0.8

Cheers,
saltminer
Attached Images
File Type: png Capture.PNG (20.1 KB, 6 views)
saltminer is offline  
Reply With Quote
Old 08-08-2017, 07:05 AM   #4
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,452
Thanks: 125
Thanked 1,870 times in 1,746 posts
Default

Hi saltminer,

Please send an email to platformsupport [at] ninjatrader [dot] com for further assistance.

In the email please include a short description that backtesting the SampleMACrossOver with a custom trading hours template is causing an error to appear in the log.
NinjaTrader_ChelseaB is offline  
Reply With Quote
Old 03-25-2018, 09:12 PM   #5
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 287
Thanks: 13
Thanked 7 times in 7 posts
Default Problem only when optimizing

Hi,
I have a strategy that can load its own intrabar granularity for more accurate backtests. It can use either 1 Minute or 1 Tick dataseries.
It works fine on a chart and in a backtest, but during an optimise the "hosted indicator tried to load additional data" error stops the optimise immediately.

I'm using AddDataSeries(...) in State.Configure. Depending on a user input enum parameter, the AddDataSeries will either be not called, or will be called to add a Minute DataSeries or add a Tick DataSeries.

Is this not possible in the Optimizer, even when this granularity parameter is fixed and not changing throughout the optimisation?

Thanks,
saltminer
saltminer is offline  
Reply With Quote
Old 03-25-2018, 09:20 PM   #6
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,452
Thanks: 125
Thanked 1,870 times in 1,746 posts
Default

Hello saltminer,

It is not supported to have dynamic variables in the AddDataSeries method.

From the help guide:

"Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner."

https://ninjatrader.com/support/help...dataseries.htm
NinjaTrader_ChelseaB is offline  
Reply With Quote
Old 03-27-2018, 04:01 PM   #7
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 287
Thanks: 13
Thanked 7 times in 7 posts
Default

Hi,
is there a way in State.Configure to detect that the strategy is being optimised, and thus the code will ALWAYS (as if hard coded) load the additional dataseries?
saltminer
saltminer is offline  
Reply With Quote
Old 03-28-2018, 07:12 AM   #8
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,452
Thanks: 125
Thanked 1,870 times in 1,746 posts
Default

Hello saltminer,

There is undocumented code shared by Matthew that demonstrates detecting the backtest type.
https://ninjatrader.com/support/foru...231#post431231
https://ninjatrader.com/support/foru...296#post431296


That said, it is still not supported to dynamically add data series including using branching commands (if statements).
NinjaTrader_ChelseaB is offline  
Reply With Quote
The following user says thank you to NinjaTrader_ChelseaB for this post:
Old 05-16-2018, 04:21 PM   #9
music_p13
Senior Member
 
Join Date: Jan 2010
Posts: 138
Thanks: 22
Thanked 7 times in 7 posts
Default

Quote:
Originally Posted by suroot View Post
Hi,

This is a low importance error/issue (for now). I got the following error when trying to check if the current close is below/above a pivot point (R1/S1) before entry. When I run backtest, I get no executions but following error:

Code:
A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.
1) What does the error mean?
2) Can pivot point indicator be used in a strategy (to check if close is less or greater than R1/S1 etc.)?

br,
Chris
Hello,

I am getting same error when adding amaPivots indicator..

A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.

Here is the code I've built with Strategy Builder, but still getting an error...

Any help?

namespace NinjaTrader.NinjaScript.Strategies
{
public class TestAmaPivots : Strategy
{
private NinjaTrader.NinjaScript.Indicators.LizardIndicator s.amaPivotsDaily amaPivotsDaily1;

protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "TestAmaPivots";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Day, 1);
}
else if (State == State.DataLoaded)
{
amaPivotsDaily1 = amaPivotsDaily(Close, amaPivotFormulaPD.Floor_Trader_Pivots, amaSessionTypePD.Daily_Bars, amaCalcModePD.Intraday_Data);
}
}

protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;

if (CurrentBars[0] < 1)
return;

// Set 1
if (CrossAbove(amaPivotsDaily1.PP, Close, 1))
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}

}
}
}

Thanks
music_p13 is offline  
Reply With Quote
Old 05-17-2018, 07:37 AM   #10
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,452
Thanks: 125
Thanked 1,870 times in 1,746 posts
Default

Hello music_p13,

The error message is that the indicator called is adding a dataseries that is not being added to your script (the host).

Is amaPivotsDaily an open source indicator you can see the code of?

What data series has the indicator added with AddDataSeries()?
NinjaTrader_ChelseaB is offline  
Reply With Quote
Old 05-17-2018, 09:35 AM   #11
music_p13
Senior Member
 
Join Date: Jan 2010
Posts: 138
Thanks: 22
Thanked 7 times in 7 posts
Default

Yes, thanks for reply, adding 1 minute and daily dataseries fixed the issue.

I am good now, thanks
music_p13 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
ERROR: A hosted indicator tried to load additional data....... TraderYoda Platform Technical Support 4 11-20-2017 01:04 PM
Error : A hosted indicator tried to load additional data. All data must first be load afshinmoshrefi Strategy Development 34 09-12-2017 12:20 PM
NT8 Error: A hosted indicator tried to load additional data. futures14 Platform Technical Support 23 03-04-2017 06:53 AM
NT 8.0.3.0 - A hosted indicator tried to load additional data... sledge Platform Technical Support 4 01-21-2017 10:05 AM
a hosted indicator tried to load additional data rcfcu2000 Version 8 Beta 6 03-07-2016 08:37 AM


All times are GMT -6. The time now is 10:51 PM.

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.