Topics

Forum Topics not found

Replies

amusleh
19 Jan 2022, 14:54

RE:

noppanon said:

Hi Amusleh,

   They had been many login issues recently. Do u have any suggest on client side how we should do in order to mitigate this problem. Please don't advice we have to code 2 bots on both cTrader app and Open API.

regards,

Noppanon

Hi,

Open API has a very good record of up time, and it can't have 100% up time.

Usually it's only down for short period of time on weekends for maintenance.

If you found any issue with Open API please report and we will fix it ASAP.

The issues you faced recently was due to some major upgrades on our side.


@amusleh

amusleh
19 Jan 2022, 14:50

Hi,

In version 4.2 if you call Server.Time inside an indicator that is being used on back tester it will give you the back test time not current time.


@amusleh

amusleh
19 Jan 2022, 13:35

RE: FIX API crash(usually after 1-20 minutes) : An existing connection was forcibly closed by the remote host

slukk200 said:

Hi Amusleh,

I have registered 2 live accounts. For one(Pepperstone) it has been running for 10 hours without any problem, but for the otherone (ICMarkets) it keeps disconnecting. I have tried your console app again with the config file you provided and it disonnected after 3 minutes. (The two apps have been running parallel so I don't think this is an internet problem)

Is there someone here at Spotware who could take a look at it?

Or should I contact the broker?

 

Hi,

I tested again on a IC Market demo account today for 2 hours and 200 symbols, I didn't faced any issue.

If we can't replicate the issue how can we fix it? I have tested it and it works fine.

I'm Spotware community developer.

 


@amusleh

amusleh
19 Jan 2022, 10:07

Hi,

The issue has been resolved, please check and let us know if there was anything wrong.

Thanks for your patience!


@amusleh

amusleh
19 Jan 2022, 07:56 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE: RE: RE:

IGForex said:

Hi 

This is how it is showing on my system.

What I was asking was is it possible to show CustomMACD without stretching as seen in the first image I posted but without a gap between current time and CustomMACD end point. Every point of CustomMACD does not have to be aligned with the time/index, but only the end of it being aligned with last index.   

Thanks

Hi,

I'm not sure what you are looking for, can you make it more clear? the indicator shows the MACD indicator values for all available bars on your chart including the last bar.


@amusleh

amusleh
19 Jan 2022, 07:51

Hi,

Please check this thread: cTDN Forum - Problem with 'openapi.ctrader.com/apps/token' endpoint

We will update you there regarding this issue.


@amusleh

amusleh
19 Jan 2022, 07:45

Hi,

We are aware of this issue, it will be fixed very soon.


@amusleh

amusleh
18 Jan 2022, 13:36

Hi,

When you buy you buy at ask price and when you sell you sell at bid price, and the difference between bid/ask is spread.

Your order stop loss got hit by ask price, the candles are based on bid price.

When you set your orders stop loss and take profit you must take into account the symbol spread.


@amusleh

amusleh
18 Jan 2022, 10:10

Hi,

Currently you can't place pending orders with quick trade panel, it will become available on cTrader web version 4.3.


@amusleh

amusleh
18 Jan 2022, 09:22

RE: RE:

IGForex said:

Hi,

Thank you for the code. It kinda works. Is there a way to show CustomMACD from the last index without stretching  or contracting?

 

Thank you
Regards
Ivan

Hi,

Not sure what do you mean, it's not stretching or contracting, usually a larger time frame bar contains multiple shorter time frame bars, that's why you see the same value for multiple bars.


@amusleh

amusleh
18 Jan 2022, 09:20

Hi,

Please post a job request or contact one of our consultants.


@amusleh

amusleh
18 Jan 2022, 09:19

Hi,

You can create a data series by using the CreateDataSeries method, please check here for examples: cAlgo API Reference - IndicatorDataSeries Interface (ctrader.com)


@amusleh

amusleh
18 Jan 2022, 09:17

RE: RE: RE:

ycomp said:

any tips though? I have disabled print statements as firemyst suggested, because it does produce some print statements on a regular basis. But any ideas what can cause this kind of problem?

My bot does nothing fancy except it does modify the order often.

So just to verify, there would be no benefit to adding Thread Sleep statements?

Also there is nothing wrong with having 2 isntances of the same bot running on the same symbol, correct? They never actually modify the same position. One modifies when positions are long, the other when short.. to change this behaviour would take a lot of work.

Hi,

It's almost impossible to help you unless you post the code of your cBot.

A lot of things can go wrong, and there will be no benefit at all if you add Thread sleep. 


@amusleh

amusleh
17 Jan 2022, 12:10

Hi,

You can do it like this:

using System;
using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class IndicatorTest : Indicator
    {
        [Parameter("Bars TimeFrame")]
        public TimeFrame BarsTimeFrame { get; set; }
        
        private Bars _bars;

        protected override void Initialize()
        {
            try
            {
                _bars = MarketData.GetBars(BarsTimeFrame);
                
            } catch (Exception e)
            {
                Print(e, e.StackTrace);
            }
        }

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

Now, to use it on a cBot or another indicator:

Indicators.GetIndicator(TimeFrame.Daily);

It means it will use daily bars.


@amusleh

amusleh
17 Jan 2022, 09:34

RE:

ycomp said:

I wrote a cAlgo bot

It works fine but after a while of running (sometimes hours), cTrader becomes very unresponsive.

I also run 2 instances of the bots on the same symbol.. one for long and one for short position management.

What would generally cause cTrader to hang or become unresponsive?

I have no idea where to start with debugging this.

The bot manages an existing (i.e. manually opened by the user) trade position. It doesn't do anything fancy like call other dlls or anything.

Do I need to put some kind of sleep statements in my code?

Any insight appreciated.

Hi,

Your cBot is not coded properly, and there is only one solution, fix your cBot code.


@amusleh

amusleh
17 Jan 2022, 09:32

Hi,

The API doesn't record each change on a position profit, it only gives you the current net profit as doing so will increase significantly the system resource usage.

But you can do it by your self, just subscribe to each position symbol OnTick event, when symbol price changes record that symbol positions net profit on a collection by using Position ID, and time, with amount of Net profit.

Later you can use that collection to get the Net profit of a position by using time.


@amusleh

amusleh
17 Jan 2022, 09:29

Hi,

The cTrader visual back test only shows your selected time frame chart, so it doesn't know or have any idea about other time frames that you might use inside a cBot code.

The visual back test option is added to help you debug and test your cBots, it's not designed for manual back testing.

There are some solutions you can use to show multiple time frames data on your cTrader back tester, like with the help of an indicator.

You can use this indicator: Custom Period Chart - AlgoDeveloper

Attach it on your back test chart, set the time frame you want to and it will display it when you start back testing on a separate indicator window or on top of your current chart bars.

I recommend you to read the indicator documentation. 


@amusleh

amusleh
17 Jan 2022, 09:24

Hi,

Each time frame uses different index, you can't use the current time frame bars index on another time frame.

You have to first get the other time frame bar index by using current time frame bar Open Time, try this:

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CustomMACD : Indicator
    {
        public MacdCrossOver _macd;

        private Bars _bars;

        [Output("Histogram Up", PlotType = PlotType.Histogram, Color = Colors.DodgerBlue)]
        public IndicatorDataSeries HistogramPositive { get; set; }

        [Output("Histogram Down", PlotType = PlotType.Histogram, Color = Colors.DodgerBlue)]
        public IndicatorDataSeries HistogramNegative { get; set; }

        [Output("MACD", Color = Colors.DodgerBlue, LineStyle = LineStyle.Lines)]
        public IndicatorDataSeries MACD { get; set; }

        [Output("Signal", Color = Colors.Red, LineStyle = LineStyle.Lines)]
        public IndicatorDataSeries Signal { get; set; }

        [Parameter("Time Frame", DefaultValue = "Hour")]
        public TimeFrame tFrame { get; set; }

        protected override void Initialize()
        {
            _bars = MarketData.GetBars(tFrame);
            _macd = Indicators.MacdCrossOver(_bars.ClosePrices, 26, 12, 9);
        }

        public override void Calculate(int index)
        {
            var seriesIndex = _bars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);

            if (_macd.Histogram[seriesIndex] > 0)
            {
                HistogramPositive[index] = _macd.Histogram[seriesIndex];
            }
            else if (_macd.Histogram[seriesIndex] < 0)
            {
                HistogramNegative[index] = _macd.Histogram[seriesIndex];
            }

            Signal[index] = _macd.Signal[seriesIndex];

            MACD[index] = _macd.MACD[seriesIndex];
        }
    }
}

@amusleh

amusleh
17 Jan 2022, 09:17

Hi,

When you run a cBot it gets the available data on your chart as Bars object.

That same object is shared with indicators that you use inside your cBot or on your chart.

You can't select the bars in UI parameters, a Bars object represent a time frame/period price data.

You have to use TimeFrame parameter and then your indicator/cBot can load that time frame bars.


@amusleh

amusleh
14 Jan 2022, 10:29

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

v.fiodorov83 said:

Hi,

Can you please post the raw full JSON response, so I will be able to deserialize it on my system and see what's wrong.


If you don't mind, then let's continue our conversation in the telegram, because if I insert data here, it will be just a mess and it will be hard for you to dig into it. In the telegram, I will send you a direct link and you will have a look. And if we manage to fix it, then we will write in this thread of the forum. How do you like this idea?

Hi,

You can send me the data via Telegram: @algodeveloper


@amusleh