Category Other  Published on 10/10/2020

Building Block: IndiCrossover

Description

 

Comes with source code.

An indicator that monitors two input DataSeries for a crossover.
Designed to be used as a building block in other indicators and cBots.

Inputs:

  • Bullish Series: The bullish dataseries source
  • Bearish Series: The bearish dataseries source

Outputs:

  • Signal: Will be 1 if the bullish and bearish series have crossed within the last bar, zero otherwise.
  • SignalEnv: 1 if the bullish series is above the bearish, -1 if the bearish is above the bullish.
  • DaysSinceLastSignal: The number of bars since the last crossover of the series.

Can be used (for example) in a moving average crossover: setting 5-day MA as the bullish series, and 10-day MA as the bearish series.

When the 5-day crosses the 10-day the “Signal” output gives a value of 1 (0 otherwise), and resets the “Days Since Last Signal” attribute to zero. The SignalEnv is +1 for bullish (ie the 5-day is above the 10-day), and -1 for bearish (5-day is below the 10-day).

A simple MA-crossover strategy would be to trade in the direction of the SignalEnv every time Signal is 1.


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 DirectIndiCross : Indicator
    {

        protected override void Initialize()
        {
            // *** Requires no access rights *** 
            // Visit: https://fxtradersystems.com and search for IndiCrossover
        }

        public override void Calculate(int index)
        {
            Chart.DrawStaticText("Availiability", "Visit: https://fxtradersystems.com and search for IndiCrossover", VerticalAlignment.Bottom, HorizontalAlignment.Left, Color.LawnGreen);
        }
    }
}


fxtradersystems's avatar
fxtradersystems

Joined on 10.09.2020

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: DirectIndiCross.algo
  • Rating: 0
  • Installs: 1261
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.