Bug: Default enum value it's not working in cTrader
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
}
}
}
Replies
firemyst
31 Oct 2022, 13:50
RE:
PanagiotisChar said:
Hi Waxy,
Did you try
[Parameter("Color", DefaultValue = "Red")] public MyColors Color { get; set; }
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
PanagiotisChar
31 Oct 2022, 11:52
Hi Waxy,
Did you try
Aieden Technologies
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar