Description
The indicator result, is calculated from FIR (Finite Impulse Response Filter) indicator and price levels
Use histogram as short term trend and dots (green and red) as open position trigger.
For more information about FIR indicator click here
//this indicator is used as short term trend confirmation
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Levels(0)]
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mFIRslope : Indicator
{
[Output("FIR - Finite Impulse Response Filter", IsHistogram =true, LineColor = "Magenta", PlotType = PlotType.Histogram, Thickness = 2)]
public IndicatorDataSeries outFIRslope { get; set; }
[Output("OpenLong trigger", LineColor = "Green", PlotType = PlotType.Points, Thickness = 5)]
public IndicatorDataSeries outLongOpen { get; set; }
[Output("OpenShort trigger", LineColor = "Red", PlotType = PlotType.Points, Thickness = 5)]
public IndicatorDataSeries outShortOpen { get; set; }
private IndicatorDataSeries _price, _fir;
protected override void Initialize()
{
_price = CreateDataSeries();
_fir = CreateDataSeries();
}
public override void Calculate(int i)
{
_price[i] = Bars.ClosePrices[i];
_fir[i] =i>3 ? (_price[i] + 2.0 * _price[i - 1] + 2.0 * _price[i - 2] + _price[i - 3]) / 6.0 : Bars.ClosePrices[i];
outFIRslope[i] = 0;
if(i>3 && _fir[i] > _fir[i-1] )
outFIRslope[i] = +0.5;
if(i>3 && _fir[i] < _fir[i-1] )
outFIRslope[i] = -0.5;
if(i>3 && _fir[i] > _fir[i-1] && Bars.ClosePrices[i] > _fir[i])
outFIRslope[i] = +1.0;
if(i>3 && _fir[i] < _fir[i-1] && Bars.ClosePrices[i] < _fir[i])
outFIRslope[i] = -1.0;
outLongOpen[i] = outShortOpen[i] = double.NaN;
if(i>3 && _fir[i] > _fir[i-1] && Bars.ClosePrices[i] > _fir[i] && Bars.LowPrices[i] < Bars.LowPrices[i-1])
outLongOpen[i] = +1.0;
if(i>3 && _fir[i] < _fir[i-1] && Bars.ClosePrices[i] < _fir[i] && Bars.HighPrices[i] > Bars.HighPrices[i-1])
outShortOpen[i] = -1.0;
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mFIRslope.algo
- Rating: 5
- Installs: 747
- Modified: 12/01/2023 22:07
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.
No comments found.