Replies

dokinya
24 Apr 2024, 07:08

RE: INDICATORS NOT LOADING...............

PanagiotisCharalampous said: 

Hi there,

Please share the indicators source code and exact instructions to reproduce the problem.

Best regards,

Panagiotis

all indicators?

is there any where else i can upload the source codes?

 

 


@dokinya

dokinya
17 May 2023, 17:43

RE:

Spotware said:

Dear trader,

Thank you for reporting this issue. Our team is investigating this issue and it will be fixed in an upcoming update.

Best regards,

cTrader Team

when can i expect an update am using 3day chart for day trading.kindly let me know thank you!

regards

dokinya


@dokinya

dokinya
16 Jul 2022, 10:42

RE:

firemyst said:

" am trying to make this cbot open trades exactly on the MA crossing"

This depends on when you define a MA crossing. Right now, your code doesn't check the current bar/candle to see if the MA's crossed. Rather, it checks the previous bar and the bar before that (last(1) and last(2)).

If you want it on the exact tick that it happens, then you need to check the current values of the MA against the previous bar's values. Eg, last(0) and last(1) instead of last(1) and last(2).

Thanks firemyst

i don't know how i missed that, regards it worked if you were a girl i would have kissed you, 

thanks


@dokinya

dokinya
16 Jun 2022, 12:46

RE:

amusleh said:

Hi,

Your indicator code has a bug, you access the Last(1) which means there should be at least two bars inside Bars collection two access the last second one, and if it's the first bar then it throws argument out of range exception.

You should check IsLastBar of Index == 0, try this:

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 DailyPriceLines : Indicator
    {
        private Bars _bars;
        
        [Parameter("High", DefaultValue = true)]
        public bool High { get; set; }

        [Parameter("Low", DefaultValue = true)]
        public bool Low { get; set; }

        [Parameter("Open", DefaultValue = true)]
        public bool Open { get; set; }

        [Parameter("Close", DefaultValue = true)]
        public bool Close { get; set; }

        [Parameter("High Color", DefaultValue = "Red")]
        public string HighColor { get; set; }

        [Parameter("Low Color", DefaultValue = "Lime")]
        public string LowColor { get; set; }

        [Parameter("Open Color", DefaultValue = "Transparent")]
        public string OpenColor { get; set; }

        [Parameter("Close Color", DefaultValue = "Transparent")]
        public string CloseColor { get; set; }



        protected override void Initialize()
        {
            _bars = MarketData.GetBars(TimeFrame.Daily);
        }

        public override void Calculate(int index)
        {
            // This or index == 0 will fix the issue
            if (!IsLastBar) return;
            
            if (High)
                Chart.DrawHorizontalLine("Daily Heigh", _bars.HighPrices.Last(1), HighColor, 1, LineStyle.Dots);

            if (Low)
                Chart.DrawHorizontalLine("Daily Low", _bars.LowPrices.Last(1), LowColor, 1, LineStyle.Dots);

            if (Open)
                Chart.DrawHorizontalLine("Daily Open", _bars.OpenPrices.Last(1), OpenColor, 1, LineStyle.Dots);

            if (Close)
                Chart.DrawHorizontalLine("Daily Close", _bars.ClosePrices.Last(1), CloseColor, 1, LineStyle.Dots);
        }
    }
}

 

Aaaah Aaaah it's working thanks bro you the best thumps up


@dokinya

dokinya
16 Jun 2022, 08:42 ( Updated at: 21 Dec 2023, 09:22 )

RE:

amusleh said:

Hi,

I can't reproduce this issue, can you post again the exact code you are using?

On which symbol and time frame you tested it?

Well i've seen something strange, LOOK

BUT ON 1DAY

 

it's showing on all other timeframe except the 1Day chart which i use for day analysis


@dokinya

dokinya
13 Jun 2022, 13:41 ( Updated at: 21 Dec 2023, 09:22 )

RE:

amusleh said:

Hi,

I just tested on both version 4.1 and 4.2.10 and it works fine:

Does it gets suspended immediately after you attach it or after sometime? which exact version of cTrader 4.2 you are using?

i'd say it's immdiately i attach it to the chart on the current version 4.2.10


@dokinya

dokinya
23 May 2022, 13:50

RE: RE:

dokinya said:

amusleh said:

Hi,

