Topics

Forum Topics not found

Replies

amusleh
31 Dec 2021, 11:55 ( Updated at: 31 Dec 2021, 11:56 )

Hi,

I added line style:

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class RoundNumbers : Indicator
    {
        [Parameter("Line Color", DefaultValue = "Blue")]
        public string LineColor { get; set; }

        [Parameter("Color", DefaultValue = 255, MinValue = 0, MaxValue = 255)]
        public int ColorAlpha { get; set; }

        [Parameter("Style", DefaultValue = LineStyle.Dots)]
        public LineStyle Style { get; set; }
        
        [Parameter(DefaultValue = 100)]
        public int StepPips { get; set; }

        protected override void Initialize()
        {
            double max = Bars.HighPrices.Maximum(Bars.HighPrices.Count);

            double min = Bars.LowPrices.Minimum(Bars.LowPrices.Count);

            double step = Symbol.PipSize * StepPips;

            double start = Math.Floor(min / step) * step;

            var color = GetColor(LineColor, ColorAlpha);

            for (double level = start; level <= max + step; level += step)
            {
                Chart.DrawHorizontalLine("line_" + level, level, color, 1, Style);
            }
        }

        public override void Calculate(int index)
        {
        }

        private Color GetColor(string colorString, int alpha = 255)
        {
            var color = colorString[0] == '#' ? Color.FromHex(colorString) : Color.FromName(colorString);

            return Color.FromArgb(alpha, color);
        }
    }
}

 


@amusleh

amusleh
31 Dec 2021, 08:51

Hi,

Please create a thread for this under forum suggestions section.


@amusleh

amusleh
31 Dec 2021, 08:50

Hi,

You can't use that data in Automate API so no there is no cBot that uses those data.


@amusleh

amusleh
31 Dec 2021, 08:48

Hi,

You can't use the bar counter on chart from Automate API, and there is no need for it.

You can easily code one, each bar has an open time and if you know the time frame you can subtract the bar open time from current time, ex:

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        private TimeSpan _barTimeLeft;

        protected override void OnStart()
        {
            Timer.Start(1);
        }
        
        protected override void OnTimer()
        {
            var previousBarTimePeriod = Bars.LastBar.OpenTime - Bars.Last(1).OpenTime;

            _barTimeLeft = previousBarTimePeriod - (Server.Time - Bars.LastBar.OpenTime);
            
            // Check logs, it should match with chart counter
            Print("{0:hh':'mm':'ss}", _barTimeLeft);

            // Close all positions if the time left is less than or equal 10 seconds
            if (_barTimeLeft.TotalSeconds <= 10)
            {
                foreach (var position in Positions)
                {
                    ClosePosition(position);
                }
            }
        }
    }
}

 


@amusleh

amusleh
31 Dec 2021, 07:25

Hi,

Please follow this instruction: Creating an Indicator | cTrader Help Center


@amusleh

amusleh
30 Dec 2021, 15:45

Hi,

Try this:

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class RoundNumbers : Indicator
    {
        [Parameter("Line Color", DefaultValue = "Gray")]
        public string LineColor { get; set; }

        [Parameter("Color", DefaultValue = 255, MinValue = 0, MaxValue = 255)]
        public int ColorAlpha { get; set; }

        [Parameter(DefaultValue = 100)]
        public int StepPips { get; set; }

        protected override void Initialize()
        {
            double max = Bars.HighPrices.Maximum(Bars.HighPrices.Count);

            double min = Bars.LowPrices.Minimum(Bars.LowPrices.Count);

            double step = Symbol.PipSize * StepPips;

            double start = Math.Floor(min / step) * step;

            var color = GetColor(LineColor, ColorAlpha);

            for (double level = start; level <= max + step; level += step)
            {
                Chart.DrawHorizontalLine("line_" + level, level, color);
            }
        }

        public override void Calculate(int index)
        {
        }

        private Color GetColor(string colorString, int alpha = 255)
        {
            var color = colorString[0] == '#' ? Color.FromHex(colorString) : Color.FromName(colorString);

            return Color.FromArgb(alpha, color);
        }
    }
}

You can use any Color name or hexadecimal color code for line color parameter, with Color alpha you can control the color transparency.


@amusleh

amusleh
30 Dec 2021, 14:57

Hi,

Please post the code of indicator and then we will be able to help you.


@amusleh

amusleh
30 Dec 2021, 08:36

Hi,

You can draw a vertical line on any time you want to, you just have to pass the time.

Use a loop and draw a line every day at 22 GMT, here is an example that might help you: 

 


@amusleh

amusleh
30 Dec 2021, 08:34

Hi,

