cBots are based on .Net. Therefore you can only call dll files based on managed code. If your dll is based on managed code, you should be able to use it.
Best regards,
Panagiotis
Thanks for the reply. I figured that was the case. I got a DLL written in managed C/C++. I need to be able to call this DLL from the cBot. I guess the only way to do that is to create a .Net DLL proxy that will call my C++ DLL?
I created a .NET DLL wrapper class that calls my unmanaged C++ DLL functions ok. I added the code below to the cBot and it compiles fine in cTrader but when I run the cBot it says it can't find the DLL even though the DLL is in the same directory?
13/08/2024 22:06:42.127 | Info | CBot instance [Client_CBOT, EURUSD, h1] started. 13-08-2024 22:06:42.908 | Error | Crashed in OnStart with DllNotFoundException: Unable to load DLL 'Client.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
Any ideas? Do I have to use the .NET DLL wrapper… doesn't make sense to do that when cBot is built in .NET?
Make sure your dll is copied to the output directory. Check the Copy Local property and make sure is set to true
using System;using cAlgo.API;namespace cAlgo.Robots { [Robot(AccessRights = AccessRights.None, AddIndicators = true)] public class TESTlistenonly : Robot { public WebSocketClient client; public string uri; protected override void OnStart() { Print("attempting connection"); client = new WebSocketClient(); var uri = new Uri("wss://server:25345/"); client.Connect(uri); Print("WebSocket connection opened"); } }}
I have my own server running on port 25345 and it works on local execution but on the cloud it says this
There was no mention of web sockets in the initial post. Yes, it's possible to use web sockets through port 25345. Does your server listen to this port?
This field is not available at the moment. It will be added in a future update.
Best regards,
Panagiotis
by any chance can you tell me when it will be released approximately? and if the platform will update automatically or will I have to search for it on the site
Hi there,
The platform will update automatically but I do not have a date for the update.
If you are looking to delete your demo accounts, you can use the link below. Please make sure you have closed all your positions and canceled all your orders before deleting your accounts.
…we cannot change something that works and thousands of cBots are built on it…
Though this post is a bit old, I disagree with the statement as I see the opposite being true all the time.
You are not really changing something that has thousands of working code relying on it, you create a new one and cleverly separate the two so people have time to adapt to the new version (and you give help and hints on the way to assist them). Otherwise you are locking yourself to a fixed path and I'm sure what was good and mainstream 10 years ago is outdated today. You cannot maintain v1.0 compatibility forever.
Most of the programming languages do this between major versions but Python is a good example with its change between v2.x and v3.x. As a trading language example Tradingview uses code version annotation in their Pine script to allow them completely revamp the code if they want to.
Hi there,
The argument was about changing OnBar() method, not adding something new. Since then we have added OnBarClosed() method for this purpose.
You need to understand how cTrader and trading works. The event is not triggered late. It's triggered as soon as the message arrives from the server. There will always be latency between the price closing the position and the execution of the order. You can't know that something happened before it happened.
Spotware cTrader is used for demonstration purposes only and the settings are not kept up to date. If you wish to backtest on realistic market data, it is better to use your broker's demo account.
It makes a lot of sense if cTrader cant provide accurate real time data.
Is there a way via code to tell cTrader at OnTick to check *now* from the broker the positions status instead of waiting for the Positions.Closed event to be triggered?
Thanks
Broker is using the cTrader platfrom. The positions information is stored in cTrader Server. cTrader Desktop gets its information from cTrader Server. This information is available on Positions collection. There is no other source of positions. There is no way to know that a position has closed before the Positions.Closed event is triggered.
There is a way to do it, but you have to code it into your bots. Here's an example:
//Get historical tradePosition p1 = args.Position;//Running Totals_runningTotalsPipsGainedLost += p1.Pips;_runningTotalsNetGainLoss += p1.NetProfit//Stop the bot if the running net gain/loss pips falls below our specified amountif (_runningTotalsPipsGainedLost < StopBotWhenPipLossesFallBelow){ //stop bot Stop();}//Stop the bot if the running net gain/loss total falls below our specified amountif (_runningTotalsNetGainLoss < StopBotWhenLossesFallBelow){ //stop bot Stop();}
Note that this only works on each individual bot instance for each bot.
If you want the running totals to be across all instances of a particular bot, then you need to set static variables that are public that all bot code would have access to.
Have your bots check that value every time they start, and before entering any positions. If that global static amount is below a certain threshold, either stop your bot, or don't allow it to enter a new position.
I assume that the trader wants to block trading for the entire account.
PanagiotisCharalampous
14 Aug 2024, 10:13
RE: RE: RE: RE: RE: Calling DLL functions help.
rick2010 said:
Make sure your dll is copied to the output directory. Check the Copy Local property and make sure is set to true
@PanagiotisCharalampous