PanagiotisCharalampous's avatar
PanagiotisCharalampous
26 follower(s) 0 following 1006 subscription(s)
Replies

PanagiotisCharalampous
16 Jan 2019, 15:04

Hi Paul,

Very interesting work. Looking forward to try this.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
16 Jan 2019, 14:15

Hi Piotr,

This is not available currently but it is in our backlog. 

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
16 Jan 2019, 11:13

Hi mustapha,

Thanks for reporting this. We are trying to reproduce this issue.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
16 Jan 2019, 09:55 ( Updated at: 21 Dec 2023, 09:21 )

Hi nijudavid,

Thanks for posting in our forum. cTrader needs to be running. It is clearly stated in the Advanced Protection form

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
16 Jan 2019, 09:42

Hi Benjamin,

You can use IsBacktesting to check if the cBot is in backtesting. This parameter will be true both in backtesting and optimization. If you need this function in backtesting as well, then you can just optimize a copy of the cBot that will not have these functions.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous

PanagiotisCharalampous
15 Jan 2019, 17:35

Hi Rossano,

It does not seem they have an iOS app deployed at the moment. Maybe you can get in touch with them and ask their plans.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Jan 2019, 17:06

Hi Rosario,

Do you use Kimura cTrader mobile application? Can you see your account on Kimura cTrader desktop or web?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Jan 2019, 17:05

Hi bienve.pf,

Thanks, now I understand what you mean. Indeed PipValue is calculated based on the rate at the begining of the backtesitng. This is a known issue and we will try to address it in a future release.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous

PanagiotisCharalampous
15 Jan 2019, 17:00

Hi eliezer_barros,

I have replied to your email. You cannot use position.Close() with FxPro as it uses an older version of cTrader. You need to use ClosePosition().

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Jan 2019, 09:41 ( Updated at: 21 Dec 2023, 09:21 )

Hi Benjamin,

If you check the log of your optimization, you will see the reason why this happens

This happens because you use Chart.DrawStaticText() function. Do you need this function in backtesting?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
15 Jan 2019, 09:19

Hi bienve.pf,

I am not sure what do you mean with your question. Pip is a standard measure of change, different in each symbol but usually it is an increment/decrement of the price in the fourth decimal place for forex pairs. One pip is usually one basis point.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 17:30

Hi missyeam,

