Description
Follow my cTrader Telegram group at https://t.me/cTraderCommunity; it's a new community but it will grow fast, plus everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them.
This simple indicator when applied to an oscillator, or any DataSeries, will show with colors when this is rising or falling.
Useful to add a visual effect and for backtesting.
Feel free to point out bugs or possible improvements in the comments or in the group linked above
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class OscRisingFalling : Indicator
{
[Parameter()]
public DataSeries source { get; set; }
[Parameter("N° Of Points", DefaultValue = 3)]
public int n_points { get; set; }
[Output("Up", Color = Colors.Green, Thickness = 2, PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries Up { get; set; }
[Output("Down", Color = Colors.Red, Thickness = 2, PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries Down { get; set; }
protected override void Initialize()
{
}
public override void Calculate(int index)
{
Up[index] = double.NaN;
Down[index] = double.NaN;
bool up = true;
bool down = true;
for (int i = 0; i < n_points; i++)
{
if (source[index - i] >= source[index - i - 1])
down = false;
if (source[index - i] <= source[index - i - 1])
up = false;
}
if (up)
Up[index] = source[index];
if (down)
Down[index] = source[index];
}
}
}
CY
cysecsbin.01
Joined on 10.11.2018 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Osc Rising Falling.algo
- Rating: 5
- Installs: 2205
- Modified: 13/10/2021 09:54
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
Please make the Absolute Strength Oscillator trend-following indicator. This is based on the forces of bulls and bears. Thanks in advance.