Topics

Forum Topics not found

Replies

amusleh
28 Mar 2022, 10:49

Hi,

You can post a job request or contact one of our consultants if you need programming service.

 


@amusleh

amusleh
28 Mar 2022, 10:48

Hi,

The disconnection can happen due to several reasons, like incorrect check sum.

There is no issue on our side and I just tested our Python samples, it works fine.

Regarding configuration, here is a valid configuration for Quotes session:

{
  "Host": "h51.p.ctrader.com",
  "Port": 5201,
  "Username": "account_number",
  "Password": "account_password",
  "BeginString": "FIX.4.4",
  "SenderCompID": "demo.icmarkets.account_number",
  "SenderSubID": "QUOTE",
  "TargetCompID": "cServer",
  "TargetSubID": "QUOTE",
}

You can check our Python or QuickFIX .NET samples on Github.


@amusleh

amusleh
28 Mar 2022, 10:43

Hola,
El mensaje de alerta se muestra solo cuando se activa, no puede ver el mensaje cuando aún no se activa.
Solo brindamos soporte en inglés, use inglés si puede y abra su hilo en la sección correspondiente, esta sección es para API de automatización.


@amusleh

amusleh
28 Mar 2022, 10:38

Hi,

A TradeOperation is a task that will happen in future, the RefreshData will not have any effect on it.

You have to use the callback to get notified about status of operation.


@amusleh

amusleh
28 Mar 2022, 10:26

Hi,

For now we just have the KeyDown event, not the key up event.

Please open a thread under suggestions section for this to be considered.


@amusleh

amusleh
28 Mar 2022, 10:25

Hi,

You can use 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), Cloud("Top", "Bottom")]
    public class Bands : Indicator
    {
        [Parameter("Distance (Pips)", DefaultValue = 10)]
        public double Distance { get; set; }

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

        [Output("Top", PlotType = PlotType.Line, LineColor = "Yellow")]
        public IndicatorDataSeries Top { get; set; }

        [Output("Bottom", PlotType = PlotType.Line, LineColor = "Yellow")]
        public IndicatorDataSeries Bottom { get; set; }

        protected override void Initialize()
        {
            Distance *= Symbol.PipSize;
        }

        public override void Calculate(int index)
        {
            Top[index] = Source[index] + Distance;
            Bottom[index] = Source[index] - Distance;
        }
    }
}

First attach the EMA indicator or any indicator you want to use as source/input, then attach the Bands indicator and set the source to your indicator (EMA).


@amusleh

amusleh
28 Mar 2022, 10:19

Hi,

Do you mean something like this:

using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        private int _lasyBarIndex;

        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {
            if (_lasyBarIndex == index) return;

            _lasyBarIndex = index;

            var bar = Bars[index];

            var barMiddle = bar.Low + ((bar.High - bar.Low) / 2);

            Chart.DrawTrendLine(index.ToString(), index, barMiddle, index + 1, barMiddle, Color.Red);
        }
    }
}

 


@amusleh

amusleh
28 Mar 2022, 09:35

Hi,

Please post a job request or contact a consultant.

 


@amusleh

amusleh
28 Mar 2022, 09:34

Hi,

Which type of data you were using for your back test? Tick data or m1 bars open prices?


@amusleh

amusleh
28 Mar 2022, 09:31

RE: Thank you

dionysian.apostle said:

Many thanks for your help with this.

Do you contract for paid work in creating cbots? I may need something creating once I have the design for it figured properly?

I also have another problem with some code not working correctly - I added a trailing stop and it works with backtest but then doesn`t place any trades...

 

I`ll put a post in the help section for that though.

 

Kind Regards.

 

 

 

 

amusleh said:

Hi,

I'm not familiar with ProRealTime code, but I think the cTrader Automate equivalent of your posted code will look something like this:

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None), Levels(0)]
    public class EMAGradient : Indicator
    {
        private ExponentialMovingAverage _ema;

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

        [Parameter("Bars #", DefaultValue = 1)]
        public int BarsNumber { get; set; }

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

        [Output("Main", IsHistogram = true, PlotType = PlotType.Histogram, Thickness = 3)]
        public IndicatorDataSeries Result { get; set; }

        protected override void Initialize()
        {
            _ema = Indicators.ExponentialMovingAverage(Source, Period);
        }

        public override void Calculate(int index)
        {
            Result[index] = _ema.Result[index] - _ema.Result[index - BarsNumber];
        }
    }
}

 

 

Hi,

You can post a job request or contact one of our consultants.


@amusleh

amusleh
28 Mar 2022, 09:29 ( Updated at: 29 Mar 2022, 14:24 )

Hi,

We got this error report on Github issues too, we tested the package on Windows and Ubuntu and it works fine.

This issue is not related to OpenApiPy, it's related to Twisted.

Related Github issue: Cannot start ConsoleSample · Issue #10 · spotware/OpenApiPy (github.com)


@amusleh

amusleh
28 Mar 2022, 09:27

RE: RE: Hello amusleh. Thank you for this. Can you please help me understand how to get this value to use in a cbot. Also can this be used to find the Angle of the EMA instead of a trendline. thank you

newbee said:

amusleh said:

Hi,

No, you can't get the angle from API, but you can calculate it if you want to:

        private double GetAngle(ChartTrendLine trendLine)
        {
            var x1 = Bars.OpenTimes.GetIndexByTime(trendLine.Time1);
            var x2= Bars.OpenTimes.GetIndexByTime(trendLine.Time2);

            double xDiff = x2 - x1;
            var yDiff = trendLine.Y2 - trendLine.Y1;

            return Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI;
        }

The above method will return the angle of a trend line in Degree, it will not work properly if your trend line is drawn in future time, because it uses bar indices for x axis.

