simple code Websocket on cBots

Created at 07 Mar 2024, 23:18
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Manisit's avatar

Manisit

Joined 07.03.2024

simple code Websocket on cBots
07 Mar 2024, 23:18


Hello, 

I have developed robots on MT4/MT5 and am interested in trying to develop on cTrader

I still don't understand how to use Websockets on cBot as shown in the example https://help.ctrader.com/ctrader-automate/guides/websocket-client/

However, the problem is that when I tried copying the code to use, it resulted in errors, and there are no examples for me to follow.

And another question, can I use other library on GuNet (Visual Studio)?

 


@Manisit
Replies

firemyst
10 Mar 2024, 03:12 ( Updated at: 10 Mar 2024, 05:44 )

"However, the problem is that when I tried copying the code to use, it resulted in errors, and there are no examples for me to follow."

Have you even tried Google?

A simple search on “c# websocketclient example” brings back a list of websites, and the first one (medium.com) has a complete example including how to add it to your project using the NuGet package manager.

https://www.google.com/search?q=c%23+websocketclient+example&sca_esv=8b94fdf9c54254b4&source=hp&ei=PyTtZbCOE6TP7_UPoLuc4Ag&iflsig=ANes7DEAAAAAZe0yT3nG5JowWnfbTh6aAtNPKXoeGw1O&oq=c%23+webSocketClient&gs_lp=Egdnd3Mtd2l6IhJjIyB3ZWJTb2NrZXRDbGllbnQqAggBMgUQABiABDIGEAAYFhgeMgsQABiABBiKBRiGAzILEAAYgAQYigUYhgMyCxAAGIAEGIoFGIYDSP1CUABYgR5wAHgAkAEAmAH3AaABqByqAQYwLjExLje4AQPIAQD4AQGYAhKgAtYcwgIOEC4YgAQYsQMYxwEY0QPCAggQABiABBixA8ICCxAAGIAEGLEDGIMBwgILEC4YgAQYsQMYgwHCAggQABgWGB4YCpgDAJIHBTAuOS45oAeOUA&sclient=gws-wiz

 


@firemyst

Manisit
10 Mar 2024, 06:39 ( Updated at: 10 Mar 2024, 15:21 )

RE: simple code Websocket on cBots

firemyst said: 

"However, the problem is that when I tried copying the code to use, it resulted in errors, and there are no examples for me to follow."

Have you even tried Google?

A simple search on “c# websocketclient example” brings back a list of websites, and the first one (medium.com) has a complete example including how to add it to your project using the NuGet package manager.

https://www.google.com/search?q=c%23+websocketclient+example&sca_esv=8b94fdf9c54254b4&source=hp&ei=PyTtZbCOE6TP7_UPoLuc4Ag&iflsig=ANes7DEAAAAAZe0yT3nG5JowWnfbTh6aAtNPKXoeGw1O&oq=c%23+webSocketClient&gs_lp=Egdnd3Mtd2l6IhJjIyB3ZWJTb2NrZXRDbGllbnQqAggBMgUQABiABDIGEAAYFhgeMgsQABiABBiKBRiGAzILEAAYgAQYigUYhgMyCxAAGIAEGIoFGIYDSP1CUABYgR5wAHgAkAEAmAH3AaABqByqAQYwLjExLje4AQPIAQD4AQGYAhKgAtYcwgIOEC4YgAQYsQMYxwEY0QPCAggQABiABBixA8ICCxAAGIAEGLEDGIMBwgILEC4YgAQYsQMYgwHCAggQABgWGB4YCpgDAJIHBTAuOS45oAeOUA&sclient=gws-wiz

 

I understand how to write a WebSocket client, but the problem is that I still don't understand what your system allows.

Can I use external libraries, or are there any built-in functions available?

Because when I try writing it in my way, it can't connect to the mock WebSocket server


@Manisit

Manisit
10 Mar 2024, 10:14 ( Updated at: 10 Mar 2024, 15:21 )

RE: simple code Websocket on cBots

firemyst said: 

"However, the problem is that when I tried copying the code to use, it resulted in errors, and there are no examples for me to follow."

Have you even tried Google?

A simple search on “c# websocketclient example” brings back a list of websites, and the first one (medium.com) has a complete example including how to add it to your project using the NuGet package manager.

https://www.google.com/search?q=c%23+websocketclient+example&sca_esv=8b94fdf9c54254b4&source=hp&ei=PyTtZbCOE6TP7_UPoLuc4Ag&iflsig=ANes7DEAAAAAZe0yT3nG5JowWnfbTh6aAtNPKXoeGw1O&oq=c%23+webSocketClient&gs_lp=Egdnd3Mtd2l6IhJjIyB3ZWJTb2NrZXRDbGllbnQqAggBMgUQABiABDIGEAAYFhgeMgsQABiABBiKBRiGAzILEAAYgAQYigUYhgMyCxAAGIAEGIoFGIYDSP1CUABYgR5wAHgAkAEAmAH3AaABqByqAQYwLjExLje4AQPIAQD4AQGYAhKgAtYcwgIOEC4YgAQYsQMYxwEY0QPCAggQABiABBixA8ICCxAAGIAEGLEDGIMBwgILEC4YgAQYsQMYgwHCAggQABgWGB4YCpgDAJIHBTAuOS45oAeOUA&sclient=gws-wiz

 

I've attempted to use other WebSocket client libraries that I've previously developed .NET apps with. However, they fail to connect to the WebSocket server. I don't understand if there's anything additional I need to set to allow this?

Development isn't hard for me, it's just that I still don't understand what your system entails, what can be used, and there are very few examples

 


@Manisit

Manisit
10 Mar 2024, 15:52 ( Updated at: 11 Mar 2024, 07:41 )

RE: RE: simple code Websocket on cBots

Manisit said: 

firemyst said: 

"However, the problem is that when I tried copying the code to use, it resulted in errors, and there are no examples for me to follow."

Have you even tried Google?

A simple search on “c# websocketclient example” brings back a list of websites, and the first one (medium.com) has a complete example including how to add it to your project using the NuGet package manager.

https://www.google.com/search?q=c%23+websocketclient+example&sca_esv=8b94fdf9c54254b4&source=hp&ei=PyTtZbCOE6TP7_UPoLuc4Ag&iflsig=ANes7DEAAAAAZe0yT3nG5JowWnfbTh6aAtNPKXoeGw1O&oq=c%23+webSocketClient&gs_lp=Egdnd3Mtd2l6IhJjIyB3ZWJTb2NrZXRDbGllbnQqAggBMgUQABiABDIGEAAYFhgeMgsQABiABBiKBRiGAzILEAAYgAQYigUYhgMyCxAAGIAEGIoFGIYDSP1CUABYgR5wAHgAkAEAmAH3AaABqByqAQYwLjExLje4AQPIAQD4AQGYAhKgAtYcwgIOEC4YgAQYsQMYxwEY0QPCAggQABiABBixA8ICCxAAGIAEGLEDGIMBwgILEC4YgAQYsQMYgwHCAggQABgWGB4YCpgDAJIHBTAuOS45oAeOUA&sclient=gws-wiz

 

I've attempted to use other WebSocket client libraries that I've previously developed .NET apps with. However, they fail to connect to the WebSocket server. I don't understand if there's anything additional I need to set to allow this?

Development isn't hard for me, it's just that I still don't understand what your system entails, what can be used, and there are very few examples

 

 

Currently, I can fix it by modifying this topic

[Robot(AccessRights = AccessRights.None)]

Modified to

[Robot(AccessRights = AccessRights.FullAccess)]


@Manisit