Proper Encapsulation

Created at 01 May 2016, 09:21
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!
MA

martinplatt.com

Joined 01.05.2016

Proper Encapsulation
01 May 2016, 09:21


Hi Guys,

I'm just getting into cAlgo - I'm a coder in .NET since beta versions, just getting into the API.

Is there any way that I could pass about information like that market information?  

I wanted to create a class to categorize candles for recognition purposes, but I have no idea if I can do that without categorization being part of the indicator or bot class directly?  I'd like to separate and decouple the various parts of the code.

I mean, if I had a Candle object, and some code - call it CandleCategorizer, is there a way that CandleCategorizer could be able to pull out the OHLC values, and populate the Candle objects, for example?

Ultimately I want to be able to decouple the MarketSeries interface from the other objects, so that they can work independently?

Ultimately is there information on the types of these API Interfaces, so that I could encapsulate everything, should I wish to?  Is the an Interface type that I could use for example, like IDataSource or something like that?

 

Cheers,

 

Martin.

 


@martinplatt.com
Replies

martinplatt.com
01 May 2016, 09:28

I'd like an answer on the Interfaces question, however, after a coffee - that was the key - I can use logic in the Indicator or robot to call constructors for a candle object, passing in the relevant values, then get it to initialize and categorize itself.  Doh.  Apologies for asking that daft question!


@martinplatt.com

ClickAlgo
02 May 2016, 10:00

Hi Martin,

You should be able to just extend the API with your own object hierarchy to suit any patterns you would like to implement, you will also serialize the data for persistence.

My apologies if you already know this, but all your candle patterns would benefit from using Unified Modelling (UML) or amore modern technique with Agile Modelling (AM)

The API is very basic and has limited or no interface-based architecture as far as I am aware, if you create a simple cBot you should be able to see all that is available through the Robot base class.


@ClickAlgo

martinplatt.com
02 May 2016, 10:16

RE:

Paul_Hayes said:

Hi Martin,

You should be able to just extend the API with your own object hierarchy to suit any patterns you would like to implement, you will also serialize the data for persistence.

My apologies if you already know this, but all your candle patterns would benefit from using Unified Modelling (UML) or amore modern technique with Agile Modelling (AM)

The API is very basic and has limited or no interface-based architecture as far as I am aware, if you create a simple cBot you should be able to see all that is available through the Robot base class.

Hey Paul,

Nice to meet you.

Candle patterns - I didn't mean programming patterns, I meant things like so that I could easily recognise say a bearish engulfing bar, morning star and so on.  

Am very familiar with UML, and the various modelling, the problem I was having from the basic look at cAlgo, was that I couldn't find a definition for the interface as such, and therefore as I wanted to use my own interface and decouple the code I write (MarketSeries seems from first looks as if it's a bit of an all purpose class that really should be decomposed?).  I'm sure I can do that, it will just have to be via trial and error, by the looks.

I think this is a little a case of my unfamiliarity with the interface, although I have bots going, and think I have my head around things a little more now.  

I don't want to have things like MarketSeries floating around other unrelated classes, and this was what I was hoping to get a proper definition of.

To do things in a nice clean OO manner, we need to be able to do that, else what we have is basically the same deal as with MT4, but in C#.  

In MT4 for example I went to C++ to try to get a nice library going, which in the most part works, just that MT4 is a bit old, and not seems to struggle to do anything at any sort of speed when there is a class hierarchy.

With MT4, you could however create classes and put them into an "include" folder, and have subfolders, so they were easily accessible.  Doesn't seem possible in cAlgo at this point.  I hope this changes, as it has a lot of potential.

Cheers,

 

Martin.


@martinplatt.com

ClickAlgo
02 May 2016, 11:55 ( Updated at: 21 Dec 2023, 09:20 )

Hi Martin, 

Nice to meet you too.

I assume you are using Visual Studio and not the cAlgo platform for development. You can design your architecture for you candle patterns with separate assemblies if you wish for portability. Again I am sorry if you already know this, but the images below demonstrates how you can manage your logic with visual studio. 

If you want to chat further for me to help you get kick started with the cTrader API, just email me direct at development@clickalgo.com


@ClickAlgo