Please tell me why the USTYield indicator needs "bars"?
Does this USTYield indicator create a new copy of itself for each bars instance or is one copy cached somehow?
Is there a simpler way to get USTYield for a Sharpe Ratio calculation?
UPDATE: Hmm. Maybe USTYield employs the bars parameter to determine the Scale of the Chart, and nothing more. I wonder where it caches its result? Certainly not in my static utility class. Maybe it's not possible to create a static utility function employing USTYield.
CODE:I'm trying to create a simple static Sharpe Ratio function for my static WL utility class, and I don't want to pass lots of stuff (like bars) into it. I'm looking for a way around this "bars" business.
public override void Initialize(BarHistory bars) { usTYield = new USTYield(bars,YieldPeriod.OneYear); }
Does this USTYield indicator create a new copy of itself for each bars instance or is one copy cached somehow?
Is there a simpler way to get USTYield for a Sharpe Ratio calculation?
UPDATE: Hmm. Maybe USTYield employs the bars parameter to determine the Scale of the Chart, and nothing more. I wonder where it caches its result? Certainly not in my static utility class. Maybe it's not possible to create a static utility function employing USTYield.
Rename
Because fundamentally every indicator in WL8 needs either a BarHistory or a TimeSeries as the first parameter. It’s just the core design.
So is
In other words, how can a single copy of the USTYield be created to be used with every stock (bars object) in the dataset?
CODE:going to cache a separate USTYield TimeSeries in the dataset for each individual stock? If so, how can I avoid that?
usTYield = USTYield.Series(bars,YieldPeriod.OneYear);
In other words, how can a single copy of the USTYield be created to be used with every stock (bars object) in the dataset?
It’s not possible. Best not to mess with that either, because each symbol in the DataSet might have varying bar counts so it’s good that each gets its own synchronized copy.
QUOTE:
because each symbol in the DataSet might have varying bar counts
Interesting thought.
But I figured out a tricky solution. I only want to compute the Sharpe Ratio for the final bar so I can assign it to the Transaction.Weight for the off-the-Chart trade that appears in the Quotes window. So I only need one double value stored as a field variable.
CODE:Yes, that means I'll be using the same USTYield value for all positions of the stock, so this will be a somewhat rough Sharpe Ratio approximation. Maybe I should use the median USTYield value over the last two years instead.
if (usTYieldLastBar == 0.0) usTYieldLastBar = new USTYield(bars,YieldPeriod.OneYear)[bars.Count-1];
CODE:The bad news is that my SharpeRatioLastValue() function cannot be made static. Bummer.
if (usTYieldLastBar == 0.0) usTYieldLastBar = Median.Value(bars.Count-1,new USTYield(bars,YieldPeriod.OneYear),504);
Thanks for the help and quick reply.
Your Response
Post
Edit Post
Login is required