Bid/Ask Custom Indicator
31 May 2019, 19:04
I had this indicator (found here: https://ctrader.com/algos/indicators/show/1167#comment-5309 ) But It seems like it is no longer available for download? Also the copy I had no longer works with the newest update to cTrader :\ Any suggestions? Thanks

PanagiotisCharalampous
03 Jun 2019, 10:29
Hi Matt,
The code below should work on the latest version of cTrader
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 BidAsk : Indicator { [Parameter("To Infinite", DefaultValue = true)] public bool ToInfinite { get; set; } [Parameter(DefaultValue = 0)] public int Displacement { get; set; } [Output("Ask", Color = Colors.DodgerBlue, PlotType = PlotType.DiscontinuousLine)] public IndicatorDataSeries SymbolAsk { get; set; } [Output("Bid", Color = Colors.Red, PlotType = PlotType.DiscontinuousLine)] public IndicatorDataSeries SymbolBid { get; set; } protected override void Initialize() { // Initialize and create nested indicators } public override void Calculate(int index) { if (!IsLastBar) return; SymbolBid[index + Displacement - 1] = double.NaN; SymbolAsk[index + Displacement - 1] = double.NaN; for (int i = ToInfinite ? -MarketSeries.Close.Count : Displacement; i < 200; i++) { SymbolBid[index + i] = Symbol.Ask; SymbolAsk[index + i] = Symbol.Bid; } } } }Best Regards,
Panagiotis
@PanagiotisCharalampous