SharpScript coding conventions

SharpScript development
Post Reply
AC_Sourav
Posts: 25
Joined: Sat Mar 28, 2015 9:15 pm

SharpScript coding conventions

Post by AC_Sourav »

Add reference to an Indicator

To add reference to another indicator please use the below method.

When using the default parameter

Code: Select all

public T AddIndicator<T>()
Using the default parameters but specifying the input

Code: Select all

public T AddIndicator<T>(ISeries<double> input)
When specifying the parameters

Code: Select all

public T AddIndicator<T>(object[] args)
when specifying both the input series and the parameters

Code: Select all

public T AddIndicator<T>(ISeries<double> input, object[] args)
e.g. reference the SMA

Code: Select all

Values[0][0] = AddIndicator<SMA>(new object[] { 14 })[0];
e.g. If you want to call reference the Avg series of the MacD indicator

Code: Select all

Values[0][0] = AddIndicator<MacD>(new object[]{ 14, 26, 9 }).Avg[0]; 
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:

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");
            }
        }
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
Alert = Alert
Market Watch = MarketWatch
Time N Sales = TimeNSales
For example if you name your market watch template as MyMW, then the Xaml template will have the key as MyMWMarketWatch

Code: Select all

<DataTemplate x:Key="MyMWMarketWatch">
  <!-- design your template here -->
</DataTemplate>
For BarType, ChartStyle and Indicator, the naming convention will be
<Class name><Script Type>
Bar Type = <class name>BarType
Chart Style = <class name>ChartStyle
Indicator = <class name>Indicator
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 HolyGrailIndicator

Code: Select all

<DataTemplate x:Key="HolyGrailIndicator">
     <!-- design your template here -->
</DataTemplate>
Post Reply