MultiCharts ATR vs. NT ATR  [SOLVED]

Questions about MultiCharts and user contributed studies.
PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

MultiCharts ATR vs. NT ATR

Postby PD Quig » 07 Nov 2013

I'm trying to emulate an ATR-based trailing stop in a NinjaTrade black box indicator (I can't see the code). The basic issue appears to be that NT's and MultiChart's ATR calculation produce quite different results.

Any ideas why this might be? ATR should be a really straight-forward calculation and the NT ATR code looks like it does what I'd expect it to do.
Attachments
NinjaTrade_ATR_code.png
(13.57 KiB) Downloaded 713 times
NinjaTrader_5R_chart.png
(67.25 KiB) Downloaded 711 times
MultiCharts_5R_chart.png
(42.2 KiB) Downloaded 710 times

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: MultiCharts ATR vs. NT ATR

Postby furytrader » 08 Nov 2013

I'm not sure if this is your reason for concern, but one reason why the indicator on the charts may look different is (I'm guessing) that the axis on MultiCharts is set to some minimal incremental value - so it isn't plotting the indicator at the level of precision that NT is. This does not mean, however, that it is necessarily calculating it incorrectly (although it could be).

If you want to check to make sure when MultiCharts is calculating the average true range correctly, I would do the following:

1) Use a Print command to show the TrueRange for the last bar on the chart and manually verify that it is correct. That is, use:

Code: Select all

IF LASTBARONCHART = TRUE THEN BEGIN
Print(NumToStr(TrueRange,5); // The second number here is the precision to be displayed
End;
2) If you pass test #1, I would then print out the TrueRange for each bar as follows ...

PRINT(DATE,",",TIME,",",NumToStr(TrueRange,5);

... and then copy and paste the results into Excel or some other spreadsheet program and average them for the last bar (going back as far as you want). Compare this to the final ATR value calculated by MultiCharts to confirm whether it is correct.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: MultiCharts ATR vs. NT ATR  [SOLVED]

Postby SP » 08 Nov 2013

The Summation of the True Range is a bit different in NJ and MC/TS.

This gives the NT ATR in MC:

Code: Select all

inputs:
ATRLength( 14 );

variables:
NinjaTrueRange ( 0 ),
NinjaAtr ( 0 ) ;

NinjaTrueRange = MaxList ( Absvalue(Low[0] - Close[1]) , MaxList ( High[0] - Low[0] , Absvalue ( High [0] - Close[1] ) ) );
NinjaAtr = (((( MinList(CurrentBar + 1, ATRLength) - 1) * NinjaAtr [1]) + NinjaTrueRange ) / ( MinList ( CurrentBar + 1, ATRLength )));
plot1(NinjaAtr );

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: MultiCharts ATR vs. NT ATR

Postby PD Quig » 08 Nov 2013

Thanks Fury and SP. I don't read C# so I missed that the summation is different. Awesome catch, SP. I'll try that after session close today.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: MultiCharts ATR vs. NT ATR

Postby PD Quig » 08 Nov 2013

Results. Thanks again, SP.
Attachments
NinjaTrader_ATR_vs_MultiCharts_ATR.png
(49.04 KiB) Downloaded 730 times


Return to “MultiCharts”