How .Series metods interract with shorter than Bars.Count series
Author: akuzn
Creation Date: 10/3/2012 2:52 AM
profile picture

akuzn

#1
Hi!
I m working now on optimizing execution speed and memory usage of my strateges.
For every open position strategy on each bar strategy computes value:

CODE:
Please log in to see this code.


If i understand right .Value creates DataSeries of Bars.Count length. And after that returns Highest result. So if it s true shorter series is needed.

I suppose that i can create shorter serie with _bars_hold length ( there is an equivalent value in Position ). But not sure that Highest or Lowest metods will interract with it correctly, so could You take a look and give and advice how to realise this idea:

CODE:
Please log in to see this code.


profile picture

Eugene

#2
To improve speed, don't disregard my advice on .Value vs .Series -- see post from 9/15/2012 9:52 AM here:

About Hurst ratio, Dennis Yang volatility

All DataSeries contain the same number of values as bars in the chart - unless you explicitly specify false for the synchronize parameter when accessing secondary symbol data via SetContext or GetExternalSymbol.

If you want a suggestion, you should explain the reasoning behind what you are doing and what are you trying to accomplish with these KAMA series.
profile picture

akuzn

#3
Thanks, i used your advice.
May be i didnt explain well.
Now i m trying to reduce memory usage especially on large periods optimization.
When strategy has an open position it computes some levels mostly using highest and lowest values of Series of full length.

For example if i m long i use as stop levels depending on volatility and other conditions precomputed

CODE:
Please log in to see this code.

They are used many times in different methods so they are placed in cache.

Now im working on trading cycle and not sure how to optimize Highest and Lowest.Value.
If Highest.Value creates new full length series - there is way to optimize, if it creates shorter serie of _bars_hold length or even just scanning by cycle beginning on bar - _bars_hold and ending on bar - optimization is not needed.

So if it creates full Bars.Count serie - the question is how to create method which will use lower memory
In this case there are 2 ways - use cycle of _bars_hold_length
or create short serie of _bars_hold_length.

For example
CODE:
Please log in to see this code.

Will work without loading memory.
But if i use many calls of highest value from same dataserie i think would be better co create this short DataSerie
Programming guide doest tell anything about it.
So could you help me with it. I feel that .Add may help
profile picture

Eugene

#4
QUOTE:
They are used many times in different methods so they are placed in cache.

double stop_long_price is not cached, it's calculated on-the-fly on every bar (performance bottleneck).

If you want my advice on performance, then consider disabling most performance visualizers (especially Performance+ and others dealing with Closed Equity - this is a bottleneck until next version of MS123 Visualizers), avoid optimizing with MS123 Scorecard (until next version of MS123 Visualizers - uses closed equity too), reduce your data loading range, don't call .Value, call Bars.Cache.Clear at the end of your Strategy, and most of all - install as much RAM sticks into your mainboard as possible.

After studying your explanation, I don't think it's worth the trouble to optimize DataSeries lower_kama_atr.
profile picture

akuzn

#5
QUOTE:
double stop_long_price is not cached, it's calculated on-the-fly on every bar (performance bottleneck).

yes, agree but i was talking about Series.

QUOTE:
If you want my advice on performance, then consider disabling most performance visualizers (especially Performance+ and others dealing with Closed Equity - this is a bottleneck until next version of MS123 Visualizers), avoid optimizing with MS123 Scorecard (until next version of MS123 Visualizers - uses closed equity too), reduce your data loading range, don't call .Value, call Bars.Cache.Clear at the end of your Strategy, and most of all - install as much RAM sticks into your mainboard as possible.

Great - but still without explanation - i dont want to create many series or replace .Value by .Series()[bar]... it creates new series loaded in memory..
if i need short serie of values - how create it??
To be honest - i expected more precious answer.
My pc has 1300 Mhz memory bus speed, 8 cores etc, all sticks slots used. I compred it to other my friend are using - good performance.
Any additional memory will be fully used if any simple value or short serie will be replaced by DataSeries.
Just trying to understand better. So could tell me - Highest.Value creates additional serie or not?
profile picture

Eugene

#6
No, it does not create an extra DataSeries. At the price of reduced performance.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).