Time stop

Created at 09 Dec 2014
AR

arushanz

Joined 09.12.2014

Status

Open


Budget

1.00 NZD


Payment Method

Direct Payment

Job Description

Can you tell me if it is possible to create a method for exiting any trade at a pre-determined time of the day? What is involved and what would be the approx cost of such a facility for the CTrader platform. Would it be easy to invoke? Thanks

Comments
Log in to add a comment.
MO
moped38 · 8 years ago

Often there have been problems with the broker. Not merely organizing and robbed, and I determined to get established brokers with site http://put-call-options.com which is advised just luchishh. Who I have been working having an additional half a year. Many thanks for attention.))

bachapk's avatar
bachapk · 9 years ago

Depends what exactly you want. Please explain your full requirements and send it to bachapk@gmail.com

ZU
zumzum · 9 years ago

Hi,

depends on what you exactly need.

if you opend orders by bot or manually and you want to close all open positions it's easy to do.

If you opend orders manually and want to close a single (particular) order it's possible to close all orders of a currency but not a particular order, since it cannot be labeled (seems like cTrader offers labels only for orders executed by a bot and it seems impossible to add a label afterwards.

If you opend the order by bot and want to close a single (particular) it's easy since you can label that order.

I don't know if there is a workaround to close an order by ID, maybe some senior coders know that.

Anyway yesterday I had the same problem when AUD news beeing released in the middle of the night (living in europe), so I coded a small bot that fulfils my requirements.

Following code is untested you can use ist as sample, so modify it for you needs. If you got a question just ask.

 

//
//This is just some free sample code. Modify, test and use it (on a DEMO account) at your own risk. NO WARRENTY!
//
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 ClosingBot : Robot
    {

        [Parameter("Year", DefaultValue = 2014)]
        public int year { get; set; }

        [Parameter("Hour", DefaultValue = 1, MinValue = 1, MaxValue = 31)]
        public int hour { get; set; }

        [Parameter("Month", DefaultValue = 12, MinValue = 1, MaxValue = 12)]
        public int month { get; set; }

        [Parameter("Minute", DefaultValue = 0, MinValue = 0, MaxValue = 59)]
        public int minute { get; set; }

        [Parameter("Day", DefaultValue = 1, MinValue = 1, MaxValue = 31)]
        public int day { get; set; }

        [Parameter("Second", DefaultValue = 0, MinValue = 0, MaxValue = 59)]
        public int second { get; set; }

        [Parameter("Close ALL?", DefaultValue = 1, MinValue = 0, MaxValue = 1)]
        public bool closeAll { get; set; }

        [Parameter("Close EURCAD?", DefaultValue = 0, MinValue = 0, MaxValue = 1)]
        public bool closeEurCad { get; set; }

        [Parameter("Close NZDUSD?", DefaultValue = 0, MinValue = 0, MaxValue = 1)]
        public bool closeNzdUsd { get; set; }


        protected override void OnStart()
        {
            // Put your initialization logic here
        }


        protected override void OnTick()
        {
            DateTime date1 = Server.Time;
            DateTime date2 = new DateTime(year, month, day, hour, minute, second);
            int result = DateTime.Compare(date1, date2);

            if (result > 0)
            {
                if (closeAll == false)
                {
                    if (closeEurCad == true)
                    {
                        Symbol EURCAD = MarketData.GetSymbol("EURCAD");
                        var positionEURCAD = Positions.FindAll("", EURCAD);
                        foreach (var position in positionEURCAD)
                            ClosePosition(position);
                        Print("What Year Is It? ", date2);
                        Print("Am I rich yet? You just made: ", LastResult.Position.NetProfit);
                    }

                    if (closeNzdUsd == true)
                    {
                        Symbol NZDUSD = MarketData.GetSymbol("NZDUSD");
                        var positionNZDUSD = Positions.FindAll("", NZDUSD);
                        foreach (var position in positionNZDUSD)
                            ClosePosition(position);
                        Print("Am I rich yet?", LastResult.Position.NetProfit);
                        Print("Am I rich yet? You just made: ", LastResult.Position.NetProfit);
                    }
                }
                else
                {
                    foreach (var position in Positions)
                    {
                        ClosePosition(position);
                        Print("What Year Is It? ", date2);
                        Print("Am I rich yet? You just made: ", LastResult.Position.NetProfit);
                    }
                }

            }
        }





        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

//v0.0.1 aplha (untested) (2014-12-09):
//initial version