Go Back   NinjaTrader Support Forum > NinjaTrader 7 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 08-31-2007, 06:41 AM   #1
cutter
Junior Member
 
Join Date: Aug 2007
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default Pivot Point Mod for Open & Close Times

Hi. I'm trying to modify a copy of the ninjascript for Pivot points so that daily pivots can be calculated from the start of the Globex session the prior day - meaning, for example, that I would like to calculate today's pivot points (8/31) from the globex open at 4:30 pm on 8/29 to the close of the cash session at 4:15 on 8/30, and using the high from within that date and time range ..... (open + high + close)/3.
>
Can someone help me figure out the coding for this? I have a programming background and have already modified some of the ninjascript indicators before, but so far I am stuck on this one.
>
I'm thinking that the section of the code that i need to modify is the part of OnBarUpdate() that defines currentClose, currentHigh and currentLow.
>
Thanks!
cutter is offline  
Reply With Quote
Old 08-31-2007, 07:00 AM   #2
NinjaTrader_Ray
Founder and CEO
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,121
Thanks: 33
Thanked 308 times in 112 posts
Default

You could internally set up your session start/end times via DateTime variables, then check in OnBarUpdate() when a new session time starts, and on the first bar >= to the session start time, store the open for example.

NT6.5 due out in beta in late September will support sessions that span two days allowing you to set the true Globex session times and thus use our standard pivot indicators.
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-31-2007, 07:15 AM   #3
cutter
Junior Member
 
Join Date: Aug 2007
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Ray, thank you. Sorry for newbie question, but how would I go about doing what you suggest?

You could internally set up your session start/end times via DateTime variables, then check in OnBarUpdate() when a new session time starts, and on the first bar >= to the session start time, store the open for example.



cutter is offline  
Reply With Quote
Old 08-31-2007, 07:37 AM   #4
NinjaTrader_Ray
Founder and CEO
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,121
Thanks: 33
Thanked 308 times in 112 posts
Default

Here is a conceptual idea:

private DateTime myStartTime = new DateTime(2007, 08, 31, 16, 30, 0);

if (Time[0].TimeOfDay.TotalSeconds >= myStartTime.TimeOfDay.TotalSeconds)
// Here is our first bar after a user defined start time
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-31-2007, 07:39 AM   #5
cutter
Junior Member
 
Join Date: Aug 2007
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks, I'll give it a shot !
cutter is offline  
Reply With Quote
Old 09-13-2007, 01:16 PM   #6
cutter
Junior Member
 
Join Date: Aug 2007
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi ...

I'm floundering with this ... I was able to add the variable definition for myStartTime and still compile ok, but can't quite figure out wher to put the if statement ....

Any chance I can get some handholding on this?

Also, any reference that you can point me to that will help me get up to speed on NinjaScript in general?

Thanks,
Charlie
cutter is offline  
Reply With Quote
Old 09-13-2007, 01:18 PM   #7
cutter
Junior Member
 
Join Date: Aug 2007
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

I should also say that I'm starting by modifying a copy of the "Pivots" indicator that comes with NibjaTrader ... thanks.
cutter is offline  
Reply With Quote
Old 09-13-2007, 01:56 PM   #8
cutter
Junior Member
 
Join Date: Aug 2007
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

I found the NinjaScript section in help and am going through it, so no need to point me to a source.

... but please, could still use some help with the actual indicator development.

Thanks.
cutter is offline  
Reply With Quote
Old 09-13-2007, 03:27 PM   #9
NinjaTrader_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 363 times in 106 posts
Default

Hi cutter,

What you want to do is work in the OnBarUpdate() section of your code. Whatever is in the OnBarUpdate() will be run through every time your bar is updated, whether that is at the end of the bar (when CalculateOnBarClose = true) or at every incoming tick (when CalculateOnBarClose = false).

For the pivots indicator you are trying to make you can do so by checking the time of your bars. If the time is the time you want then you would store away your Open High Close values for use on the pivots.

Here is a code snippet demonstrating how you could theoretically proceed with your idea.

Code:
if (ToDay(Time[0]) == (ToDay(DateTime.Now) - 1))
{
     globexopen = Open[0];
     globexhigh = High[0];
     globexclose = Close[0];
}
After you have saved the proper OHC values you would pass those into the Pivot calculations instead of the default ones used. Now this exact code wouldn't be enough to handle your situation because you need to handle weekends where minus 1 wouldn't be enough, but you get the idea.

FYI: The ToDay() function returns an integer representing the date of the DateTime object. Time[0] is the DateTime object timestamped for the particular bar your indicator is calculating on at the moment and DateTime.Now is the DateTime object representing the exact time right now (i.e. your computer's current system time).

Hope that helps. Also you may find using these as reference useful http://www.ninjatrader-support.com/v...ead.php?t=2777
NinjaTrader_JoshP is offline  
Reply With Quote
Old 09-14-2007, 05:26 AM   #10
cutter
Junior Member
 
Join Date: Aug 2007
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh, thank you so much, this is a big help to me. Will give it a try and post results.
cutter is offline  
Reply With Quote
Old 09-17-2007, 12:17 PM   #11
fragalles
Member
 
Join Date: Aug 2007
Posts: 38
Thanks: 0
Thanked 0 times in 0 posts
Default Half pivots

I think its easy to implement but i am simply not a programmer, so if anyone could post here a pivot point modification that shows the price in the middle of two pivot lines for example (PP+S1 / 2)+S1 I would be more than happy.

Reading in the book MASTERING THE TRADE, this is one of the key setups to reduce position size.

Maybe also in NT 6.5 we could find this important update to the pivot indicator.
fragalles 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
Problem with close[0] and close[1] recentrage Indicator Development 4 07-19-2007 08:55 AM
Point Change Charts SigmaTrader Suggestions And Feedback 2 07-10-2007 01:15 PM
Bar Close / Open timing Kardinal Platform Technical Support 2 07-06-2007 08:06 AM
Trouble with Open, High, Low, Close SuzyG Indicator Development 4 03-05-2007 05:03 AM
Open position on close down andrewedmondson Platform Technical Support 3 10-05-2005 07:02 AM


All times are GMT -6. The time now is 08:13 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.