Description
PDI (Price Difference) is a simple signal indicator of the price difference between the previous and the current bars. It displays as signal marks the candlesticks, on which the previous Applied price is higher than the current one by the pre-defined Price difference. If the price difference is positive, the mark will be placed on the Low price of the current candlesticks. If it is negative - on the High price.
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class mPDI : Indicator
{
[Parameter("Difference (100)", DefaultValue = 100)]
public int inpDifference { get; set; }
[Parameter("Data Source", DefaultValue = "Close")]
public DataSeries inpDataSource { get; set; }
[Output("PDI Up", LineColor = "Red", PlotType = PlotType.Points, Thickness = 5)]
public IndicatorDataSeries outUp { get; set; }
[Output("PDI Down", LineColor = "Green", PlotType = PlotType.Points, Thickness = 5)]
public IndicatorDataSeries outDn { get; set; }
private MovingAverage _ma;
private double diff;
protected override void Initialize()
{
_ma = Indicators.MovingAverage(inpDataSource, 1, MovingAverageType.Simple);
diff = inpDifference * Symbol.PipSize;
}
public override void Calculate(int i)
{
outUp[i] = i>1 && _ma.Result[i]-_ma.Result[i-1] > diff ? Bars.LowPrices[i] : double.NaN;
outDn[i] = i>1 && _ma.Result[i]-_ma.Result[i-1] < -diff ? Bars.HighPrices[i] : double.NaN;
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mPDI.algo
- Rating: 5
- Installs: 925
- Modified: 25/01/2023 21:36
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.
The Price Rate of Change (ROC) is a momentum-based technical indicator that measures the percentage change in price between the current price and the price a certain number of periods ago, also you can get it on aurora store