cAlgo.Lib Error

Created at 12 Aug 2021, 13:05
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
WM

wmclennan77

Joined 29.06.2021

cAlgo.Lib Error
12 Aug 2021, 13:05


Hi all,

 

I have a custom indicator that I got from the forums that I would like to test out.

On compiling, I receive the following error:

Error CS0234: The type or namespace name 'Lib' does not exist in the namespace 'cAlgo' (are you missing an assembly reference?)

Source for clarification:

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Lib;


namespace cAlgo.Indicators
{
    [Indicator(TimeZone = TimeZones.UTC, IsOverlay = false, AccessRights = AccessRights.None)]
    [Levels(-5, -3, -2, -1, -0.75, -0.5, -0.25, 0, 0.25, 0.5,
    0.75, 1, 2, 3, 5)]
    public class VelocityIndicator : Indicator
    {
        #region cIndicators Parameters

        [Parameter("Number Of Candle", DefaultValue = 5, MinValue = 1)]
        public int NumberOfCandle { get; set; }

        [Parameter("Moving Average", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MovingAverageType { get; set; }

        [Parameter("MA Period", DefaultValue = 14, MinValue = 2)]
        public int Period { get; set; }

        [Output("High Acceleration", Color = Colors.Green, Thickness = 1)]
        public IndicatorDataSeries HighAccelerationSeries { get; set; }

        [Output("Low Acceleration", Color = Colors.Red, Thickness = 1)]
        public IndicatorDataSeries LowAccelerationSeries { get; set; }

        [Output("Moving Average", Color = Colors.Blue, Thickness = 2)]
        public IndicatorDataSeries MovingAverageSeries { get; set; }

        #endregion

        MovingAverage _movingAverage;
        double _elapsedTime;

        protected override void Initialize()
        {
            _movingAverage = Indicators.MovingAverage(HighAccelerationSeries, Period, MovingAverageType);

            long elapsedTicks = (long)Math.Ceiling((NumberOfCandle + 0.5) * MarketSeries.TimeFrame.ToTimeSpan().Ticks);
            TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);
            _elapsedTime = elapsedSpan.TotalSeconds;
        }

        /// <summary>
        /// S = S0 + V0t +(at^2)/2   a = (2*(S-S0))/t^2.
        /// v = v0 +at
        /// </summary>
        /// <param name="index"></param>
        public override void Calculate(int index)
        {
            double high = MarketSeries.High[index];
            double previewHigh = MarketSeries.High[index - NumberOfCandle];
            double actualPriceOrHigh = (MarketSeries.Bars() - 1) == index ? Symbol.Mid() : high;

            double low = MarketSeries.Low[index];
            double previewLow = MarketSeries.Low[index - NumberOfCandle];
            double actualPriceOrLow = (MarketSeries.Bars() - 1) == index ? Symbol.Mid() : low;

            double highAcceleration = (2 * (high - previewHigh) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits);
            double lowAcceleration = (2 * (low - previewLow) / Math.Pow(_elapsedTime, 2)) * Math.Pow(10, 2 * Symbol.Digits);

            HighAccelerationSeries[index] = highAcceleration;
            LowAccelerationSeries[index] = lowAcceleration;
            MovingAverageSeries[index] = _movingAverage.Result[index];


            // Print("{0} {1} {2} {3} {4}",highAcceleration, lowAcceleration, elapsedTime, MarketSeries.Bars()-1, index);

        }
    }
}

Any  help would be appreciated, thanks.


@wmclennan77
Replies

amusleh
12 Aug 2021, 20:23

Hi,

cAlgo.Lib is an external library this is referenced by this indicator, you have to add a reference to cAlgo.Lib.dll file.

cAlgo.Lib is not part of Automate API, you have to find that library file and add a reference to it on your indicator project.


@amusleh