PineScript to Ctrader Indicator

Created at 16 Jul 2020, 16:37
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!
RamboForex's avatar

RamboForex

Joined 03.11.2019

PineScript to Ctrader Indicator
16 Jul 2020, 16:37


Hi All,

 

I planning to create new indicator with below logic.

 

1. DataSeries i could not have source =ohlc4   only available high,open,low, close

src=ohlc4
haOpen = (src + nz(haOpen[1]))/2
haC=(ohlc4+haOpen+max(high,haOpen)+min(low,haOpen))/4

 

If i want to use this code to create indicator, can we convert below pinescript code to CTrader?


EMA1=ema(haC,EMAlength)
EMA2=ema(EMA1,EMAlength)
EMA3=ema(EMA2,EMAlength)

 

Kindly please help me on conversion of this code. 

 


@RamboForex
Replies

PanagiotisCharalampous
16 Jul 2020, 16:44

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

 


@PanagiotisCharalampous

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

PanagiotisCharalampous
17 Jul 2020, 10:22

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


@PanagiotisCharalampous

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

... Deleted by UFO ...

selva.note3
08 Mar 2024, 14:10 ( Updated at: 09 Mar 2024, 07:12 )

RE: PineScript to Ctrader Indicator

Dear PanagiotisCharalampous

 

I would like to request 2 indicators code to be converted to CTrader, Its really a good one which draws order blocks, Choch and FVG its really useful if you do this for me. if you can do that please reply i will DM the codes

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

 


@selva.note3

PanagiotisCharalampous
11 Mar 2024, 07:45

RE: RE: PineScript to Ctrader Indicator

selva.note3 said: 

Dear PanagiotisCharalampous

 

I would like to request 2 indicators code to be converted to CTrader, Its really a good one which draws order blocks, Choch and FVG its really useful if you do this for me. if you can do that please reply i will DM the codes

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

 

Hi there,

If you need a quote for the conversion, contact me at development@clickalgo.com


@PanagiotisCharalampous