How to start an indicator on a specific date?

I see the function paramDate() which can be used like so:
startDate = ParamDate( "Start Date", "2021-01-01" );

What I would like to know is how to create and plot an indictor that starts on startDate?



If you mean like in example below..
What is the benefit?

startDate = ParamDate( "Start Date", "2021-01-01" );

sma = MA(C,20);
dn = DateNum();
sma_perDate = IIf(dn>=startDate, sma, Null);

Plot( sma_perDate, "SMA", colorRed );

Also see

No benefit for MA, but some other indicators (replacing with nulls all the quotes arrays needed before doing their calculations) may start at different levels and then converge.

Anyway, I wonder if there is a way to avoid ‘plotting’ such forced "empty" (nulls) bars at the start (or at the end in some other situations - let's suppose I would like to plot ONLY a specific year/period).
If not, IMO, if it does not involve problems that I cannot foresee, it would be a candidate to consider adding in the future to SetOption().


Tip o' de hat for all your contributions to the community.


Tell me some news not outdated stuff.

Re-read comment.
It was written "If..." and question "What is benefit?" in case it is meant like that.
There is no mention of which indicator in which way in 1st post.
Using IIf() as done above won't change calculations for any indicator. It will just replace elements not being within date range by Null.

To calculate only from custom range it should rather be used Sparse* functions (compressing price arrays and expanding indicator being dependent on those price arrays).

To plot from-to date zoom in (e.g. via ZoomToRange) or draw via Gfx.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.