TimeSpan as parameter

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