How to optimize my code ?

Questions about MultiCharts and user contributed studies.
User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

How to optimize my code ?

Postby TJ » 05 Sep 2007

I realized my codes are not efficient.

How can i optimize my code ?

is there any books or tutorial out there?

any tips or trick? or FAQ on efficient coding ?

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 05 Sep 2007

Hello TJ,

It is hard to give any specific recommendations. The skill to write efficient codes comes with gaining overall experience and knowledge in programming.

In general, the following aspects of the code might be inefficient:

1. algorithm
2. algorithm implementation
3. inefficient employment of PowerLanguage functionality.

What you could do is seek help with professional EasyLanguage programmers who could do refactoring for your codes. It is not uncommon for indicators to work 100 of times (and up) faster after refactoring.

Nick
Posts: 496
Joined: 04 Aug 2006
Has thanked: 4 times
Been thanked: 24 times

Postby Nick » 06 Sep 2007

What are you trying to do TJ? many things have more elegant solutions. For example a common way of calculating a moving average is (in pseudo code)

sum=0
for n = 0 to averagelength-1 sum=sum+close[n];
average=sum/averagelength

This is a grossly inefficient way of doing things much better is to add the new data point and remove the one from 'length' periods ago. this eliminates the loop. I would say 9 out of 10 times the problem is loops or worse nested loops.

Cheers,
Nick


Return to “MultiCharts”