Topics
Forum Topics not found
Replies
amusleh
08 Apr 2022, 10:31
Hi,
Do you mean adding categories/folder support on cTrader automate cBots/Indicators list? Or showing the .NET solution projects hierarchy like Visual Studio? If you mean the later then you can use Visual Studio or any other .NET IDE (after 4.2 release) for it, in case of the former please create a new thread under suggestions section.
@amusleh
amusleh
08 Apr 2022, 10:26
Hi,
There is no need to create a new data series for that, you can work on a split of a data series, ex:
/// <summary>
/// Returns the minimum value between start and end (inclusive) index in a DataSeries
/// </summary>
/// <param name="dataSeries"></param>
/// <param name="startIndex">Start index Inclusive (Ex: 1)</param>
/// <param name="endIndex">End index Inclusive (Ex: 10)</param>
/// <returns>double</returns>
private double Minimum(DataSeries dataSeries, int startIndex, int endIndex)
{
var min = double.PositiveInfinity;
for (var i = startIndex; i <= endIndex; i++)
{
min = Math.Min(dataSeries[i], min);
}
return min;
}
/// <summary>
/// Returns the maximum value between start and end (inclusive) index in a DataSeries
/// </summary>
/// <param name="dataSeries"></param>
/// <param name="startIndex">Start index Inclusive (Ex: 1)</param>
/// <param name="endIndex">End index Inclusive (Ex: 10)</param>
/// <returns>double</returns>
private double Maximum(DataSeries dataSeries, int startIndex, int endIndex)
{
var max = double.NegativeInfinity;
for (var i = startIndex; i <= endIndex; i++)
{
max = Math.Max(dataSeries[i], max);
}
return max;
}
@amusleh
amusleh
07 Apr 2022, 09:16
( Updated at: 21 Dec 2023, 09:22 )
Hi,
The Chart drawings are working fine in Visual back test mode, ex:
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TestDrawing : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Price { get; set; }
protected override void OnStart()
{
var line = Chart.DrawHorizontalLine("1", Price, Color.Red);
line.IsInteractive = true;
}
}
}
Result:
If you set the IsInteractive property of a chart object to True then it will remain on chart even if back test stop, otherwise the objects will be removed from the chart on back test stop.
In non visual mode the chart drawings will not show up.
@amusleh
amusleh
07 Apr 2022, 09:06
Hi,
All cTrader services use cTrader Proxy cloud, please read: cTrader Proxy Cloud | Solving Last Mile Latency | Spotware Systems Ltd
@amusleh
amusleh
07 Apr 2022, 09:02
Hi,
If your cBot/Indicator is built with previous version of cTrader then you need Visual Studio 2019 for opening it.
For cBots/Indicators that are built with cTrader 4.2 you need Visual Studio 2022.
Installing Visual Studio 2019 might solve this issue, you can install both Visual Studio 2019 and 2022.
@amusleh
amusleh
07 Apr 2022, 08:00
Hi,
Check the API references for a sample: Event Closed | API reference | cTrader Community
@amusleh
amusleh
05 Apr 2022, 14:17
( Updated at: 21 Dec 2023, 09:22 )
RE: RE:
hejnekem said:
firemyst said:
> Hi, I would like to run this bot on different instances, but I couldnt do it. I tried label and symbol too.
What do you mean?
To run multiple instances of a bot, just add more "instances" under the bot and choose the symbol you want to run it against.
Example:
In teh above, one instance will run on EURUSD H1 timeframe, the other bot will run under the US30 symbol.
It doesnt work, because when I start a second instance it doesnt start, other times the first instance closes the second one.
Hi,
Are you sure it's a cTrader cBot code? It uses some APIs that is not part of cTrader automate API.
@amusleh
amusleh
05 Apr 2022, 09:54
Hi,
When you are using Nuget packages on your Indicators/cBots that target .NET framework you have to use the .NET SDK compiler, you can't use embedded compiler for those types of Indicators/cBots.
You can change the .NET compiler from your cTrader settings -> Automate tab.
@amusleh
amusleh
05 Apr 2022, 09:52
Hi,
The account balance is updated when you close a position, or you deposit/withdraw funds, for later two there is no way to know that but for position close you can use the Positions Closed event.
So what you need to do is first subscribe to Positions.Closed event and then move your calculation logic to Positions closed event handler.
@amusleh
amusleh
05 Apr 2022, 09:44
RE: RE: RE: Code to make this work?
william@hallsdesign.co.uk said:
Hi,
I have been going round in circles with this, and all I want is the current price of a pair I have. I have everything, all my code is placing a trade etc.. But only if I manually add the price in for my pair and run my code.
I have tried all the subscribing and ProtoOASpotEvent stuff. If you wouldnt mind helping me out with the exact code you did, that would be greatly appreciated. I just wish they would allow you to place a market order with a stopLoss and takeProfit without having to faff with all of this!!Thanks in advance
William
Hi,
To receive live quotes of a symbol you have to send a ProtoOASubscribeSpotsReq, after that you will keep receiving ProtoOASpotEvent(s) which will contain the latest symbol bid/ask prices.
For code example please check the console sample of OpenApiPy: OpenApiPy/main.py at main · spotware/OpenApiPy (github.com)
For creating a new market order you have to send a ProtoOANewOrderReq: OpenApiPy/main.py at 50b00db0a2570d4cb62ab0a191501f49aa5ea191 · spotware/OpenApiPy (github.com)
You can set the stop loss and take profit in relative: Messages - cTrader Open API (spotware.github.io)
@amusleh
amusleh
08 Apr 2022, 10:40
Hi,
You can separate each instance orders by using the Symbol name, example:
The BotPendingOrders enumerable will give you only those orders that are from same symbol and with same Label.
@amusleh