Price Difference indicator free
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.
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
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; } } }
Comments