TimeSpan as parameter

Created at 19 Sep 2017, 19:43
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!
HE

herve.va

Joined 19.09.2017

TimeSpan as parameter
19 Sep 2017, 19:43


Good afternoon,

I want to use TimeSpan as parameter with default value but don't how to do it.

Is it possible ?


@herve.va
Replies

afhacker
19 Sep 2017, 21:29

Use string then parse it:

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.IO.Pipes;
using System.Globalization;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Blank : Robot
    {
        private TimeSpan userTimeZone;

        [Parameter("Time Zone(UTC)", DefaultValue = "10:00:00")]
        public string UserTimeZone { get; set; }

        protected override void OnStart()
        {
            userTimeZone = TimeSpan.Parse(UserTimeZone, CultureInfo.InvariantCulture);
        }

        protected override void OnTick()
        {
        }

        protected override void OnStop()
        {
        }
    }
}

 


@afhacker

herve.va
20 Sep 2017, 17:46

thanks afhacker, it is good.


@herve.va