Bug: Default enum value it's not working in cTrader

Created at 31 Oct 2022, 10:16
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Waxy's avatar

Waxy

Joined 12.05.2015

Bug: Default enum value it's not working in cTrader
31 Oct 2022, 10:16


Hello,

Some of the recents updates to cTrader have broken the ability for the bot to use the default enums when declared, I provide code sample, where even If I set default color to Red, the instance I create sets it to transparent.

Please do fix as soon as possible.
Regards,

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    public enum MyColors
    {
        Transparent,
        Black,
        Red,
        Blue,
        Yellow
    }

    [Robot(AccessRights = AccessRights.None)]
    public class EnumTester : Robot
    {
        [Parameter("Color", DefaultValue = MyColors.Red)]
        public MyColors Color { get; set; }

        protected override void OnStart()
        {
            // To learn more about cTrader Automate visit our Help Center:
            // https://help.ctrader.com/ctrader-automate

            Print($"Color is {Color}");
        }

        protected override void OnTick()
        {
            // Handle price updates here
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

 


@Waxy
Replies

PanagiotisChar
31 Oct 2022, 11:52

Hi Waxy,

Did you try

[Parameter("Color", DefaultValue = "Red")] public MyColors Color { get; set; }

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

firemyst
31 Oct 2022, 13:50

RE:

PanagiotisChar said:

Hi Waxy,

Did you try

[Parameter("Color", DefaultValue = "Red")] public MyColors Color { get; set; }

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

HI @PanagiotisChar:

I believe it's broken in the latest cTrader release, because the code below doesn't work for me any more either. It always comes up with a default value of "Yesterday" instead of "Three_Weeks":

     public enum LoadFromData
        {
            Yesterday,
            Today,
            Two_Days,
            Three_Days,
            One_Week,
            Two_Weeks,
            Three_Weeks,
            Monthly,
            Custom
        }
        [Parameter("Amount of Historic Data to Load:", DefaultValue = LoadFromData.Three_Weeks)]
        public LoadFromData LoadFromInput { get; set; }

 


@firemyst

Waxy
31 Oct 2022, 19:47

RE:

Hello Panagiotis,

I'm using Spotware 4.4.17, this doesn't work either way with string or enum. but it should work with using enums as before, there shouldn't be a downgrade to this feature, it's just a small bug I believe, that should be fixed asap.

Regards,


@Waxy

Spotware
01 Nov 2022, 09:33

Dear all,

The product team has identified this bug and it will be fixed in an upcoming release.

Best regards,

cTrader Team


@Spotware