Hello,
I have a fairly complex calculation that I use several times.
would a function for the calculation be faster when optimizing or is it faster to create new variables for each iteration of the calculation?
Second thought or question...
This FAQ thread is awesome...viewtopic.php?t=10811
I haven't seen many posts about how to increase optimization speed. Curious if there was a good post about optimization speed that anyone knew about?
Faster optimization speed question and a thought
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Faster optimization speed question and a thought
I am glad you find it useful.
Good trading to you.
Re: Faster optimization speed question and a thought
I am glad you find it useful.
Good trading to you.
Awe dang... no tips on the speed question... I thought for sure you would have some input.. hahah
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Faster optimization speed question and a thought
My understanding is, the function is a "human" short cut.
When MC compiles the indicator, the function code is inserted back into the script wherever it appears.
However, all is not lost. Good coding practice can speed up the execution.
For example:
should be written as
When MC compiles the indicator, the function code is inserted back into the script wherever it appears.
However, all is not lost. Good coding practice can speed up the execution.
For example:
Code: Select all
If H < average( C, 20 ) then . . .
If L > average( C, 20 ) then . . .
Code: Select all
AVG20 = average( c, 20 );
If H < AVG20 then . . .
If L > AVG20 then . . .
Re: Faster optimization speed question and a thought
Thanks very Much.. This is something I picked up last year. Always try to replace a recurring function/calculation with a Variable.My understanding is, the function is a "human" short cut.
When MC compiles the indicator, the function code is inserted back into the script wherever it appears.
However, all is not lost. Good coding practice can speed up the execution.
For example:
should be written asCode: Select all
If H < average( C, 20 ) then . . . If L > average( C, 20 ) then . . .
Code: Select all
AVG20 = average( c, 20 ); If H < AVG20 then . . . If L > AVG20 then . . .
After this I imagine it gets more difficult to lean out a script. Thanks for the confirmation on the function though.. Nice to know that it is efficient to use them at will as long as you follow that first rule