<commit_before>#Template for Indicator, Condition and Strategy
[Originally posted as a question in the Agenatrader forum](http://www.tradeescort.com/phpbb_de/viewtopic.php?f=18&t=2680&p=11739)

This tutorial will show you our templates for indicators, conditions, strategies and give you the ability to communicate between these scripts. This will lead you to more code transparency and reduces your programming time. 

##Why do we want this?
AgenaTrader provides you the ability to create indicators, conditions, alerts and strategies in c# and use them during trading. 
Of course you can start creating an indicator and copy the code afterwards into a condition, a strategy or an alert.
Programming by using "copy & paste" is easy but on the other hand there are many disadvantages like lack of testing reasons, no single point for bug fixing and low maintainability. 

#Indicator
In many cases we are starting with indicators because indicators are the best place to start on script development. 
You will be able to get pretty quick an indication if your trading idea is working and of course you are able to screen instruments visual and verify if your trading idea will be profitable.

##Interface
We use an interface to ensure that all scripts like indicators, conditions, strategies and alerts use the same properties and methods. 
```C#
public interface IDummyOneMinuteEvenOdd {
/* Here we define all properties we need. */
}
```

##Result value
The result value object will holds all result data from the calculate method so we know what to do next. In a strategy we create a long or short order, in a condition we set the Occured object, and so on.
```C#
public class ResultValueDummyOneMinuteEvenOdd {
/* Here we define all properties we need as a result of the calculate method. */
}
```

###Method calculate
We want to capsulate the main logic into one main methods in the indicator. In our case we do this using the following public method in the indicator.

```C#
 public ResultValueDummyOneMinuteEvenOdd calculate(IBar data, bool islongenabled, bool isshortenabled) {
/* 
* Here we do all the smart work and in the end we return our result object
* So the condition or another scripts knows what to do (e.g. a strategy will create an order in the market)
*/
}
```

So it is possible that other scripts just need to call the calculate method of the indicator and get a decision what to do. 
In our case the calculate method return an object which holds all important information what has to be done. 
If we get the OrderAction.Buy as a Entry result, we need to start a long order in a strategy or we set the condition value to 1.

#Files
[Indicator](https://github.com/simonpucher/AgenaTrader/blob/master/Indicator/DummyOneMinuteEvenOdd_Indicator.cs)

[Condition](https://github.com/simonpucher/AgenaTrader/blob/master/Condition/DummyOneMinuteEntryOdd_Condition.cs)

[Strategy](https://github.com/simonpucher/AgenaTrader/blob/master/Strategy/DummyOneMinuteOdd_Strategy.cs)

To compile these scripts without any error you also need access to the [utility indicator] (https://github.com/simonpucher/AgenaTrader/blob/master/Utility/GlobalUtilities_Utility.cs) to use global source code elements.<commit_msg>Filenames, class names, DisplayName and ToString()<commit_after>#Template for Indicator, Condition and Strategy
[Originally posted as a question in the Agenatrader forum](http://www.tradeescort.com/phpbb_de/viewtopic.php?f=18&t=2680&p=11739)

This tutorial will show you our templates for indicators, conditions, strategies and give you the ability to communicate between these scripts. This will lead you to more code transparency and reduces your programming time. 

##Why do we want this?
AgenaTrader provides you the ability to create indicators, conditions, alerts and strategies in c# and use them during trading. 
Of course you can start creating an indicator and copy the code afterwards into a condition, a strategy or an alert.
Programming by using "copy & paste" is easy but on the other hand there are many disadvantages like lack of testing reasons, no single point for bug fixing and low maintainability. 

#Indicator
In many cases we are starting with indicators because indicators are the best place to start on script development. 
You will be able to get pretty quick an indication if your trading idea is working and of course you are able to screen instruments visual and verify if your trading idea will be profitable.

##Interface
We use an interface to ensure that all scripts like indicators, conditions, strategies and alerts use the same properties and methods. 
```C#
public interface IDummyOneMinuteEvenOdd {
/* Here we define all properties we need. */
}
```

##Result value
The result value object will holds all result data from the calculate method so we know what to do next. In a strategy we create a long or short order, in a condition we set the Occured object, and so on.
```C#
public class ResultValueDummyOneMinuteEvenOdd {
/* Here we define all properties we need as a result of the calculate method. */
}
```

###Method calculate
We want to capsulate the main logic into one main methods in the indicator. In our case we do this using the following public method in the indicator.

```C#
 public ResultValueDummyOneMinuteEvenOdd calculate(IBar data, bool islongenabled, bool isshortenabled) {
/* 
* Here we do all the smart work and in the end we return our result object
* So the condition or another scripts knows what to do (e.g. a strategy will create an order in the market)
*/
}
```

So it is possible that other scripts just need to call the calculate method of the indicator and get a decision what to do. 
In our case the calculate method return an object which holds all important information what has to be done. 
If we get the OrderAction.Buy as a Entry result, we need to start a long order in a strategy or we set the condition value to 1.

#Miscellaneous
##Filenames and Class names
To import all scripts into AgenaTrader without any error we add _indicator, _strategy, _condition or _alert to the filename and also to the c# class name.

##DisplayName and ToString()
In each script we override the ToString() method and the DisplayName to provide a readable string in AgenaTrader. So we do see a readable string instead of the class name in AgenaTrader.
```C#
        public override string ToString()
        {
            return "Dummy one minute even/odd (C)";
        }

        public override string DisplayName
        {
            get
            {
                return "Dummy one minute even/odd (C)";
            }
        }
```

#Files
[Indicator](https://github.com/simonpucher/AgenaTrader/blob/master/Indicator/DummyOneMinuteEvenOdd_Indicator.cs)

[Condition](https://github.com/simonpucher/AgenaTrader/blob/master/Condition/DummyOneMinuteEntryOdd_Condition.cs)

[Strategy](https://github.com/simonpucher/AgenaTrader/blob/master/Strategy/DummyOneMinuteOdd_Strategy.cs)

To compile these scripts without any error you also need access to the [utility indicator] (https://github.com/simonpucher/AgenaTrader/blob/master/Utility/GlobalUtilities_Utility.cs) to use global source code elements.
{'fraction_non_alphanumeric': 0.05598106113354686, 'fraction_numerical': 0.003342152903495335, 'mean_word_length': 4.387846961740435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3223183', 'n_tokens_mistral': 1895, 'n_tokens_neox': 1843, 'n_words': 980}