Replies

PanagiotisCharalampous
08 Nov 2017, 11:29

Hi irmfar,

It will repeat the last result since you are instructing the indicator to print only when it is at the last bar. You should change the condition as follows

        public override void Calculate(int index)
        {
            if (!IsLastBar)
                Print(" print only once for each bar at the moment" + index);
        }

Let me know if this helps.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
08 Nov 2017, 10:50 ( Updated at: 21 Dec 2023, 09:20 )

Hi itmfar,

I created an example based on your code and it seems to be working as expected. See code sample and screenshot below

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }
        private int secondGap;
        private int firstGap;

        protected override void Initialize()
        {
            secondGap = MarketSeries.Close.Count - 10;
            firstGap = MarketSeries.Close.Count - 20;
        }

        public override void Calculate(int index)
        {
            if (index > firstGap && index < secondGap)
                ChartObjects.DrawVerticalLine("v" + index, index, Colors.White);
        }
    }
}

Let me know if I misunderstood something.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
08 Nov 2017, 10:35

Hi itmfar,

Calculate function is invoked once for each bar and then for each tick for the last bar. The reason this happens is that for each tick the values for the last bar change therefore the indicator might need to be recalculated. If you want to skip recalculation for the last bar, you might consider using the IsLastBar property of the Indicator.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
08 Nov 2017, 10:20

Hi mto1995,

PercentK is a DataSeries so it is not a single value but a collection. So you need to define which value you want to access. See below an example on how to get the last value of the DataSeries

        protected override void OnTick()
        {
            var a = Indicators.StochasticOscillator(9, 3, 9, MovingAverageType.Simple);

            if (a.PercentK.Last() <= 80)
            {
                // close position
            }
        }

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
08 Nov 2017, 09:29

Dear Trader,

Thanks for posting your suggestion in our forum. We appreciate the time you spent to share your thoughts with us. Your suggestion has been considered by our team for some time now but we still cannot commit to a definite answer, if it is going to be developed and when. However, seeing that there is interest for such a feature increases the chances of adding this into our backlog.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
07 Nov 2017, 12:58

We have this in mind, don't worry :)

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
07 Nov 2017, 12:40

Hi ycomp,

Yes we are aware of it. But we are currently in the process of designing a new community platform that will be much more improved than the current one, therefore our development efforts are focused on that direction.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
07 Nov 2017, 11:46

Hi Nicola,

From a first sight, you could put it in the end of the foreach loop, so that the position is partially closed just after the modification. However, if you are not experienced in C# programming, I would strongly advise you to collaborate with a professional programmer to make such changes, to avoid the risk of unintended results. There is a lot of code in the cBot and will require proper testing to verify that your change does exactly what you wanted to achieve.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
07 Nov 2017, 11:10

Hi animegalaxi,

Thanks for posting in our forum! See below an example of how you can close approximately 2/3 of a position. Note that the closing volume should always adhere to the Symbol's volume step requirements, therefore the exact 2/3 is not always achievable.

                var steps = Positions[0].Volume / Symbol.VolumeStep;
                var stepsToClose = (int)(steps * 2 / 3);
                ClosePosition(Positions[0], Symbol.VolumeStep * stepsToClose);

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
07 Nov 2017, 10:13

Hi ycomp,

Currently there is no such option. However Trading API will return the same error code as Accounts API. See a similar discussion you had a while ago here

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 18:07

Hi andi21,

Sorry I meant to say symbol and selected timeframe. So it actually updates only the market series displayed on the chart.

Best Regards, 

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 17:18

Hi andi21,

We had a look at the issue. The reason that it behaves like this, ut is because MarketSeries for the selected symbol are updated on scrolling on the chart while other MarketSeries for other symbols are not. We will fix the issue in a future release of cAlgo where we will add a method to get series for a specified time span.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 09:33

Dear Trader,

Thanks for your post. Unfortunately it is not clear what you are asking for. Are you trying to start the Timer with shorter intervals? If yes, then you can use the Start method overload that takes as input a TimeSpan instead of seconds. See below an example how to set the TimeSpan to 500 milliseconds.

 Timer.Start(new TimeSpan(0, 0, 0, 0, 500));

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 09:21

Dear Trader,

Thanks for posting in our forum. For some reason it seems cTrader cannot be downloaded on the virtual server. Can you try disabling temporarily any firewall/antivirus and try again?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 09:17

Hi swervehomez@gmail.com,

If you need professional help with your cBot, you might try posting a job in the Jobs section or contact a professional Consultant.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 09:15

Hi swervehomez@gmail.com,

If you need professional help with your cBot, you might try posting a job in the Jobs section or contact a professional Consultant.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 09:12

Hi khan_tu,

Is it possible to share your cBot code with us so that we can tell you where the problem is? Do you use ClosePosition method to close your positions?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
06 Nov 2017, 09:07

Hi khan_tu,

Apologies, I just noticed that you needed an in-build indicator. In the case of in-build indicators, you do not need to reference them. You can access them directly from the API. See below a code sample

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Price { get; set; }

        protected override void OnStart()
        {

        }

        protected override void OnTick()
        {
           var ichimokuInd = Indicators.IchimokuKinkoHyo(9, 26, 52);
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
04 Nov 2017, 09:33

Hi khan_tu,

I cannot see any problem in the process of referencing a custom indicator. Could you please send some more information to reproduce the error e.g. the code of the custom indicator, some screenshots etc?

Best Regards,

Panagiotis 


@PanagiotisCharalampous

PanagiotisCharalampous
03 Nov 2017, 16:44

Hi irmscher9,

Thanks for sending the report. Our Quality Assurance team will study it and investigate the issue.

Best Regards,

Panagiotis


@PanagiotisCharalampous