I changed the code a bit. See below

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 ClickAlgoSchoolSMA : Robot
    {
        #region User defined parameters

        [Parameter("Instance Name", DefaultValue = "001")]
        public string InstanceName { get; set; }

        [Parameter("Lot Size", DefaultValue = 0.1)]
        public double LotSize { get; set; }

        [Parameter("Source SMA #1")]
        public DataSeries SourceSma1 { get; set; }

        [Parameter("Source SMA #2")]
        public DataSeries SourceSma2 { get; set; }

        [Parameter("Period SMA #1", DefaultValue = 5, MinValue = 1, MaxValue = 100)]
        public int PeriodsSma1 { get; set; }

        [Parameter("Period SMA #2", DefaultValue = 20, MinValue = 1, MaxValue = 100)]
        public int PeriodsSma2 { get; set; }

        [Parameter("Calculate OnBar", DefaultValue = false)]
        public bool CalculateOnBar { get; set; }

        #endregion

        #region Indicator declarations

        private SimpleMovingAverage _sma1 { get; set; }
        private SimpleMovingAverage _sma2 { get; set; }

        #endregion

        #region cTrader events

        double _volume;
        protected override void OnStart()
        {
            // construct the indicators
            _sma1 = Indicators.SimpleMovingAverage(SourceSma1, PeriodsSma1);
            _sma2 = Indicators.SimpleMovingAverage(SourceSma2, PeriodsSma2);
            _volume = Symbol.QuantityToVolume(LotSize);
        }


        protected override void OnTick()
        {
            if (CalculateOnBar)
            {
                return;
            }

            ManagePositions();
        }


        protected override void OnBar()
        {
            if (!CalculateOnBar)
            {
                return;
            }

            ManagePositions();
        }


        protected override void OnStop()
        {
            // unused
        }

        #endregion

        #region Position management

        private void ManagePositions()
        {
            if (_sma1.Result.LastValue > _sma2.Result.LastValue)
            {
                ClosePosition(TradeType.Sell);

                if (!IsPositionOpenByType(TradeType.Buy))
                {
                    OpenPosition(TradeType.Buy);
                }
            }


            if (_sma1.Result.LastValue < _sma2.Result.LastValue)
            {
                ClosePosition(TradeType.Buy);

                if (!IsPositionOpenByType(TradeType.Sell))
                {
                    OpenPosition(TradeType.Sell);
                }
            }
        }


        private void OpenPosition(TradeType type)
        {
            // open a new position
            ExecuteMarketOrder(type, this.Symbol, _volume, InstanceName, null, null);
        }


        private void ClosePosition(TradeType type)
        {
            var p = Positions.Find(InstanceName, this.Symbol, type);

            if (p != null)
            {
                ClosePosition(p);
                if (p.NetProfit < 0)
                {
                    _volume += 1000;
                }
                else
                {
                    _volume = Symbol.QuantityToVolume(LotSize);
                }
            }
        }

        #endregion

        #region Position Information


        private bool IsPositionOpenByType(TradeType type)
        {
            var p = Positions.FindAll(InstanceName, Symbol, type);

            if (p.Count() >= 1)
            {
                return true;
            }

            return false;
        }

        #endregion
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 16:26

Hi michael00,

If your account is a demo account and if your application is working with other accounts, then make sure that your password is correct.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 16:23

Hi missyeam,

Can you give me backtesting parameters and dates to check this?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 15:27

Thanks missyearm,

Let me know if the below works for you

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 ClickAlgoSchoolSMA : Robot
    {
        #region User defined parameters

        [Parameter("Instance Name", DefaultValue = "001")]
        public string InstanceName { get; set; }

        [Parameter("Lot Size", DefaultValue = 0.1)]
        public double LotSize { get; set; }

        [Parameter("Source SMA #1")]
        public DataSeries SourceSma1 { get; set; }

        [Parameter("Source SMA #2")]
        public DataSeries SourceSma2 { get; set; }

        [Parameter("Period SMA #1", DefaultValue = 5, MinValue = 1, MaxValue = 100)]
        public int PeriodsSma1 { get; set; }

        [Parameter("Period SMA #2", DefaultValue = 20, MinValue = 1, MaxValue = 100)]
        public int PeriodsSma2 { get; set; }

        [Parameter("Calculate OnBar", DefaultValue = false)]
        public bool CalculateOnBar { get; set; }

        #endregion

        #region Indicator declarations

        private SimpleMovingAverage _sma1 { get; set; }
        private SimpleMovingAverage _sma2 { get; set; }

        #endregion

        #region cTrader events

        double _volume;
        protected override void OnStart()
        {
            // construct the indicators
            _sma1 = Indicators.SimpleMovingAverage(SourceSma1, PeriodsSma1);
            _sma2 = Indicators.SimpleMovingAverage(SourceSma2, PeriodsSma2);
            _volume = Symbol.QuantityToVolume(LotSize);
            Positions.Closed += Positions_Closed;
        }

        private void Positions_Closed(PositionClosedEventArgs obj)
        {
            if (obj.Position.NetProfit < 0)
                _volume += 1000;
            else
                _volume = Symbol.QuantityToVolume(LotSize);

        }

        protected override void OnTick()
        {
            if (CalculateOnBar)
            {
                return;
            }

            ManagePositions();
        }


        protected override void OnBar()
        {
            if (!CalculateOnBar)
            {
                return;
            }

            ManagePositions();
        }


        protected override void OnStop()
        {
            // unused
        }

        #endregion

        #region Position management

        private void ManagePositions()
        {
            if (_sma1.Result.LastValue > _sma2.Result.LastValue)
            {

                if (!IsPositionOpenByType(TradeType.Buy))
                {
                    OpenPosition(TradeType.Buy);
                }

                ClosePosition(TradeType.Sell);
            }


            if (_sma1.Result.LastValue < _sma2.Result.LastValue)
            {

                if (!IsPositionOpenByType(TradeType.Sell))
                {
                    OpenPosition(TradeType.Sell);
                }

                ClosePosition(TradeType.Buy);
            }
        }


        private void OpenPosition(TradeType type)
        {



            // open a new position
            ExecuteMarketOrder(type, this.Symbol, _volume, InstanceName, null, null);
        }


        private void ClosePosition(TradeType type)
        {
            var p = Positions.Find(InstanceName, this.Symbol, type);

            if (p != null)
            {
                ClosePosition(p);
            }
        }

        #endregion

        #region Position Information


        private bool IsPositionOpenByType(TradeType type)
        {
            var p = Positions.FindAll(InstanceName, Symbol, type);

            if (p.Count() >= 1)
            {
                return true;
            }

            return false;
        }

        #endregion
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 14:43

Hi missyeam,

If you post your cBot code, we might be able to help you.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 14:17

Hi michael00,

The host name works fine for me. What host name do you get in your FIX API form in cTrader? Are you using a demo account?

Best Regards,

 


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 14:11

Hi Sasha,

The specific variable has nothing to do with stop outs. If you want to know the reason of position closing use obj.Reason.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 12:39

Hi Ton,

There is no such feature available at the moment. However it is in our backlog therefore you should expect it in one of the future versions.

Best Regards, 

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
14 Jan 2019, 11:33

Hi Ulises,

We will be releasing a revamped help site very soon.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous