Problems with empty values

Hi,

I noticed that the ExampleMA of the ADK does not behave in the same way as the internal MA function. A plot of the ExampleMA always shows EMPTY VALUES a!t the left side of the pane, independent from zoom.
I expected the EMPTY VALUES only at the very beginning of the timeline.
Attached is a compromising diagram of the ExampleMA (blue line) and the internal MA.
Pane|690x437
This is the code I used to plot the ExampleMA:

// ExampleMA

ExMA = ExampleMA(C,50);
Plot(C, “C”, colorBlack, styleCandle);
Plot(ExMA, “ExMA”, colorBlue, styleLine);

At the moment I am programming a c++ function, which will also have Empty Values at the beginning of the timeline. How can I ensure that this will happen only at the very beginning of the timeline?

You need to read the Knowledge Base about QuickAFL: http://www.amibroker.com/kb/2008/07/03/quickafl/
It is recommended to read entire article from the beginning to end, but “Important notes” point c) applies directly to you.

1 Like

Thank you for the quick reply.
I added
SetBarsRequired(sbrAll,sbrAll);
to the code and now it works.

1 Like

That’s incorrect.

If anything, you should rather use SetBarsRequired( 200, 0 ).

Specifying sbrAll is wrong because you loose all advantages and speed provided by QuickAFL. To get stable EMA from 50 bars, 200 prior bars is perfectly enough, you don’t need/want to use more, because your code will run slower. And also there is no point in specifying any FUTURE requirements (second parameter), by doing so you are triggering false impression that your formula looks into the future. Second parameter should always be ZERO, unless you really look into the future.

1 Like