PPMA

Moderator: admin

PPMA

Postby dataman » Mon Apr 19, 2010 2:46 am

I'm new to devloping custom indicators.
Can some one tell me what the 'core' indcators are - is PPMA a core indicator ?
If not - how is it calculated
I just get 0 in the data fields when i try to plot it in the 'oscillator area' part of the graph.
dataman
 
Posts: 1
Joined: Mon Apr 19, 2010 2:02 am

Re: PPMA

Postby Nikolay.Gekht » Tue Apr 20, 2010 9:29 pm

PPMA is standard indicator and is available always.
However, you can calculate PPMA faster than create an indicator instance.
Just declare your indicator required source as Bar
(indicator:requiredSource(core.Bar); in the Init() function),
and then use the following to calculate PPMA(N) value for bar i:
ppma = core.avg(source.typical, core.rangeTo(i, N);
Please, do not forget that ppma cannot be calculate for the first N bars of the chart.
So, the correct way is:
1) declare global variable first:
local first;

2) in the Prepare function calculate the value of this variable as the first available period of the source plus N, where N is parameter of the PPMA

first = source:first() + N;

3) In the Update function skip calculate until the bar number is less than first

if period >= first then
... calculate here
end
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 13 guests