1. Yes, it can modify any pending order or position, it doesn't matter if its created by itself or manually or by any other cBot

2. It can, you have to reference/add the indicator on your cBot

3. No, you can't, you have to do it with code


@amusleh

amusleh
29 Dec 2021, 08:58

Hi,

Do you mean something like 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 TopYbottomYtest : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        protected override void Initialize()
        {
            if (Source == Bars.HighPrices)
            {
                Print("High Prices");
            }
        }

        public override void Calculate(int index)
        {
        }
    }
}

 


@amusleh

amusleh
29 Dec 2021, 08:53

Hi,

Right now this information is not available on Automate API, if you want to you can create a thread under suggestions section for it.


@amusleh

amusleh
28 Dec 2021, 08:00

Hi,

On your first post you just asked for Bollinger bands cross, you didn't mentioned any other indicator.

When you post code please use the editor "Insert Code Snippet" option.

The issue with your code is invalid indicator index, if you are using this code on a cBot try to use .Last(1) or .Last(2), you shouldn't pass the bar index which starts from beginning because the Last method uses reverse indexing.

And the LastValue property gives you the latest value inside indicator series, you should not use it because it will give non deterministic results as the last value isn't completed yet and it can change.

For more please check code examples on automate API references.


@amusleh

amusleh
27 Dec 2021, 09:10

Hola,

Publique una solicitud de trabajo o pídale ayuda a uno de nuestros consultores.

Solo brindamos asistencia en inglés; si es posible, escriba en inglés.


@amusleh

amusleh
27 Dec 2021, 09:00

Hi,

As I said it works fine on my system:

Can you tell what's you system graphics card? most probably that's the issue as it can't process fast enough that amount of data.


@amusleh

amusleh
24 Dec 2021, 11:24

Hi,

I tired with your exact code and its working fine, I replicated your actions on the video and the bottom line didn't disappeared.

Can you tell me which broker cTrader you are using or which version? I tried on Spotware Beta cTrader 4.1.


@amusleh

amusleh
24 Dec 2021, 07:57

Hi,

It works fine, try this:

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TopYbottomYtest : Indicator
    {
        private double topY, bottomY;

        protected override void Initialize()
        {
            TopBottomYtest();
            Chart.ScrollChanged += onscrollchanged;
        }

        private void onscrollchanged(ChartScrollEventArgs f)
        {
            TopBottomYtest();
        }

        private void TopBottomYtest()
        {
            topY = Math.Round(Chart.TopY, Symbol.Digits);
            bottomY = Math.Round(Chart.BottomY, Symbol.Digits);
            Chart.DrawStaticText("test", "TOP " + topY.ToString() + " Bottom " + bottomY.ToString(), VerticalAlignment.Bottom, HorizontalAlignment.Center, Color.Red);
            Chart.DrawTrendLine("trendlinetesttop", Chart.FirstVisibleBarIndex, Chart.TopY, Chart.LastVisibleBarIndex, Chart.TopY, Color.Red, 30);
            Chart.DrawTrendLine("trendlinetestbottom", Chart.FirstVisibleBarIndex, Chart.BottomY, Chart.LastVisibleBarIndex, Chart.BottomY, Color.Red, 30);
        }

        public override void Calculate(int index)
        {
        }
    }
}

 


@amusleh

amusleh
24 Dec 2021, 07:51

Hi,

Its possible, please post a job request or contact one of our consultants.


@amusleh

amusleh
24 Dec 2021, 07:47

Hi,

It will be released in next few weeks.


@amusleh

amusleh
23 Dec 2021, 11:25 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE: RE:

firemyst said:

amusleh said:

 

The clouds uses output color which user can change, the color is not hardcoded, the output names are.

How does a user change the output color?

 

I have several indicators with "clouds" on them and cannot see anywhere in the indicator properties to change the colors of the clouds between the lines -- only the "lines" that make up the indicator.

 

Nothing in the online API reference seems to indicate how either:

https://ctrader.com/api/reference/cloudattribute

Thank you

Hi,

Did you tried the example indicator on API references?

If one output line goes above the other then the color change to that output line color. you don't have to provide the color for cloud attribute, that's optional.


@amusleh

amusleh
23 Dec 2021, 09:10

RE:

firemyst said:

While a nice feature (and finally catching up with the competition), it would be nice if the Spotware cTrader team even allowed end users to be able to select their own colors rather than what the programmer does!

The @Spotware team needs some sort of human-interface engineer (or someone) when implementing such features -- it's ridiculous that a charting feature with colors is implemented and end users have no way to change/customize it. Certainly doesn't put "traders first".

The clouds uses output color which user can change, the color is not hardcoded, the output names are.


@amusleh