- ago
When I drag and drop the Gain indicator into a Chart, I get one thing. When I convert it to code (see below) and execute it, I get a totally different plot. Which is correct?

CODE:
   ind1 = new Gain(bars.Close,"History",true);    PlotIndicator(ind1, WLColor.FromArgb(255,0,130,0), PlotStyle.HistogramTwoColor);
For the above code, it sets the frequency string to "History". Does "History" mean "Daily" bars? This isn't clear.
0
220
Solved
9 Replies

Reply

Bookmark

Sort
- ago
#1
Your starting dates are different (chart vs. strategy window). Nothing else.
0
Cone8
 ( 25.44% )
- ago
#2
"History" calculates the gain for each bar referenced to the close of first bar in the chart.

If you select "Quarterly", for example, the gain for each bar is referenced to the previous quarter's close.

Same idea for the other frequencies: "Yearly", "Monthly", "Weekly", "Daily".
1
- ago
#3
QUOTE:
"History" calculates the gain for each bar referenced to the close of first bar in the chart.

I thought that meant the first bar "appearing" in the Chart, but that's wrong. It's the first bar loaded into the Chart instead. This really needs to be documented better.

0
Best Answer
Cone8
 ( 25.44% )
- ago
#4
I don't follow you. Why all the arrows pointing to 500 bars?

The first loaded and appearing bar is bar #0.
bars.Close[0] is the reference price for frequency "History".
0
- ago
#5
QUOTE:
The first loaded and appearing bar is bar #0.

Yes, but bar #0 starts at the first loaded bar, which is two years off the Daily-scaled Chart when 500 bars are loaded into the Chart. Perhaps your point is that I should only be loading 100 bars so all loaded bars appear (i.e. are visible) on the Chart. But sometimes I like to scroll the Chart back two years, so I load 500 bars.
0
Cone8
 ( 25.44% )
- ago
#6
I repeated "appear" after you said it. That's not in the documentation. I would write "visible" when talking about what you can see in the chart. "Appear" is an ambiguous term in this context.

fwiw, QuickRef updated:
Returns the gain of the source TimeSeries with respect to the last value for the specified frequency (minimum Daily). The reference value for frequency 'History' is fixed to the closing price at the first bar (bar 0).
0
Glitch8
 ( 11.81% )
- ago
#7
As a general rule indicators in WL8 will NEVER be based on which bar happens the appear along the left edge of the chart.
0
- ago
#8
QUOTE:
... indicators in WL8 will NEVER be based on which bar happens to "appear" along the left edge of the chart.

I didn't know that. But I've only been using WL for 8 years. Thanks for the clarification.
0
Glitch8
 ( 11.81% )
- ago
#9
Glad to help!
1

Reply

Bookmark

Sort