NewsItems
Definition
NewsItems can be used to store news articles.
Properties
| Property | Description |
|---|---|
| Items | Collection of NewsEventArgs representing news articles |
| NewsToMaintain | An int representing the number of articles to maintain |
| Update() | For storing news articles |
Syntax
NewsItems
Examples
/* Example of storing and accessing news items from an Add On. The concept can be carried overto any NinjaScript object you may be working on. */public class MyAddOnTab : NTTabPage{private NewsSubscription newsSubscription;private NewsItems newsItems;public MyAddOnTab(){// Subscribe to newsnewsSubscription = new NewsSubscription();newsSubscription.Update += OnNews;newsItems = new NewsItems(10);// Print newsPrintNews(newsItems);}// This method is fired as new News events come in. Old News events are not provided when you subscribe.private void OnNews(object sender, NewsEventArgs e){// Store the news itemsnewsItems.Update(e);}// Loop through the stored news articles and output themprivate void PrintNews(NewsItems news){for (int x = 0; x < news.Items.Count; x++){NinjaTrader.Code.Output.Process(string.Format("ID: {0} News Provider: {1} Headline: {2}",news.Items[x].Id,news.Items[x].NewsProvider,news.Items[x].Headline), PrintTo.OutputTab1);}}// Called by TabControl when tab is being removed or window is closedpublic override void Cleanup(){// Make sure to unsubscribe to the News subscriptionif (newsSubscription != null)newsSubscription.Update -= OnNews;}// Other required NTTabPage members left out for demonstration purposes. Be sure to add them in your own code.}