Using this news class file you can now easily integrate the cTrader Forex News Manager into your very own trading robot, the download is free and it includes the C#class that you can add to your existing project.
What Does It Do?
This is a code library in the form of a C# class that you can add to your existing cTrader cBot or indicator to pause trading during major news events, you can also close any open trades to prevent your stops from being taken out when there is high volatility.
How Does it Work?
This API does not work alone, you will need to download the ClickAlgo News Manager, it is this cBot that will send a signal to be picked up by this API in your automated trading systems or cBots. It works by the news manager loading the next week's news events before they happen a file is created in the shared cTrader folder below.
Each of the files above is named using the currency-NRM.json, if you open the file with a simple text or JSON editor you will see the data read by the class API. When there is an upcoming news event the value will change to true.
{
"Value": "false",
"WriteTime": "2023-12-30T07:42:18.473+00:00",
"Writer": {
"Type": "Robot",
"Name": "ClickAlgoNewsManager",
"InstanceId": "2d3451d7-ca51-4243-afdd-e133a4786d66"
}
}
How Do I Use It?
The code below shows a basic cBot with example code that you can use in your trading robot or even indicator to manage news events, the class API handles closing trades and this can be set when you construct the NewsSignal class with an additional parameter at the end (true). When you download the file from this page you will get the complete cBot source code including the class API which handles the news events.
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ClickAlgoNewsManagerExample : Robot
{
private NewsSignal _newsSignal;
protected override void OnStart()
{
// configure news release manager client
_newsSignal = new NewsSignal(this, this.SymbolName);
// use this if you do not want to close positions
//_newsSignal = new NewsSignal(this, this.Symbol.Code, true;
}
protected override void OnBar()
{
// if there is a news release event in progress, exit method, pause robot
if (_newsSignal.IsNewsRelease)
{
return;
}
// add your logic here to manage trades
}
protected override void OnTick()
{
// if there is a news release event in progress, exit method, pause robot
if (_newsSignal.IsNewsRelease)
{
return;
}
// add your logic here to manage trades
}
}
}
How To Install & Remove
First, make sure you have the cTrader trading platform installed and then unzip the file and double-click on it to automatically install it onto the platform.
Any Questions?
If you have any questions or if there are any bugs, please first search our product help forum for the answer, if you cannot find it, post a new question.
Need a Broker
If you are still looking for a broker you can trust, take a look at our best cTrader broker site.