How to programatically get value of Camarilla pivots from anaPivotZones indicator?
I have a hopefully straighforward question.
In NT strategy code, using Fat Tail's Pivot Zones indicator, how do I programatically get value for the various Camarilla pivot zones - R1High, R1Low, PPHigh, PPLow etc?
I can seem to plot it fine, but when I try to retrieve the values (for example, of R1High) progamatically in OnBarUpdate method, it gives me an error on the chart saying "no data found. Please reload daily data or use calcFromIntradayData"...
All pivot indicators - this includes the default pivot indicators supplied with NinjaTrader - load daily data asynchronously. If you access the pivots indicator in DailyBars mode, this asynchronous loading of daily data will not work.
This has been confirmed by NinjaTrader support, and you will find various threads on this subject in the Ninjatrader forum.
As a consequence you can only programmatically access the pivot indicators in CalcFromIntradayDatamode. I have attached a model indicator, which accesses the default pivots indicator of NinjaTrader. If you set it to DailyBars, it will display nothing. You need to set it to CalcFromIntradayData
An alternative way of loading daily data would be to use the Add() method. However, the heuristic used by NinjaTrader to add daily bars is flawed, so they will not be inserted at the correct place for all types of session templates. I have therefore not coded a pivots indicator, which use the Add() method.
Do not hesitate to come back, if you have any further questions.
The following 4 users say Thank You to Fat Tails for this post:
So, I tried changing Calculation Mode from DailyBars to CalcFromIntradayData, and you're right, I can access the Pivot info programatically.
However, the pivot values calculated using Dailybars vs CalcFromIntradayData seem way off. For example, R4High using dailybars is 1.2754 while, it is 1.2739 when using CalcFromIntradayData. Hmmm...
If the highs are different, it shows that you use a false session template. Highs and lows should be the same for daily data and intraday data, if an appropriate session template is used.
The only short coming of intraday data is that you cannot use the settlement price for futures. The settlement price cannot be retrieved from any intraday chart, because the information is simply not available. So you are limited to the use of the last traded price of the selected session.
Your high or low problem can be easily solved. Best you post a chart with the indicator applied and I will comment on it.
I have attached the two screenshots. 1st is using DailyBars. 2nd is using CalcFromIntraday..
In the Dataseries for 6e, I have specified session template as "CME FX Futures ETH" - not sure if this is correct..
Your templates are correct. The Camarilla pivots are calculated from prior day's high, low and close. In DailyBars the close is the settlement price (1.2700), whereas in CalcFromIntradayData mode it is the last traded price (1.2712).
The difference of 12 pips affects all Camarilla pivots. For example the level for R4 will be 1.2772 calculated from the settlement price, but 1.2784 calculated from the last traded price.
Also please update the indicator. Although I did not change the version number, I have made a few changes to the indicator
-> holidays entered for 2012
-> bug removed (one of the levels did not plot as range but as line, only affected Camarilla pivots)
-> bug removed (levels Y-PRL and Y-Mid, only affected Camarilla pivots)
-> 5th level added
The following 2 users say Thank You to Fat Tails for this post:
So then it seems the way to get accurate camarilla pivot values that uses settlement prices would be to Add a second dataseries (daily) to the strategy and use that second dataseries in the pivots indicator...
I have not yet found a satisfactory solution. I personally use segmented session templates for 6E which divide the session into 3 segments, as some of my indicators use the opening range and/or the volatility of a specific session.
The problem with daily data is that NinjaTrader does not add it at the beginning of the trading day, but in some cases earlier (with hindsight knowledge) and in some cases later, as shown in the chart below. So I do not trust in adding data synchronously via the Add() method.
That is the reason that the pivots indicator loads it asynchronously by using a cache.