Topics

Forum Topics not found

Replies

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