SharpScript coding conventions
Posted: Wed Apr 01, 2015 8:44 pm
Add reference to an Indicator
To add reference to another indicator please use the below method.
When using the default parameter
Using the default parameters but specifying the input
When specifying the parameters
when specifying both the input series and the parameters
e.g. reference the SMA
e.g. If you want to call reference the Avg series of the MacD indicator
Note: new object[]{} is the parameter values of the specific indicators constructor.
[Input Attribute]
A user code (which can be an Indicator or a BarType etc) can have one or more Properties. ArthaChitra, uses these user defined properties internally for various tasks, from comparing two objects or simply to append the display name.
Whether the properties be included or excluded from such evaluation depends if the coder assigns the Input Attribute to that property.
For example if the user has two properties, as below:
in such scenario the Property Period will be taken into consideration for various internal assessments as the Input Attribute has been assigned to it, while the Pen property will be ignored. Please refer to the CustomPlot indicator that comes natively with ArthaChitra for further reference.
Xaml naming conventions
The below user defined Xaml template must have the following suffix:
Xaml Template = Suffix
For BarType, ChartStyle and Indicator, the naming convention will be
<Class name><Script Type>
To add reference to another indicator please use the below method.
When using the default parameter
Code: Select all
public T AddIndicator<T>()
Code: Select all
public T AddIndicator<T>(ISeries<double> input)
Code: Select all
public T AddIndicator<T>(object[] args)
Code: Select all
public T AddIndicator<T>(ISeries<double> input, object[] args)
Code: Select all
Values[0][0] = AddIndicator<SMA>(new object[] { 14 })[0];
Code: Select all
Values[0][0] = AddIndicator<MacD>(new object[]{ 14, 26, 9 }).Avg[0];
[Input Attribute]
A user code (which can be an Indicator or a BarType etc) can have one or more Properties. ArthaChitra, uses these user defined properties internally for various tasks, from comparing two objects or simply to append the display name.
Whether the properties be included or excluded from such evaluation depends if the coder assigns the Input Attribute to that property.
For example if the user has two properties, as below:
Code: Select all
private Pen pen;
[XmlIgnore]
public Pen Pen
{
get { return pen; }
set
{
pen = value;
if (pen.CanFreeze)
{
pen.Freeze();
}
}
}
private double period;
[Input]
public double Period
{
get { return period; }
set
{
period = value;
NotifyPropertyChanged("Period");
}
}
Xaml naming conventions
The below user defined Xaml template must have the following suffix:
Xaml Template = Suffix
For example if you name your market watch template as MyMW, then the Xaml template will have the key as MyMWMarketWatchAlert = Alert
Market Watch = MarketWatch
Time N Sales = TimeNSales
Code: Select all
<DataTemplate x:Key="MyMWMarketWatch">
<!-- design your template here -->
</DataTemplate>
<Class name><Script Type>
For example if you have an Indicator, called HolyGrail, and you have a corresponding Xaml template for it, then the template will be named as HolyGrailIndicatorBar Type = <class name>BarType
Chart Style = <class name>ChartStyle
Indicator = <class name>Indicator
Code: Select all
<DataTemplate x:Key="HolyGrailIndicator">
<!-- design your template here -->
</DataTemplate>