Description
This program is a custom indicator for the cAlgo trading platform, used for developing trading robots and technical indicators for cTrader. The indicator is called "BaselinePower" and is used to plot three moving average lines on a price chart, allowing traders to visualize trends and make informed trading decisions.
Here is a detailed description of the program's features and functionality:
Parameters
The program defines several user-configurable parameters:
- Period: The period of the first moving average (default 9).
- Ma Type: The type of moving average for the first period (default Weighted).
- Period Signal: The period of the second moving average (default 9).
- Ma Type: The type of moving average for the second period (default Weighted).
- Period Signal2: The period of the third moving average (default 9).
- Ma Type: The type of moving average for the third period (default Weighted).
Outputs
The program defines three output data series:
- Result: The value of the first moving average.
- Signal: The value of the second moving average.
- Signal2: The value of the third moving average.
These outputs are plotted as lines on the chart, with specific colors and thicknesses:
- Result: green line (Lime)
- Signal: red line (Red)
- Signal2: golden line (Gold)
Initialization
In the Initialize
method, the program initializes three moving average objects:
ma
: The first moving average calculated on the closing prices with the specified period and type.signal
: The second moving average calculated on the results of the first moving average.signal2
: The third moving average calculated on the results of the second moving average.
Calculation
In the Calculate
method, the program updates the values of the output data series for each index on the chart:
- The value of
Result
is updated with the value of the first moving average. - The value of
Signal
is updated with the value of the second moving average. - The value of
Signal2
is updated with the value of the third moving average.
Usage
This program can be used by traders to:
- Track market trends using multiple moving averages.
- Identify buy or sell signals when the moving averages cross.
- Visualize price dynamics over different periods.
In summary, the "BaselinePower" indicator is a powerful tool for traders who want to analyze price trends using multiple moving averages, offering a clear and configurable visualization directly on the trading chart.
Reference indicator here : https://ctrader.com/algos/indicators/show/4407/
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
{
[Cloud("Result", "Signal", FirstColor = "Lime", SecondColor = "Red", Opacity = 0.15)]
[Cloud("Result", "Signal2", FirstColor = "Lime", SecondColor = "Red", Opacity = 0.15)]
[Cloud("Signal", "Signal2", FirstColor = "Lime", SecondColor = "Red", Opacity = 0.15)]
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class BaselinePowerTF : Indicator
{
[Parameter("TimeFrame", DefaultValue = "Daily", Group = "Calculation Type")]
public TimeFrame TF1 { get; set; }
[Parameter("Period", DefaultValue = 5, Group = "Calculation Ma")]
public int Period { get; set; }
[Parameter("Ma Type", DefaultValue = MovingAverageType.Weighted, Group = "Calculation Ma")]
public MovingAverageType MaTypePeriod { get; set; }
[Parameter("Period Signal", DefaultValue = 5, Group = "Calculation Ma")]
public int PeriodSignal { get; set; }
[Parameter("Ma Type", DefaultValue = MovingAverageType.Weighted, Group = "Calculation Ma")]
public MovingAverageType MaTypePeriodSignal { get; set; }
[Parameter("Period Signal2", DefaultValue = 5, Group = "Calculation Ma")]
public int PeriodSignal2 { get; set; }
[Parameter("Ma Type", DefaultValue = MovingAverageType.Weighted, Group = "Calculation Ma")]
public MovingAverageType MaTypePeriodSignal2 { get; set; }
[Output("Result", PlotType = PlotType.Line, LineColor = "Lime", Thickness = 1)]
public IndicatorDataSeries Result { get; set; }
[Output("Signal", PlotType = PlotType.Line, LineColor = "Gold", Thickness = 1)]
public IndicatorDataSeries Signal { get; set; }
[Output("Signal2", PlotType = PlotType.Line, LineColor = "Red", Thickness = 1)]
public IndicatorDataSeries Signal2 { get; set; }
private BaselinePower ma;
private Bars bars1;
protected override void Initialize()
{
bars1 = MarketData.GetBars(TF1);
if (!IsBacktesting)
{
while (bars1.OpenTimes[0] > Bars.OpenTimes[0])
bars1.LoadMoreHistory();
}
ma = Indicators.GetIndicator<BaselinePower>(bars1, Period, MaTypePeriod, PeriodSignal, MaTypePeriodSignal, PeriodSignal2, MaTypePeriodSignal2);
}
public override void Calculate(int index)
{
int idx1 = TF1 == Chart.TimeFrame ? index : bars1.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
Result[index] = ma.Result[idx1];
Signal[index] = ma.Signal[idx1];
Signal2[index] = ma.Signal2[idx1];
}
}
}
YesOrNot2
Joined on 17.05.2024
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: BaselinePowerTF.algo
- Rating: 5
- Installs: 390
- Modified: 29/07/2024 13:07
Thank you!