If you to get the angle from API then please open a thread on forum suggestions section.

 

Hi,

Yes, you can use the code to get angle of a moving average, you just have to change the points (x1, x2, y1, y2), ex:

        private double GetAngle(int x1, double y1, int x2, double y2)
        {
            double xDiff = x2 - x1;
            var yDiff = y2 - y1;

            return Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI;
        }

 


@amusleh

amusleh
26 Mar 2022, 12:29

Hi,

For anyone who is reading this thread in future you can use the Go To Date indicator: 

 


@amusleh

amusleh
24 Mar 2022, 14:19

RE: RE: RE: RE: RE: RE: RE: RE: RE: RE:

florent.herb said:

florent.herb said:

amusleh said:

florent.herb said:

Hi,

Thank you for your comprehensive answer. Okay for optimisation and what about the live trading on the VPS? I will have several instances with a lot of TP happening quickly. What is to be  prefered? Thank you.

Best Regards

Hi,

For manual trading 4 GB memory and a 2 core VPS will be enough, if you are not using custom indicators and you don't have too many open charts otherwise you need more resources.

Hi,

No I mean when using a VPS running a Cbot. Live trading on a cBot :)

When do you know that a cbot needs more CPU or more RAM? Is 2 CPU and 8 GB RAM a combo that could work for a dozen instances opened on a huge cBot? Sorry for all the questions but it is crucial for me to understand this  :/. Than you very much.

 

Just run your cBot on minimum available resource, if your system memory or CPU usage was too high then upgrade.


@amusleh

amusleh
24 Mar 2022, 14:17

RE: RE:

MTrade12 said:

amusleh said:

Hi,

What do you mean by referencing them?

You have access to all chart objects and the events like object added/removed/updated.

If you want to draw trend line on chart you can do it with Char.DrawTrendLine method.

Here are some examples:

cAlgo API Reference - Chart Interface (ctrader.com)

cAlgo API Reference - ChartArea Interface (ctrader.com)

cAlgo API Reference - ChartTrendLine Interface (ctrader.com)

 

Hi amusleh!

 

Sorry, i realise now i could've been clearer in what i meant!

Let's say I want to manually draw a horizontal line on GBPCHF chart at 1.2265. 

By default, my manually drawn horizontal line is called "Horizontal Line 1", and each subsequent line is "Horizontal Line +1". 

Am i able using Calgo, to identify "Horizontal Line 1", and if so, can then obtain the price or X Value of it?

Hope that clarfies!

 

 

Hi,

Yes, you can.

Use chart object comments for objects identification.

Check my previous post links, there you can find examples.


@amusleh

amusleh
24 Mar 2022, 12:05

RE: RE: RE: RE: RE: RE: RE:

florent.herb said:

Hi,

Thank you for your comprehensive answer. Okay for optimisation and what about the live trading on the VPS? I will have several instances with a lot of TP happening quickly. What is to be  prefered? Thank you.

Best Regards

Hi,

For manual trading 4 GB memory and a 2 core VPS will be enough, if you are not using custom indicators and you don't have too many open charts otherwise you need more resources.


@amusleh

amusleh
24 Mar 2022, 09:24 ( Updated at: 24 Mar 2022, 09:25 )

Hi,

I'm not familiar with ProRealTime code, but I think the cTrader Automate equivalent of your posted code will look something like this:

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None), Levels(0)]
    public class EMAGradient : Indicator
    {
        private ExponentialMovingAverage _ema;

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

        [Parameter("Bars #", DefaultValue = 1)]
        public int BarsNumber { get; set; }

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

        [Output("Main", IsHistogram = true, PlotType = PlotType.Histogram, Thickness = 3)]
        public IndicatorDataSeries Result { get; set; }

        protected override void Initialize()
        {
            _ema = Indicators.ExponentialMovingAverage(Source, Period);
        }

        public override void Calculate(int index)
        {
            Result[index] = _ema.Result[index] - _ema.Result[index - BarsNumber];
        }
    }
}

 


@amusleh

amusleh
24 Mar 2022, 09:16 ( Updated at: 24 Mar 2022, 12:03 )

RE: RE: RE: RE: RE:

florent.herb said:

Hi amusleh,

I would like your view on this that has little to do with the topic above but still... 

What is more "important" considering a forex VPS in general: RAM or number of CPU?

Considering a dozen of instances opened at the same time on ctrader, between 4 or 6 GB of RAM and 4 or 6 CPU what combo of RAM / CPU would be best to choose? Thank you for all the help you can give me :)

Best Regards,

Florent

Hi,

It depends on your cBot and the way you want to use cTrader, for optimization the number of cores and base clock of each core is very important because optimization can use multiple cores and run in parallel multiple back tests on different CPU cores, it's not sequential like back test.

If you want to use VPS for optimization you you need at least 8 GB of ram and a 4 core CPU.

Increasing RAM size will not increase the optimization speed unless your cBot uses lots of RAM.


@amusleh

amusleh
24 Mar 2022, 09:11

Hi,

What do you mean by referencing them?

You have access to all chart objects and the events like object added/removed/updated.

If you want to draw trend line on chart you can do it with Char.DrawTrendLine method.

Here are some examples:

cAlgo API Reference - Chart Interface (ctrader.com)

cAlgo API Reference - ChartArea Interface (ctrader.com)

cAlgo API Reference - ChartTrendLine Interface (ctrader.com)

 


@amusleh

amusleh
23 Mar 2022, 07:50

Hi,

You can use historical tick data to get historical spread data.

Just get the historical tick data by using API ProtoOAGetTickDataReq message, and then calculate the spread by using each tick bid/ask prices, spread is the different between bid and ask price.


@amusleh