Replies

RamboForex
20 Jul 2020, 11:03 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi malleswaramma.ram,

The problem is the scale

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Panagiotis

Yes i was thinking may be scale issue

can we override scale OFF for Willams R so that we can see the both Indicators on the screen?

 

Please suggest the solution.

 


@RamboForex

RamboForex
17 Jul 2020, 10:54

RE:

PanagiotisCharalampous said:

Hi malleswaramma.ram,

Here you go

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("EMA Length")]
        public int EMALength { get; set; }

        [Output("R", LineColor = "Red")]
        public IndicatorDataSeries R { get; set; }

        [Output("G", LineColor = "Green")]
        public IndicatorDataSeries G { get; set; }

        private IndicatorDataSeries ema1 { get; set; }
        private IndicatorDataSeries ema2 { get; set; }
        private IndicatorDataSeries ema3 { get; set; }

        private IndicatorDataSeries _haOpen;
        private IndicatorDataSeries _haClose;

        protected override void Initialize()
        {
            _haOpen = CreateDataSeries();
            _haClose = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...

            var open = Bars.OpenPrices[index];
            var high = Bars.HighPrices[index];
            var low = Bars.LowPrices[index];
            var close = Bars.ClosePrices[index];
            var previousOpen = Bars.OpenPrices[index - 1];
            var previousClose = Bars.ClosePrices[index - 1];


            _haClose[index] = (open + high + low + close) / 4;
            _haOpen[index] = (previousOpen + previousClose) / 2;

            var ema1 = Indicators.ExponentialMovingAverage(_haClose, EMALength);
            var ema2 = Indicators.ExponentialMovingAverage(ema1.Result, EMALength);
            var ema3 = Indicators.ExponentialMovingAverage(ema2.Result, EMALength);
        }
    }
}

Best Regards,

Panagiotis 

Join us on Telegram

Thank you so much Mate for your quick response. it is resolved the issue.

 

Now i understand the the CreateDataSeries needed for any indicator.

 

 


@RamboForex

RamboForex
17 Jul 2020, 10:13

RE:

PanagiotisCharalampous said:

Hi malleswaramma.ram,

If you need professional assistance, you can consider posting a Job or contacting a Consultant.

Best Regards,

Panagiotis 

Join us on Telegram

 

Thank you for suggestion @Panagiotis

I had written almost in C# However bit confused Dataseries of Candles.

 

here is my logic. if you could help me on Dataseries for Pinscript that would solve my problem. rest i can work.

 

 

 [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("EMA Length")]
        public int EMALength { get; set; }

        [Output("R", LineColor = "Red")]
        public IndicatorDataSeries R { get; set; }

        [Output("G", LineColor = "Green")]
        public IndicatorDataSeries G { get; set; }

        private IndicatorDataSeries ema1 { get; set; }
        private IndicatorDataSeries ema2 { get; set; }
        private IndicatorDataSeries ema3 { get; set; }

        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...

            var open = Bars.OpenPrices[index];
            var high = Bars.HighPrices[index];
            var low = Bars.LowPrices[index];
            var close = Bars.ClosePrices[index];
            var previousOpen = Bars.OpenPrices[index - 1];
            var previousClose = Bars.ClosePrices[index - 1];


            var haClose = (open + high + low + close) / 4;
            var haOpen = (previousOpen + previousClose) / 2;

            var ema1= Indicators.ExponentialMovingAverage(haClose, EMALength);
            var ema2 = Indicators.ExponentialMovingAverage(ema1, EMALength);
            var ema3 = Indicators.ExponentialMovingAverage(ema2, EMALength);
        }


@RamboForex