By commenting I mean remove that line of code by making it a comment, ex:

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

namespace cAlgo
{
    [Indicator("Support and Resistance At Price", IsOverlay = true, AccessRights = AccessRights.None)]
    public class SRAtPrice : Indicator
    {
        private double extremeHigh = 0;
        private double extremeLow = 0;
        private double dayHi = 0;
        private double dayLo = 0;
        private SortedList<double, int> prices = new SortedList<double, int>();
        private IList<Zone> zones = new List<Zone>();

        private const string ExtremeHighName = "ExtremeHigh";
        private const string ExtremeLowName = "ExtremeLow";
        private const string DayHighName = "DayHigh";
        private const string DayLowName = "DayLow";

        [Parameter("Periods", DefaultValue = 100)]
        public int Periods { get; set; }

        [Parameter("Show Extreme H/L", DefaultValue = true)]
        public bool ShowExtremeHL { get; set; }

        [Parameter("Show Day H/L", DefaultValue = true)]
        public bool ShowDayHL { get; set; }

        [Parameter("Required Hits", DefaultValue = 0)]
        public int RequiredHits { get; set; }

        [Parameter("Zone Size", DefaultValue = 2)]
        public int ZoneSize { get; set; }

        [Parameter("Max Lines In Zone", DefaultValue = 1)]
        public int MaxLinesInZone { get; set; }

