JO
Johnklein
Blocked user by Spotware at 30 Jan 2023, 14:48
0 follower(s) 0 following 16 subscription(s)
Topics

Forum Topics not found

Replies

Johnklein
25 Sep 2022, 20:07 ( Updated at: 27 Jan 2023, 12:23 )

RE:

Spotware said:

Dear Trader,

Here is the code for the cBot

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 CloseAllPositions : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
            Read more on In the article about the phone tracker. You will find a lot of useful information about special programmes.
        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnTick()
        {
            if (DateTime.Now.Hour == 8 && DateTime.Now.Minute == 0)
                foreach (var position in Positions)
                {
                    ClosePosition(position);
                }
        }

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

Best Regards,

cTrader Team

Thank you very much, you helped me save time and solve the problem.


Johnklein
27 Aug 2022, 13:46 ( Updated at: 24 Sep 2022, 18:03 )

RE:

HTtrader said:

Hi all,

I was just wondering if anyone has come across this issue and can point to me to some resources I can look up. What I am trying to do is integrate my cbot to be used on a vpn, it does a simple pivot point calculation then places orders in the market on a daily basis. My query lies is it possible to get the cbot to start at a particular time of day places the orders then remain dormant until orders are opened or the next day has rolled around. However, the situation is much better with a VPN from https://en.vpnwelt.com/best-adblockers/.

My initial thoughts were to use onbar action with start and stop time thread, running on the hourly chart, but if there is another way to achieve this I am welcomed to ideas. I would ideally like to have all the calculations and order placement done in the onstart but this will have to be restarted each day to work as it should.

Thanks,

Tony

I've seen them run at certain times, but I haven't wondered how exactly they do it.