StrategyBase

View as Markdown

StrategyBase contains properties and methods for managing a Strategy object, and is the base class from which AtmStrategy derives.

Note: For a complete, working example of this class in use, download framework example located on our Developing AddOns Overview.

Examples

1// A button called acctStratButton in an NTTabPage displays all ATM and NinjaScript strategies configured on a selected Account when clicked
2private void OnButtonClick(object sender, RoutedEventArgs e)
3{
4 Button button = sender as Button;
5
6 if (button != null && ReferenceEquals(button, acctStratButton))
7 {
8 // When the button is pressed, iterate through all ATM and NinjaScript strategies
9 // This comprises all which are active, recovered upon last connect, or deactivated since last connect
10 // First, lock the Strategies collection to avoid in-flight changes to the collection affecting our output
11 lock (accountSelector.SelectedAccount.Strategies)
12 // Iterate through the Strategies collection in the selected Account
13 foreach (StrategyBase strategy in accountSelector.SelectedAccount.Strategies)
14 outputBox.AppendText(string.Format("{0}Name: {1}{0}ATM Template Name: {2}{0}Instrument: {3}{0}State: {4}{0}Category: {5}{0}",
15 Environment.NewLine,
16 strategy.Name,
17 strategy.Template,
18 strategy.Instruments[0].FullName,
19 strategy.State,
20 strategy.Category));
21 }
22}