Pieces of long code to be stored in a script or library

Created at 07 Dec 2018, 04:19
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!
mparama's avatar

mparama

Joined 11.10.2016

Pieces of long code to be stored in a script or library
07 Dec 2018, 04:19


Dear Panagiotis,

in many of my bots I have the same pieces of long code.

There is a way to store it in a script or library and recall it back in a cBot with a simple line of code instead of hundreds line of code ?

Thank you very much for your always kind help


@mparama
Replies

PanagiotisCharalampous
07 Dec 2018, 10:23 ( Updated at: 21 Dec 2023, 09:21 )

Hi Luigi,

A cBot is nothing less than a C# project. So if you edit it using Visual Studio you can have all the options available for a C# project. This means that you can have separate classes for reusable code. See below an example of calling a function of another class inside the cBot.

This way you can organize your code in a proper object oriented approach. Let me know if you need any additional assistance.

Best Regards,

Panagiotis


@PanagiotisCharalampous

mparama
07 Dec 2018, 18:33 ( Updated at: 21 Dec 2023, 09:21 )

RE:

Panagiotis Charalampous said:

Hi Luigi,

A cBot is nothing less than a C# project. So if you edit it using Visual Studio you can have all the options available for a C# project. This means that you can have separate classes for reusable code. See below an example of calling a function of another class inside the cBot.

This way you can organize your code in a proper object oriented approach. Let me know if you need any additional assistance.

Best Regards,

Panagiotis

Thank youv very much !!!!


@mparama

ctid581738
10 Jun 2023, 17:40 ( Updated at: 21 Dec 2023, 09:23 )

Hi Panagiotis! It seems, each Indicator and Bot uses its own project. So, how is it possible to share code between projects (Indicators or Bots)?

PanagiotisCharalampous said:

Hi Luigi,

A cBot is nothing less than a C# project. So if you edit it using Visual Studio you can have all the options available for a C# project. This means that you can have separate classes for reusable code. See below an example of calling a function of another class inside the cBot.

This way you can organize your code in a proper object oriented approach. Let me know if you need any additional assistance.

Best Regards,

Panagiotis

 


@ctid581738