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 04-11-2018, 06:33 PM   #1
sandman
Senior Member
 
Join Date: Jun 2010
Posts: 595
Thanks: 144
Thanked 52 times in 42 posts
Default Pivots - Intermediate (NT7)

I am using the standard NinjaTrader provided pivots which are usually sufficient.

(I have modified it "RoundedToTickSize" which is useful for instruments such as 6J which shows much more decimals on the chart than on the DOM.)

But sometimes the gap between these pivots is quite huge and some "intermediate" pivot lines in between PP and R1 and PP and S2 would be useful. I'd like to give it a go and create these and if there is interest for this I can then post the result in the files sharing section. Note this would be for NT7.

I would appreciate if someone could tell me a good formula to calculate these mid-pivot lines? The standard ones are as follows.

pp = (currentHigh + currentLow + currentClose) / 3;
s1 = 2 * pp - currentHigh;
s2 = pp - (currentHigh - currentLow);

r1 = 2 * pp - currentLow;
r2 = pp + (currentHigh - currentLow);

sandman
sandman is offline  
Reply With Quote
Old 04-12-2018, 06:09 AM   #2
sandman
Senior Member
 
Join Date: Jun 2010
Posts: 595
Thanks: 144
Thanked 52 times in 42 posts
Default

I got a formula for mid pivots and have used one for testing purposes. For NT7 that is. I inserted it into the code, it compiles with no errors but it does not show up any pivot at all.

What can/should I do?

What I did specifically is to take the original NT indicator Pivots, and saved it under a new name called PivotsNTPlus. I then added:
in the Variables Section: private double rmid = 0;
in the Initialize: Add(new Plot (Color.Black, "RMID"));
in OnBarUpdate: rmid = 0.5*(pp + r1);
and RMID.Set(rmid);
and further down in Properties region:
[Browsable(false)]
[XmlIgnore]
public DataSeries RMID
{
get { return Values[7]; }
}

sandman
sandman is offline  
Reply With Quote
Old 04-12-2018, 06:28 AM   #3
NinjaTrader_Paul
NinjaTrader Customer Service
 
NinjaTrader_Paul's Avatar
 
Join Date: May 2014
Posts: 4,173
Thanks: 437
Thanked 1,091 times in 1,045 posts
Default

Hello sandman,

Thanks for your post(s).

When you applied the indicator, do you see any error messages posted in the "Log" tab of the control center related to the indicator?
NinjaTrader_Paul is offline  
Reply With Quote
Old 04-12-2018, 06:39 AM   #4
sandman
Senior Member
 
Join Date: Jun 2010
Posts: 595
Thanks: 144
Thanked 52 times in 42 posts
Default

Yes, Paul. It says: Error on plotting indicator: Please check the OnBarUpate or the Plot method: Index was outside the bounds of the array.
sandman is offline  
Reply With Quote
Old 04-12-2018, 08:29 AM   #5
NinjaTrader_Paul
NinjaTrader Customer Service
 
NinjaTrader_Paul's Avatar
 
Join Date: May 2014
Posts: 4,173
Thanks: 437
Thanked 1,091 times in 1,045 posts
Default

Hello sandman,

Thanks for your reply.

This would indicate that an index is pointing to something that does not exist. As you have added a plot you would need to make sure that you have added enough for the various arrays. Your 2nd post looks correct to me in terms of what is needed to add another plot so that is not the issue.

In looking at the indicator code, I think the issue is likely to be the first variable listed as it is an array of brushes and I only count 7. I would add another to that array statement and see if that resolves the issue. Note that this is just a place holder as the actual color is determined by your add plot statement.
NinjaTrader_Paul is offline  
Reply With Quote
Old 04-12-2018, 09:45 AM   #6
sandman
Senior Member
 
Join Date: Jun 2010
Posts: 595
Thanks: 144
Thanked 52 times in 42 posts
Default

Paul. I vaguely get what you are saying but have a difficulty transferring it into code (I am not really a programmer). I counted 6 arrays total in the original version. And I added 1 for the new mid-pivot makes 7 total, yet you saying you count "only" 7 seems to indicate it now needs 8. ???

Could you look over the full code which I have attached as a cs file and indicate where I have to add what?

sandman
Attached Files
File Type: cs PivotsToTickSizePlus.cs (27.4 KB, 16 views)
sandman is offline  
Reply With Quote
Old 04-12-2018, 09:52 AM   #7
NinjaTrader_Paul
NinjaTrader Customer Service
 
NinjaTrader_Paul's Avatar
 
Join Date: May 2014
Posts: 4,173
Thanks: 437
Thanked 1,091 times in 1,045 posts
Default

Hello Sandman,

Thanks for your reply.

This is the first line in region variables:

private SolidBrush[] brushes = { new SolidBrush(Color.Black), repeats 6x times...

There are a total 7 of new SolidBrush(Color.Black) you need to make a copy and add 1 so that in the array there are 8 of new SolidBrush(Color.Black)

Of course if you add more pivots you will need to add another one for each pivot added.
NinjaTrader_Paul is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Paul for this post:
Old 04-12-2018, 10:01 AM   #8
sandman
Senior Member
 
Join Date: Jun 2010
Posts: 595
Thanks: 144
Thanked 52 times in 42 posts
Default

Paul. Thank you very much. Needless to say that worked immediately.

sandman
sandman is offline  
Reply With Quote
The following user says thank you to sandman for this post:
Old 04-12-2018, 02:59 PM   #9
sandman
Senior Member
 
Join Date: Jun 2010
Posts: 595
Thanks: 144
Thanked 52 times in 42 posts
Default

Paul.
I am finished with it. I call it PivotsRoundedtoTickSizePlus. Firstly, rounding to tick size is useful for instruments such as 6J. "Plus" because I added pivots in between PP and S1, S1 and S2 and S2 and S3 (same for Resistance). I also added in the Woodie S1 and R1. These additional pivots can be turned on or off with "Addtl pivots" in the Parameters section of the indicator menu.

Before posting it in the files sharing section I thought I would check to see if you would test it to see there is nothing untoward that crept in. And secondly I'd like to make sure I am not violating something as NinjaTrader actually holds the copyright on the indicator. I included a note in that respect in the beginning of the code.

sandman
Attached Files
File Type: zip PivotsToTickSizePlus.zip (6.4 KB, 7 views)
sandman is offline  
Reply With Quote
Old 04-13-2018, 11:49 AM   #10
NinjaTrader_Paul
NinjaTrader Customer Service
 
NinjaTrader_Paul's Avatar
 
Join Date: May 2014
Posts: 4,173
Thanks: 437
Thanked 1,091 times in 1,045 posts
Default

Hello sandman,

Thanks for your reply.

Please feel free to post in the NinjaTrader7 Indicators file sharing are. We appreciate your consideration and welcome your contributions to the community.
NinjaTrader_Paul is offline  
Reply With Quote
Old 04-20-2018, 01:56 AM   #11
sandman
Senior Member
 
Join Date: Jun 2010
Posts: 595
Thanks: 144
Thanked 52 times in 42 posts
Default

Paul. Thanks. I posted it now (though I took the Woodie Pivots out again). Thanks again for your help.
sandman
sandman is offline  
Reply With Quote
The following user says thank you to sandman for this post:
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
Intermediate between StrategyBase and IndicatorBase TazoTodua Indicator Development 19 09-13-2018 12:45 AM
Woodies Pivots in NT7 aligator Platform Technical Support 11 02-11-2011 08:07 AM
Intermediate Risk. Drakmyre Indicator Development 4 10-04-2008 09:58 PM


All times are GMT -6. The time now is 11:35 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.