        [Output("Extreme H/L Style", Color = Colors.Red, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries ExtremeHLStyle { get; set; }

        [Output("Day H/L Style", Color = Colors.Blue, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries DayHLStyle { get; set; }

        [Output("S/R Style", Color = Colors.Orange, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries SRStyle { get; set; }

        public override void Calculate(int index)
        {
            if (this.IsLastBar)
            {
                var currentOpenDate = this.MarketSeries.OpenTime[index].Date;
                var earliest = index - this.Periods;
                for (var i = index; i >= earliest; i--)
                {
                    if (i >= 0)
                    {
                        var high = this.MarketSeries.High[i];
                        var nextHigh = this.MarketSeries.High[i + 1];
                        var low = this.MarketSeries.Low[i];
                        var nextLow = this.MarketSeries.Low[i + 1];
                        this.extremeHigh = Math.Max(high, this.extremeHigh);
                        this.extremeLow = this.extremeLow == 0 ? low : Math.Min(low, this.extremeLow);

                        if (this.TimeFrame < TimeFrame.Minute)
                        {
                            if (this.MarketSeries.OpenTime[i].Date == currentOpenDate)
                            {
                                this.dayHi = Math.Max(high, this.dayHi);
                                this.dayLo = this.dayLo == 0 ? low : Math.Min(low, this.dayLo);
                            }
                        }

                        if (nextHigh <= high)
                        {
                            this.AddOrUpdatePrice(high);
                        }

                        if (nextLow >= low)
                        {
                            this.AddOrUpdatePrice(low);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                this.zones.Clear();
                var rangePipSize = (this.Symbol.PipSize * (double)this.ZoneSize);
                for (var i = this.extremeLow + rangePipSize; i < this.extremeHigh - rangePipSize; i += rangePipSize + this.Symbol.PipSize)
                {
                    this.zones.Add(new Zone 
                    {
                        Start = i,
                        End = i + rangePipSize,
                        LinesRendered = 0
                    });
                }

                //this.ChartObjects.RemoveAllObjects();

                foreach (var price in this.prices.Keys)
                {
                    this.RenderSRIfRequred(price, this.prices[price]);
                }

                if (this.ShowExtremeHL)
                {
                    this.DrawExtremeHigh();
                    this.DrawExtremeLow();
                }

                if (this.TimeFrame < TimeFrame.Minute && this.ShowDayHL)
                {
                    this.DrawDayHigh();
                    this.DrawDayLow();
                }
            }
        }

        private void RenderSRIfRequred(double price, int count)
        {
            if (count < this.RequiredHits)
            {
                return;
            }

            foreach (var range in this.zones)
            {
                if (price >= range.Start && price <= range.End)
                {
                    if (range.LinesRendered != this.MaxLinesInZone)
                    {
                        range.LinesRendered++;
                        this.DrawSR(price);
                    }
                    return;
                }
            }
        }

        private void AddOrUpdatePrice(double priceValue)
        {
            if (this.prices.ContainsKey(priceValue))
            {
                this.prices[priceValue]++;
            }
            else
            {
                this.prices.Add(priceValue, 1);
            }
        }

        private void DrawExtremeHigh()
        {
            this.DrawExtreme(ExtremeHighName, this.extremeHigh);
        }

        private void DrawExtremeLow()
        {
            this.DrawExtreme(ExtremeLowName, this.extremeLow);
        }

        private void DrawDayHigh()
        {
            this.DrawDay(DayHighName, this.dayHi);
        }

        private void DrawDayLow()
        {
            this.DrawDay(DayLowName, this.dayLo);
        }

        private void DrawExtreme(string name, double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("ExtremeHLStyle");
            this.ChartObjects.DrawHorizontalLine(name, level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private void DrawDay(string name, double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("DayHLStyle");
            this.ChartObjects.DrawHorizontalLine(name, level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private void DrawSR(double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("SRStyle");
            this.ChartObjects.DrawHorizontalLine(string.Format("SR {0}", level), level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private T GetAttributeFrom<T>(string propertyName)
        {
            var attrType = typeof(T);
            var property = this.GetType().GetProperty(propertyName);
            return (T)property.GetCustomAttributes(attrType, false).GetValue(0);
        }

        private class Price
        {
            internal double Value { get; set; }
            internal int Count { get; set; }
        }

        private class Zone
        {
            internal double Start { get; set; }
            internal double End { get; set; }
            internal int LinesRendered { get; set; }
        }
    }
}

it's good thanks 

i thought this issue was sorted but i've just realized it was not... the indicator won't update it's stuck, and in some timeframe it's not showing, but when i delete it

it shows's and stay stuck.

 


@dokinya

dokinya
20 May 2022, 10:00

RE:

amusleh said:

Hi,

By commenting I mean remove that line of code by making it a comment, ex:

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

namespace cAlgo
{
    [Indicator("Support and Resistance At Price", IsOverlay = true, AccessRights = AccessRights.None)]
    public class SRAtPrice : Indicator
    {
        private double extremeHigh = 0;
        private double extremeLow = 0;
        private double dayHi = 0;
        private double dayLo = 0;
        private SortedList<double, int> prices = new SortedList<double, int>();
        private IList<Zone> zones = new List<Zone>();

        private const string ExtremeHighName = "ExtremeHigh";
        private const string ExtremeLowName = "ExtremeLow";
        private const string DayHighName = "DayHigh";
        private const string DayLowName = "DayLow";

        [Parameter("Periods", DefaultValue = 100)]
        public int Periods { get; set; }

        [Parameter("Show Extreme H/L", DefaultValue = true)]
        public bool ShowExtremeHL { get; set; }

        [Parameter("Show Day H/L", DefaultValue = true)]
        public bool ShowDayHL { get; set; }

        [Parameter("Required Hits", DefaultValue = 0)]
        public int RequiredHits { get; set; }

        [Parameter("Zone Size", DefaultValue = 2)]
        public int ZoneSize { get; set; }

        [Parameter("Max Lines In Zone", DefaultValue = 1)]
        public int MaxLinesInZone { get; set; }

        [Output("Extreme H/L Style", Color = Colors.Red, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries ExtremeHLStyle { get; set; }

        [Output("Day H/L Style", Color = Colors.Blue, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries DayHLStyle { get; set; }

        [Output("S/R Style", Color = Colors.Orange, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries SRStyle { get; set; }

        public override void Calculate(int index)
        {
            if (this.IsLastBar)
            {
                var currentOpenDate = this.MarketSeries.OpenTime[index].Date;
                var earliest = index - this.Periods;
                for (var i = index; i >= earliest; i--)
                {
                    if (i >= 0)
                    {
                        var high = this.MarketSeries.High[i];
                        var nextHigh = this.MarketSeries.High[i + 1];
                        var low = this.MarketSeries.Low[i];
                        var nextLow = this.MarketSeries.Low[i + 1];
                        this.extremeHigh = Math.Max(high, this.extremeHigh);
                        this.extremeLow = this.extremeLow == 0 ? low : Math.Min(low, this.extremeLow);

                        if (this.TimeFrame < TimeFrame.Minute)
                        {
                            if (this.MarketSeries.OpenTime[i].Date == currentOpenDate)
                            {
                                this.dayHi = Math.Max(high, this.dayHi);
                                this.dayLo = this.dayLo == 0 ? low : Math.Min(low, this.dayLo);
                            }
                        }

                        if (nextHigh <= high)
                        {
                            this.AddOrUpdatePrice(high);
                        }

                        if (nextLow >= low)
                        {
                            this.AddOrUpdatePrice(low);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                this.zones.Clear();
                var rangePipSize = (this.Symbol.PipSize * (double)this.ZoneSize);
                for (var i = this.extremeLow + rangePipSize; i < this.extremeHigh - rangePipSize; i += rangePipSize + this.Symbol.PipSize)
                {
                    this.zones.Add(new Zone 
                    {
                        Start = i,
                        End = i + rangePipSize,
                        LinesRendered = 0
                    });
                }

                //this.ChartObjects.RemoveAllObjects();

                foreach (var price in this.prices.Keys)
                {
                    this.RenderSRIfRequred(price, this.prices[price]);
                }

                if (this.ShowExtremeHL)
                {
                    this.DrawExtremeHigh();
                    this.DrawExtremeLow();
                }

                if (this.TimeFrame < TimeFrame.Minute && this.ShowDayHL)
                {
                    this.DrawDayHigh();
                    this.DrawDayLow();
                }
            }
        }

        private void RenderSRIfRequred(double price, int count)
        {
            if (count < this.RequiredHits)
            {
                return;
            }

            foreach (var range in this.zones)
            {
                if (price >= range.Start && price <= range.End)
                {
                    if (range.LinesRendered != this.MaxLinesInZone)
                    {
                        range.LinesRendered++;
                        this.DrawSR(price);
                    }
                    return;
                }
            }
        }

        private void AddOrUpdatePrice(double priceValue)
        {
            if (this.prices.ContainsKey(priceValue))
            {
                this.prices[priceValue]++;
            }
            else
            {
                this.prices.Add(priceValue, 1);
            }
        }

        private void DrawExtremeHigh()
        {
            this.DrawExtreme(ExtremeHighName, this.extremeHigh);
        }

        private void DrawExtremeLow()
        {
            this.DrawExtreme(ExtremeLowName, this.extremeLow);
        }

        private void DrawDayHigh()
        {
            this.DrawDay(DayHighName, this.dayHi);
        }

        private void DrawDayLow()
        {
            this.DrawDay(DayLowName, this.dayLo);
        }

        private void DrawExtreme(string name, double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("ExtremeHLStyle");
            this.ChartObjects.DrawHorizontalLine(name, level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private void DrawDay(string name, double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("DayHLStyle");
            this.ChartObjects.DrawHorizontalLine(name, level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private void DrawSR(double level)
        {
            var attribute = this.GetAttributeFrom<OutputAttribute>("SRStyle");
            this.ChartObjects.DrawHorizontalLine(string.Format("SR {0}", level), level, attribute.Color, attribute.Thickness, attribute.LineStyle);
        }

        private T GetAttributeFrom<T>(string propertyName)
        {
            var attrType = typeof(T);
            var property = this.GetType().GetProperty(propertyName);
            return (T)property.GetCustomAttributes(attrType, false).GetValue(0);
        }

        private class Price
        {
            internal double Value { get; set; }
            internal int Count { get; set; }
        }

        private class Zone
        {
            internal double Start { get; set; }
            internal double End { get; set; }
            internal int LinesRendered { get; set; }
        }
    }
}

it's good thanks 

 


@dokinya

dokinya
19 May 2022, 19:10 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE: RE: downgrade

amusleh said:

dokinya said:

amusleh said:

Hi,

We were able to reproduce the issue with your indicator, we are investigating now what's causing it, please be patient and wait for our reply.

 

is there anyway i can downgrade the platform? 

Hi,

There is no way to downgrade, for this particular indicator you can comment the "this.ChartObjects.RemoveAllObjects();" line and it will work on version 4.2.

isn't this the same thing already on the indicator or where am i supposed to comment that?


@dokinya

dokinya
19 May 2022, 14:12

RE: downgrade

amusleh said:

Hi,

We were able to reproduce the issue with your indicator, we are investigating now what's causing it, please be patient and wait for our reply.

 

is there anyway i can downgrade the platform? 


@dokinya