PDA

View Full Version : indicator formulas


alexkow1
06-09-2010, 07:48 PM
Hi,

I would like to understand the calculations behind the indicators so that i can logically create strategies.
how can i find out how indicators are being calculated in ninjatrader?
for example the keltner channel?

thanks
alex

NinjaTrader_Bertrand
06-10-2010, 01:18 AM
Alex, you can just open them up via Tools > Edit NinjaScript > Indicator...then point to the one you're interested in, this will show you the source code.

alexkow1
06-10-2010, 05:01 AM
hi,

Thanks for your reply.
I have one other question, when I looked at the way the keltner channel is calculated
I noticed that the SMA is calculated as typical:

SMA(Typical, Period)[0];

does the "Typical" stand for the way the SMA is calculated?
and if yes, how is it calculated?

Also, there is another part of code i don't quiet understand:

double offset = SMA(diff, Period)[0] * offsetMultiplier;

I understand the SMA and offset multiplier, but what is meant by diff?

thanks for your help,
alex

NinjaTrader_Bertrand
06-10-2010, 05:16 AM
Alex, the SMA midline serving as Keltner basis is calculated using the Typical price (H + L + C divided by 3) as input then, not for example the Close value.

'diff' signifies the High / Low range of the bar, it's just a substraction used later to arrive at the upper lower band values.

alexkow1
06-10-2010, 06:11 AM
Thanks for the quick reply.

so the way i understand the calculation of the SMA using the typical price is that
if we had for example a period of 10, then we would calculate the typical price for every candle within the 10 candle period and then divide the total by 10. is my logic correct?

and for the difference of the high and low, would we calculate the difference of the high and low of all 10 individual candles and then divide the total by 10?

or did i misunderstand the way these two are calculated?

thanks
alex

NinjaTrader_Bertrand
06-10-2010, 06:17 AM
For the SMA, you would sun the individual tpyical price of each candle within the lookback period (10 in this case) and then divide this sum by this period to arrive at your current SMA value.

The diff is doing the same, however it would take the average per above of the High - Low results.

You can review the SMA indicator code, too if interested.

alexkow1
06-10-2010, 06:23 AM
alright, i get it now.

thanks for going through this with me.

alex