I discovered that the volume data for most current bar is often incorrect (and subsequently corrected).
I would like to take the EMA volume of the most recent 20 bars, but not including the most recent 2 bars.
How might I code for that?
I am using:
CODE:
Please log in to see this code.
I tried
CODE:
Please log in to see this code.
but the name 'bar' does not exist yet, and cannot convert 'double' to WLDataSeries.
Size:
Color:
No "bar" exists outside of the loop. You can:
1) either exclude the last two bars from the calculation by creating a custom series as shown in the WealthScript Programming Guide (DataSeries >
Filling a Custom DataSeries, Example #2),
2) or simply offset Volume forward two bars using a shift operator (>> in this case) again like shown in WealthScript Programming Guide (DataSeries > Series Operators >
How to: Offset or Delay a DataSeries) or in the QuickRef >
DataSeries object:
CODE:
Please log in to see this code.
Size:
Color:
Great. Thank you.
If I merely saw this in code without context, I would have thought the >> meant "advancing" the series, but the Guide also confirms the opposite to be the case.
So I also learn or assume by this that data series are set up such that the most recent bar is on the left side, not the right side.
Size:
Color:
Advancing with >> in your example means that you take the value from the day before yesterday (because yesterday's value is believed to be incorrect today) and shift it one bar forward (the same principle applies for shifting more than 1 bar).
>> shifts from the "left" (a.k.a. the past) to the right edge.
Size:
Color:
Aahh. Thank you for your clarifying illustration. Now it makes better sense to me.
Is that like pulling the railroad tracks to the front right, from under the standing train which is facing the right?
Size:
Color:
:) Amusing analogy. Yes, that's right.
Size:
Color: