How to coding expire date for ea

Created at 06 May 2017, 08:52
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!
KO

korakodmy

Joined 17.07.2016

How to coding expire date for ea
06 May 2017, 08:52


Hello everyone

I want to coding expire date in 1 month

Example , Start ea on date 1 May 2017  ea will expire on 1 Jun 2017

 

Thank you very much


@korakodmy
Replies

tradermatrix
06 May 2017, 12:26

RE:

korakodmy said:

Hello everyone

I want to coding expire date in 1 month

Example , Start ea on date 1 May 2017  ea will expire on 1 Jun 2017

 

Thank you very much

Hello
I dated April 15, 2017 for example baktesting
Made at your convenience..@+

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 EXEMPLE : Robot
    {
       [Parameter("Initial Volume", DefaultValue = 10000, MinValue = 0)]
       public int InitialVolume { get; set; }

        [Parameter("Stop Loss", DefaultValue = 20)]
        public int StopLoss { get; set; }

        [Parameter("Take Profit", DefaultValue = 20)]
        public int TakeProfit { get; set; }


    bool timeprotected = true;
        // if true ;Expiry YEAR MM DD
        DateTime expirytime = new DateTime(2017, 4, 15);


        protected override void OnTick()
        {
            if (timeprotected == true && DateTime.Compare(Server.Time.Date, expirytime) >= 1)
            {
                //your email
                Informer("Robot Expired!! Please contact .....@....");

                Stop();
            }
        }

 


@tradermatrix