Topics

Forum Topics not found

Replies

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

amusleh
14 Jan 2022, 09:53 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE: RE: RE:

v.fiodorov83 said:

amusleh said:

v.fiodorov83 said:

amusleh said:

Hi,

You don't have to use this library for sending alerts to Telegram, you can use the Telegram .NET library that I mentioned on my first post.

You can also code the whole API interaction by yourself, you don't have to use any library, but they will make it much easier for you.

Well, you see, it turns out that if somewhere you have some library or dependency has the wrong version, different in x.x.x.x.1, then all this will not work and find where exactly the problem is unrealistic to find.

Nevertheless, thank you for your help and have a nice day.

Hi,

Telegram.Bot library can't deserialize the conversation updates, because one of the fields that must be integer comes as an empty string.

Either its the error code or the update ID, those are integers.

To find what's causing this issue, open the Telegram Bot API getUpdates on your browser: api.telegram.org/bot<your Bot Token>/getUpdates

Replace "your Bot Token" with your bot token, and post the response here.


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Well, here's a screenshot for an example. Here is the log of my conversation with the bot and there is also a log of his entry into the group. He has no messages from the terminal or any requests ..

 

What else is interesting. In the "Alerts" window you can write any nonsense in Username/Chanel form, if the token is correct, then it does not display the error "wrong group name or username", and then it also crashes

 

 

 

 

 

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.


@amusleh

amusleh
13 Jan 2022, 19:10

RE: RE:

v.fiodorov83 said:

amusleh said:

Hi,

You don't have to use this library for sending alerts to Telegram, you can use the Telegram .NET library that I mentioned on my first post.

You can also code the whole API interaction by yourself, you don't have to use any library, but they will make it much easier for you.

Well, you see, it turns out that if somewhere you have some library or dependency has the wrong version, different in x.x.x.x.1, then all this will not work and find where exactly the problem is unrealistic to find.

Nevertheless, thank you for your help and have a nice day.

Hi,

Telegram.Bot library can't deserialize the conversation updates, because one of the fields that must be integer comes as an empty string.

Either its the error code or the update ID, those are integers.

To find what's causing this issue, open the Telegram Bot API getUpdates on your browser: api.telegram.org/bot<your Bot Token>/getUpdates

Replace "your Bot Token" with your bot token, and post the response here.


@amusleh

amusleh
13 Jan 2022, 17:44

Hi,

For calculating the monetary value of a symbol pip/tick please follow this tutorial: Profit/Loss Calculation - Open API (spotware.github.io)


@amusleh