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 ?
How to optimize my code ?
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 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.
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.
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
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