Topics
Forum Topics not found
Replies
amusleh
09 Dec 2021, 09:35
Hi,
1. To get the last candle data which is not closed yet you can use Bars.Last(0) or Bars[Bars.Count - 1].
2. For displaying the data on chart you can use either chart controls or chart objects, please the examples on API references:
cAlgo API Reference - Symbol Interface (ctrader.com)
cAlgo API Reference - ChartText Interface (ctrader.com)
cAlgo API Reference - ChartStaticText Interface (ctrader.com)
3. You can use pending order expiry time parameter to set a time based expiry for your pending orders, for 30 minute your code looks correct to me, you have to post the error then I will be able to help you.
4. In cTrader each order or position that you open will have their own ID property, those IDs are unique and you can access it by using position or pending order Id property, you can also assign label or comment for orders if you want to, for more please check the API reference examples:
cAlgo API Reference - Position Interface (ctrader.com)
cAlgo API Reference - Positions Interface (ctrader.com)
6. Not sure what do you mean by deep market data, do you mean market order book data? check the API references example for market depth:
cAlgo API Reference - MarketDepth Interface (ctrader.com)
Please open separate threads for each of your questions in future, that will make it much easier for us to respond.
@amusleh
amusleh
08 Dec 2021, 10:16
Hi,
You can't use optimizer for multi symbol optimization, right now the optimizer can only work with single symbol cBots.
The cTrader back tester does support multi symbol cBots back testing.
The multi symbol optimization will be added on cTrader desktop version 4.2.
@amusleh
amusleh
08 Dec 2021, 09:09
Hi,
You can create a dashboard with Automate API, there are lots of possible ways you can create a dashboard.
You can use ChartObjects, Chart controls, WinForms, or WPF.
If you have no knowledge of C# and .NET then it will be hard for you, but you can try and search on cTrader.com for dashboard, you might find some open source indicators that you can modify based on your needs.
@amusleh
amusleh
08 Dec 2021, 09:05
RE: RE:
george.secillano said:
amusleh said:
Hi,
We are aware of this issue and it will be fixed on future releases, thanks for reporting.
Good to know, thanks!
Current version: 76
Where is the server version upgrade announced? Do you have an ETA?
Hi,
I can't give you any ETA, but you can follow our Github proto message repository for updates and new releases: spotware/openapi-proto-messages: Open API Proto Messages (github.com)
@amusleh
amusleh
08 Dec 2021, 08:50
RE: Yes plz enable negative value
TommyFFX said:
What's the point of Fibonacci alone without the expansion or negative values to target prices. Many regards and hopefully this will be added soon. Just switched from mt4 to cTrader and this is my first obstacle on cTrader otherwise love it, done with mt4
Hi,
You can use our Fibonacci drawing indicator if you need more features.
@amusleh
amusleh
08 Dec 2021, 08:45
Hi,
The order filled event will be triggered if an order gets filled fully or partially, there is no event for partial fill and you can use the filled event to check if the order is filled partially or fully by subtracting the position volume from pending order volume.
@amusleh
amusleh
07 Dec 2021, 16:11
RE: RE:
sirinath said:
amusleh said:
Hi,
The events are for all orders, there is no specific event for a single order.
You have to assign a comment or label for your order and subscribe to PendingOrders or Positions events, you can then check if the event got triggered was related to the order that you wanted to track or not.
Many thanks for the response. What are the order / trade related events in cTrader and how can I listen to them?
Please check the API references:
cAlgo API Reference - Positions Interface (ctrader.com)
cAlgo API Reference - PendingOrders Interface (ctrader.com)
@amusleh
amusleh
07 Dec 2021, 09:24
RE: RE:
xiao-linlong said:
amusleh said:
Hi,
If mouse cursor is over order/alert lines then none of the mouse events will work, and the chart mouse leave event will be triggered.
To solve this issue you can hide the cTrader order/alert lines and instead manage your orders only with your own quick order tool.
Here is an example on how you can capture the last mouse cursor location:
using cAlgo.API; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Test : Robot { private double _lastMouseX, _lastMouseY; protected override void OnStart() { Chart.MouseMove += Chart_MouseMove; Chart.MouseEnter += Chart_MouseEnter; Chart.MouseLeave += Chart_MouseLeave; } // This event will be triggered if mouse cursor goes over chart order/alert lines // When this event got triggered all other mouse events will stop working as the cursor is not over chart private void Chart_MouseLeave(ChartMouseEventArgs obj) { } // This event will be triggered if mouse cursor cameback to chart from order/alert lines // When this event got triggered all mouse events will start working back private void Chart_MouseEnter(ChartMouseEventArgs obj) { } private void Chart_MouseMove(ChartMouseEventArgs obj) { _lastMouseX = obj.MouseX; _lastMouseY = obj.MouseY; } } }
Dear Sir:
"Quicktrade" is not affected by the order/alarm line. It would be great if our button could be dragged and dropped to any place like the "Quicktrade" button. After hiding the cTrader order/alarm line, there is no even the button to close the order. In addition, the order line and the alarm line themselves only have the function of prompting, and there is no operation meaning, because the move/double/close all need to click the leftmost button , I don’t know why the line affects the mouse event. I hope the team will consider solving the problem of cTrader order/alarm line affecting the order in the next version. You have also seen that more than I have encountered this trouble, many friends have encountered this Troubled. thanks.
Hi,
Please open a thread for this on suggestions section and if it got enough voter by community we will change this behavior if already haven't opened one yet.
@amusleh
amusleh
07 Dec 2021, 09:23
Hi,
The Bars[0] will give you the first bar on the chart, if you want to get the latest open bar you have to use Bars[Bars.Count - 1] or Bars.LastBar or Bars.Last(0).
If you want to get the latest closed bar you can use Bars.Last(1) or Bars[Bars.Count - 2].
if you get the last bar it will be not completed or closed yet, so the bar high, low and close prices can change until the bar is finished or closed.
@amusleh
amusleh
07 Dec 2021, 09:19
Hi,
All pending orders are in PendingOrders collection, and you can use Linq queries to filter, sort, or group them, here is an example of filtering orders based on label:
var myLabel = "MyLabel";
var pendingOrdersWithMyLabel = PendingOrders.Where(order => order.Label.Equals(myLabel, System.StringComparison.OrdinalIgnoreCase));
To use Linq you have to add the "using System.Linq" on top of your indicator or cBot, for more about Linq check here: Language-Integrated Query (LINQ) (C#) | Microsoft Docs
@amusleh
amusleh
07 Dec 2021, 09:15
Hi,
The events are for all orders, there is no specific event for a single order.
You have to assign a comment or label for your order and subscribe to PendingOrders or Positions events, you can then check if the event got triggered was related to the order that you wanted to track or not.
@amusleh
amusleh
06 Dec 2021, 09:10
RE:
dudegrowth said:
Hi,
I've been trying for 2 days now and i'm not being lucky in trying some github repos that already made nodejs version of open api v2.
I've tried this library which at first part it looked to me that i found the solution i was searching for but still im not able to do anything with it because in first part when i try to connect with it it fails. https://github.com/Reiryoku-Technologies/Mida.
Did you found any solution regard that?
Hi,
Did you tried this one: Reiryoku-Technologies/cTrader-Layer: A Node.js communication layer for the cTrader Open API. (github.com)
@amusleh
amusleh
06 Dec 2021, 09:08
Hi,
This code example might help you:
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Test : Robot
{
protected override void OnStart()
{
var maxNetProfitPosition = GetMaxNetProfitPosition();
if (maxNetProfitPosition != null)
{
ClosePosition(maxNetProfitPosition);
}
}
private Position GetMaxNetProfitPosition()
{
Position result = null;
foreach (var position in Positions)
{
if (result == null)
{
result = position;
continue;
}
if (position.NetProfit > result.NetProfit)
{
result = position;
}
}
return result;
}
}
}
@amusleh
amusleh
06 Dec 2021, 09:01
Hi,
If mouse cursor is over order/alert lines then none of the mouse events will work, and the chart mouse leave event will be triggered.
To solve this issue you can hide the cTrader order/alert lines and instead manage your orders only with your own quick order tool.
Here is an example on how you can capture the last mouse cursor location:
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Test : Robot
{
private double _lastMouseX, _lastMouseY;
protected override void OnStart()
{
Chart.MouseMove += Chart_MouseMove;
Chart.MouseEnter += Chart_MouseEnter;
Chart.MouseLeave += Chart_MouseLeave;
}
// This event will be triggered if mouse cursor goes over chart order/alert lines
// When this event got triggered all other mouse events will stop working as the cursor is not over chart
private void Chart_MouseLeave(ChartMouseEventArgs obj)
{
}
// This event will be triggered if mouse cursor cameback to chart from order/alert lines
// When this event got triggered all mouse events will start working back
private void Chart_MouseEnter(ChartMouseEventArgs obj)
{
}
private void Chart_MouseMove(ChartMouseEventArgs obj)
{
_lastMouseX = obj.MouseX;
_lastMouseY = obj.MouseY;
}
}
}
@amusleh
amusleh
06 Dec 2021, 08:51
RE: RE:
ncel01 said:
Hi Panagiotis,
I forgot to mention but both my question and the example I provided was about indexes and not FX pairs.
PanagiotisCharalampous said:
Hi ncel01,
No, the equation is the one I provided above, assuming that the unit of measurement of the margin i.e. the currency, is the same to the one used for the account. Else you will need to make the relevant conversions.
Best Regards,
Panagiotis
Hi,
Without conversion you will not be able to calculate the used or required margin for all symbols.
And for conversion you need a symbol base asset and quote asset, also you need the symbol conversion chain which are not available right now in automate API.
You can open a thread on suggestions section for adding the symbol conversion feature if you want to.
@amusleh
amusleh
10 Dec 2021, 09:18
Hi,
Please post your cBot/indicator code, otherwise we can't replicate this error and we will not be able to help you.
Be sure your broker symbol names match the ones you use inside your cBot code.
@amusleh