NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 08-06-2012, 11:57 AM   #31
alabell
Senior Member
 
Join Date: Jun 2011
Posts: 214
Thanks: 34
Thanked 10 times in 10 posts
Default

while not entirely intuitive, this makes sense...

and so now i would need to do the math for all of s1, r1, s2 and r2....

where can i find these formulae, either in math or in code, as NT calculates them, as I know that there are certain different methods of doing this.
alabell is offline  
Reply With Quote
Old 08-06-2012, 12:02 PM   #32
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Andrew,
There are several ways to calculate the Pivot values. Please refer to the below site which describes the most common method to calculate the pivot points
http://www.mypivots.com/articles/art...aspx?artnum=36
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 08-08-2012, 03:45 PM   #33
alabell
Senior Member
 
Join Date: Jun 2011
Posts: 214
Thanks: 34
Thanked 10 times in 10 posts
Default

Uing the methodology described, I went about creating my own metrics.


Day bars are indexed as 1
Variables are doubles

protected override void OnBarUpdate()

{


high = Highs[1][0];
low = Lows[1][0];
close = Closes[1][0];
range = high - low;


myPP = ((high + low + close) / 3);
myR1 = (2 * myPP) - low;
myR2 = myPP + range;
myS1 = (2 * myPP) - high;
myS2 = myPP - range;

//Returns PP value
pivotPoint = ((this.PriorDayOHLC().PriorClose[0] + this.PriorDayOHLC().PriorHigh[0] + this.PriorDayOHLC().PriorLow[0]) / 3);

//Returns R1 value
resistance1 = ((2 * pivotPoint) - this.PriorDayOHLC().PriorLow[0]);

//Returns R2 value
resistance2 = pivotPoint + (this.PriorDayOHLC().PriorHigh[0] - this.PriorDayOHLC().PriorLow[0]);

//Returns S1 value
support1 = ((2 * pivotPoint) - this.PriorDayOHLC().PriorHigh[0]);

//Returns S2 value
support2 = pivotPoint - (this.PriorDayOHLC().PriorHigh[0] -this.PriorDayOHLC().PriorLow[0]);

Print(Time[0].ToString() + " R2: " + resistance2.ToString() + " R1: " + resistance1.ToString() + " PP: " + pivotPoint.ToString() + " S1: " + support1.ToString() + " S2: " + support2.ToString());


Print(Time[0].ToString() + "myR2: " + myR2.ToString() + "myR1: " + myR1.ToString() + "myPP: " + myPP.ToString() + "myS1: " + myS1.ToString() + "myS2: " + myS2.ToString());

____________________________________________


these numbers do not yield identical same pivot/support/resist numbers.

at this point i am having issues with the amount of time I have spent, because I keep coding and I can not get a the numbers to match based on the manner inw hich I have been advised.

This is not a complicated piece of code, please advise.

Thanks,

Andrew
alabell is offline  
Reply With Quote
Old 08-08-2012, 05:45 PM   #34
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,777
Thanks: 158
Thanked 565 times in 556 posts
Default

Can you please clarify who you connect to for data? This is displayed in the bottom left hand corner of the NinjaTrader Control Center.

If you disconnect from your data provider, and connect the Kinetick End of Day connection, do you get the results you are looking for?
NinjaTrader_Matthew is offline  
Reply With Quote
Old 08-08-2012, 06:27 PM   #35
alabell
Senior Member
 
Join Date: Jun 2011
Posts: 214
Thanks: 34
Thanked 10 times in 10 posts
Default

I am using kinetick at all times.
alabell is offline  
Reply With Quote
Old 08-09-2012, 04:08 AM   #36
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello alabell,
The below code calculates the pivots based on daily bars
Code:
pivotPoint = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
While this code is calculating the pivots based on intraday bars.
Code:
pivotPoint = ((this.PriorDayOHLC().PriorClose[0] + this.PriorDayOHLC().PriorHigh[0] + this.PriorDayOHLC().PriorLow[0]) / 3);
As such there can be differences as the data set differs.

Also please refer to this post which discusses this in details
http://www.ninjatrader.com/support/f...ead.php?t=4676
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 08-09-2012, 07:13 AM   #37
alabell
Senior Member
 
Join Date: Jun 2011
Posts: 214
Thanks: 34
Thanked 10 times in 10 posts
Default

so now we are back to the original formulae which were quoted to me a week or two ago, so please answer this question for me:

-- If a daily bar is, as it sounds, a one day bar, with a high, low open and close like I might see in a 2 year daily chart that would have aprox. 500 bars:

what is the proper definition of an intraday bar?

Thank you kindly.
alabell is offline  
Reply With Quote
Old 08-09-2012, 07:23 AM   #38
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Andrew,
Intraday bars will be the bars built from either tick data or minute data.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 08-09-2012, 07:44 AM   #39
alabell
Senior Member
 
Join Date: Jun 2011
Posts: 214
Thanks: 34
Thanked 10 times in 10 posts
Default

pivotPoint = ((this.PriorDayOHLC().PriorClose[0] + this.PriorDayOHLC().PriorHigh[0] + this.PriorDayOHLC().PriorLow[0]) / 3);


If the above code is built from intraday bars (minute or tick bars), are these bars then scanned to find a day's high, low and close from which to build your pivot point?


alternatively, a day bar simply records a H,L,O,C for the specific date in question?

is this the difference?

If yes, I suppose I get it, but shouldn't they be the same?

if no, then I don't understand how the above code would work to calculate "yesterday's pivot point".

Thanks as always.
alabell is offline  
Reply With Quote
Old 08-09-2012, 08:05 AM   #40
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Andrew,
OHLC calculated from intraday bar can differ from Daily bars. There are several factors like:

Daily bars are generally based on RTH session while OHLC built from intraday data uses the charts session template (which can be RTH or ETH or any other custom template) to calculate the OHLC.

The closing price of a daily bar is based on the volume weighted average price of the last 30 minutes. In case of intraday data it is the last traded price.

The pivots will be calculated anyway, based on what data you provide. If the data set differs the pivot values too will differ.
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Old 08-09-2012, 08:19 AM   #41
alabell
Senior Member
 
Join Date: Jun 2011
Posts: 214
Thanks: 34
Thanked 10 times in 10 posts
Default

Quote:
Originally Posted by NinjaTrader_Joydeep View Post
Hello Andrew,
OHLC calculated from intraday bar can differ from Daily bars. There are several factors like:

Daily bars are generally based on RTH session while OHLC built from intraday data uses the charts session template (which can be RTH or ETH or any other custom template) to calculate the OHLC.

The closing price of a daily bar is based on the volume weighted average price of the last 30 minutes. In case of intraday data it is the last traded price.

The pivots will be calculated anyway, based on what data you provide. If the data set differs the pivot values too will differ.

The Close of a daily bar is the VWAP of the last half hour? I had no idea. This surprised me greatly.
alabell is offline  
Reply With Quote
Old 08-09-2012, 08:43 AM   #42
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Andrew,
To be more specific, closing price is the Settlement price in a daily bar.
NinjaTrader_Joydeep is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pivot indicator imagineer Indicator Development 1 06-07-2010 12:56 PM
pivot indicator andrew100 Strategy Development 18 02-17-2010 07:42 AM
Pivot indicator saeed Charting 3 12-22-2009 08:03 AM
Best pivot indicator blazer Indicator Development 2 10-11-2009 04:12 AM
Pivot indicator mballagan Indicator Development 6 10-01-2009 10:44 AM


All times are GMT -6. The time now is 03:38 AM.