Schedule stop and start of a particular ctrader profile on PC
Schedule stop and start of a particular ctrader profile on PC
18 Oct 2023, 16:08
Hi,
The cBot which I want to shutdown 1 hour before the market close and start 1 hour after the market reopen is a third party cBot that I have purchased.
This cBot is called Trendpilot and it does not have a setting to not trade when the spread is very high, because of which it places ridiculous amounts of trades at market start time when the price is going bonkers.
On this computer I have 3 different profiles of cTrader running. I only want to stop and start (2 hours later) this particular profile of cTrader (where i am running 28 instances of trendpilot) and leave the other 2 profiles of cTrader untouched.
What would be a recommended way to do it.
If its possible to write a batch file to start and stop a particular profile of ctrader then I can use that batch file and just create an entry in the Windows scheduler to run these batch files one hour before the market closes and one hour after the market opens.
If there is an API to start and stop cbots, or prevent the instance of cTrader from opening new trades, I could write a custom cBot to prevent trading when spread is too high.
Or do I need to use something like AutoHotKey and automate closing and opening of windows with mouse clicks..
Please let me know,
Thanks.
Replies
PanagiotisChar
25 Oct 2023, 06:05
( Updated at: 25 Oct 2023, 06:13 )
Hi there,
You can post suggestions here.
You can also use cTrader CLI to interact externally with cBots.
@PanagiotisChar
driftingprogrammer
25 Oct 2023, 06:29
( Updated at: 25 Oct 2023, 10:53 )
RE: Schedule stop and start of a particular ctrader profile on PC
PanagiotisChar said:
Hi there,
You can post suggestions here.
You can also use cTrader CLI to interact externally with cBots.
Thanks for letting me know about CLI, I should be good to go with my requirements with this tool.
Thanks again.
@driftingprogrammer
driftingprogrammer
01 May 2024, 14:29
( Updated at: 02 May 2024, 07:04 )
RE: Schedule stop and start of a particular ctrader profile on PC
PanagiotisChar said:
Hi there,
You can post suggestions here.
You can also use cTrader CLI to interact externally with cBots.
Hi,
The API System.Environment.Exit(0);
which in version 4.0 use to shutdown the entire ctrader is now only shutting down the cbot and the cbot is restarting after shutting down.
Is there any API now, which I could use to shutdown that very instance of cTrader, like I was able to do in the older versions with the above API.
Please let me know as this is critical for me, my instance of ctrader is running many instances of a third party cBot which I want to shutdown before the market close (I dont want to close any position, I just want the cBots to shutdown that is why I had been shutting down cTrader itself with the above API).
Thanks.
@driftingprogrammer
PanagiotisCharalampous
02 May 2024, 07:13
RE: RE: Schedule stop and start of a particular ctrader profile on PC
driftingprogrammer said:
PanagiotisChar said:
Hi there,
You can post suggestions here.
You can also use cTrader CLI to interact externally with cBots.
Hi,
The API
System.Environment.Exit(0);
which in version 4.0 use to shutdown the entire ctrader is now only shutting down the cbot and the cbot is restarting after shutting down.
Is there any API now, which I could use to shutdown that very instance of cTrader, like I was able to do in the older versions with the above API.
Please let me know as this is critical for me, my instance of ctrader is running many instances of a third party cBot which I want to shutdown before the market close (I dont want to close any position, I just want the cBots to shutdown that is why I had been shutting down cTrader itself with the above API).
Thanks.
cBots now run in separate processes. If you want to close cTrader, you need to find the process and kill it
https://stackoverflow.com/questions/6046916/how-to-close-another-process-from-c-sharp
@PanagiotisCharalampous
driftingprogrammer
02 May 2024, 07:23
( Updated at: 02 May 2024, 10:25 )
RE: RE: RE: Schedule stop and start of a particular ctrader profile on PC
PanagiotisCharalampous said:
driftingprogrammer said:
PanagiotisChar said:
Hi there,
You can post suggestions here.
You can also use cTrader CLI to interact externally with cBots.
Hi,
The API
System.Environment.Exit(0);
which in version 4.0 use to shutdown the entire ctrader is now only shutting down the cbot and the cbot is restarting after shutting down.
Is there any API now, which I could use to shutdown that very instance of cTrader, like I was able to do in the older versions with the above API.
Please let me know as this is critical for me, my instance of ctrader is running many instances of a third party cBot which I want to shutdown before the market close (I dont want to close any position, I just want the cBots to shutdown that is why I had been shutting down cTrader itself with the above API).
Thanks.
cBots now run in separate processes. If you want to close cTrader, you need to find the process and kill it
https://stackoverflow.com/questions/6046916/how-to-close-another-process-from-c-sharp
Thanks for your response.
Can you please guide me on how I can identify the process I need to kill, I have 3 different profiles of cTrader running, each instance running 20 to 80 cbots.
@driftingprogrammer
driftingprogrammer
25 Oct 2023, 05:19 ( Updated at: 25 Oct 2023, 05:20 )
I acomplished this with the following approach
To close cTrader few hours before the market close I coded the below cBot
using System;
using System.Linq;
using System.Diagnostics;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class ShutdownTrendpilot : Robot
{
[Parameter("Trade before", DefaultValue = 25, MinValue = 0)]
public int EndTime { get; set; }
[Parameter("Trade after", DefaultValue = 4, MinValue = 0)]
public int StartTime { get; set; }
[Parameter("Wait in minutes", DefaultValue = 20, MinValue = 0)]
public int WaitPeriod { get; set; }
protected override void OnStart()
{
}
protected override void OnBar()
{
if (DateTime.Now.TimeOfDay.Hours < StartTime || DateTime.Now.TimeOfDay.Hours > EndTime)
{
System.Threading.Thread.Sleep(WaitPeriod * 60 * 1000);
System.Environment.Exit(0);
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
To start the cBot I wrote a batch file
start "" "C:\data\work\trendpilot_demo - Pepperstone cTrader.lnk"
And added a schedule in Windows scheduler to invoke the batch file few hours after the market open.
Spotware, if you are listening, can you please let me know how I can add an enhancement request to include in API the ability to start stop other third party cBots running in that instance of cTrader.
Thanks.
@driftingprogrammer