Advice on Best Practices for Designing Indicators

Created at 13 Jun 2024, 09:10
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!
PE

PerfAlgo

Joined 13.06.2024

Advice on Best Practices for Designing Indicators
13 Jun 2024, 09:10


Hello Community,

I’m working on a new indicator that combines several ideas. I’m trying to figure out the most efficient way to build it and would love your thoughts.

I have two potential design strategies:
1. Modular Approach: I build separate indicators for each part of the logic, then pull these together into one main indicator. This way, I can reuse parts of the indicator elsewhere.
2. Integrated Approach: I put all the logic into one indicator. This may be faster because it reduces the need for the indicators to talk to each other, but it might make the indicator less flexible for other uses.

My questions are:
- Is there a big difference in performance between these two approaches in practical scenarios?
- Does cTrader handle these differently in terms of efficiency?

I’d like to know if the difference is big enough to affect how I should build this. Any advice or experiences you can share would be really helpful.
Thanks!


@PerfAlgo
Replies

PanagiotisCharalampous
13 Jun 2024, 10:22

Hi there,

It's hard to give definite answers in such vague descriptions. In principle if the code is the same, there should not be any difference. cTrader does not do anything special. It just executes your code.

Best regards,

Panagiotis


@PanagiotisCharalampous

firemyst
17 Jun 2024, 09:13

Best practices are generally not what you described, but more like how specific parts of indicators are implemented.

 

  • For instance, there's been plenty of examples posted in these forums (that I've commented on) where people do the “GetBars” on every single tick. Bad! 
  • Or where people have an expression like “x * 3” a dozen times throughout the same method. Bad! 
  • Or where people draw a horizontalline, trendline, or other line, that only changes once per bar, on every tick. Bad! 

 

Lots of things like the above (to name a few) will affect performance. Maybe not enough for users to notice it, but they unnecessarily use up cpu-cycles from the rest of cTrader.

 


@firemyst