Category Trend  Published on 28/08/2024

CSTP Indicators 1 Parametter

Description

This indicator is specifically designed to be used in the trading bot cTrader Strategy Tester v1.12. (https://ctrader.com/algos/cbots/show/4487/)

Here’s a simple description of its functionality and its importance:

Code Description

Declaration and Parameters:

  • The code defines an indicator called CSTP_Indi_1Parametter, allowing the user to choose from various types of trend indicators. The user can select the desired indicator through the IndicatorSelection parameter.
  • Another parameter, Period, determines the period over which the selected indicator will be calculated.

Indicator Enumeration:

  • An enumeration (EnumIndiSelection) is defined, listing different types of indicators such as moving averages (exponential, simple, etc.), Donchian Channel, linear regression, Aroon, and ADXR.

Indicator Calculations:

  • The Calculate(int index) method is the core of the code, executed for each new data point (each new bar). Depending on the selected indicator, it calculates the values for Result (usually closing prices) and Signal (the calculated indicator value).

Result Display:

  • The results of these calculations are plotted on the chart as two lines (Result and Signal), with specified colors and styles.

Importance for the cTrader Strategy Tester v1.12 Bot

This code is essential for the cTrader Strategy Tester v1.12 bot. It allows the bot to test and optimize various trading strategies using different types of technical indicators. With this code, the bot can dynamically select and calculate the most relevant indicators for the strategy being evaluated, making it adaptable to different market conditions.
 

Telegram group : https://t.me/cTraderStrategyTesterProject

GitHub : https://github.com/YesOrNotCtrader/Ctrader-Stragegy-Tester-Project

Enjoy for Free =) 
Previous account here : https://ctrader.com/users/profile/70920
Contact telegram :  https://t.me/nimi012 

 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class CSTP_Indi_1Parametter : Indicator
    {
        [Parameter(DefaultValue = EnumIndiSelection.Exponetial_Moving_Average)]
        public EnumIndiSelection IndicatorSelection { get; set; }
        public enum EnumIndiSelection
        {
            Exponetial_Moving_Average,
            Hull_Moving_Average,
            Simple_Moving_Average,
            TimesSeries_Moving_Average,
            Triangular_Moving_Average,
            VIDYA_Moving_Average,
            Weigthed_Moving_Average,
            WilderSmoothing_Moving_Average,
            Donchian_Middle,
            Linear_Regression_Intercept,
            Linear_Regression_Forecast,
            Aroon,
            Adxr,
        }

        [Parameter(DefaultValue = 13)]
        public int Period { get; set; }

        [Output("Result", IsHistogram = false, LineColor = "Green", LineStyle = LineStyle.Solid, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Result { get; set; }
        [Output("Signal", IsHistogram = false, LineColor = "Red", LineStyle = LineStyle.Solid, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Signal { get; set; }

        protected override void Initialize()
        {

        }
        public override void Calculate(int index)
        {
            switch (IndicatorSelection)
            {
                case (EnumIndiSelection.Exponetial_Moving_Average):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.Exponential).Result[index];
                    break;
                case (EnumIndiSelection.Hull_Moving_Average):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.Hull).Result[index];
                    break;
                case (EnumIndiSelection.Simple_Moving_Average):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.Simple).Result[index];
                    break;
                case (EnumIndiSelection.TimesSeries_Moving_Average):
                    Result[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.TimeSeries).Result[index];
                    Signal[index] = Bars.ClosePrices[index];
                    break;
                case (EnumIndiSelection.Triangular_Moving_Average):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.Triangular).Result[index];
                    break;
                case (EnumIndiSelection.VIDYA_Moving_Average):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.VIDYA).Result[index];
                    break;
                case (EnumIndiSelection.Weigthed_Moving_Average):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.Weighted).Result[index];
                    break;
                case (EnumIndiSelection.WilderSmoothing_Moving_Average):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.MovingAverage(Bars.ClosePrices, Period, MovingAverageType.WilderSmoothing).Result[index];
                    break;
                case (EnumIndiSelection.Donchian_Middle):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.DonchianChannel(Period).Middle[index];
                    break;
                case (EnumIndiSelection.Linear_Regression_Intercept):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.LinearRegressionIntercept(Bars.ClosePrices, Period).Result[index];
                    break;
                case (EnumIndiSelection.Linear_Regression_Forecast):
                    Result[index] = Bars.ClosePrices[index];
                    Signal[index] = Indicators.LinearRegressionForecast(Bars.ClosePrices, Period).Result[index];
                    break;
                case (EnumIndiSelection.Aroon):
                    Result[index] = Indicators.Aroon(Period).Up[index];
                    Signal[index] = Indicators.Aroon(Period).Down[index];
                    break;
                case (EnumIndiSelection.Adxr):
                    Result[index] = Indicators.AverageDirectionalMovementIndexRating(Period).DIPlus[index];
                    Signal[index] = Indicators.AverageDirectionalMovementIndexRating(Period).DIMinus[index];

                    break;
            }

        }
    }
}


YE
YesOrNot2

Joined on 17.05.2024

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: CSTP_Indi_1Parametter.algo
  • Rating: 0
  • Installs: 290
  • Modified: 28/08/2024 15:17
Comments
Log in to add a comment.
No comments found.