Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Indicator Development

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

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 09-14-2017, 01:18 AM   #1
turbofib
Senior Member
 
Join Date: Sep 2013
Posts: 354
Thanks: 128
Thanked 5 times in 5 posts
Default High Daily, High Weekly , High Month in intraday

my chaart is setting 5 minutes

2 question :

1)
and i want to know the High Daily, High Weekly , High Month

I write in State.Configure add

AddDataSeries(BarsPeriodType.Daily,1);
AddDataSeries(BarsPeriodType.Weekly,1);
AddDataSeries(BarsPeriodType.Month,1);

or there is a better code

2)there is a method already built to calculate it intraday of daily ..monthy and weekly?
Last edited by turbofib; 09-14-2017 at 05:46 AM.
turbofib is offline  
Reply With Quote
Old 09-14-2017, 07:24 AM   #2
NinjaTrader_Paul
NinjaTrader Customer Service
 
NinjaTrader_Paul's Avatar
 
Join Date: May 2014
Posts: 3,126
Thanks: 361
Thanked 748 times in 723 posts
Default

Hello turbofib,

Thanks for your post.

For live data only, you can add the bars as you have shown and use the setting of Calculate.OnPriceChange to then access the current day bar, week bar and month bar, highs. using Highs[n][0] where n would be the related BarsArray of the added bars. Please see attached.

The only existing method that relates would be CurrentDayOHL which will work historically and live

Please note that your AddDataSeries() examples have syntax errors, here are the corrections:
AddDataSeries(BarsPeriodType.Day,1);
AddDataSeries(BarsPeriodType.Week,1);

References:
http://ninjatrader.com/support/helpG...dataseries.htm
http://ninjatrader.com/support/helpG...-us/?highs.htm
http://ninjatrader.com/support/helpG...nt_day_ohl.htm
Attached Images
File Type: png Tubrbofib-1.PNG (103.6 KB, 6 views)
NinjaTrader_Paul is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Paul for this post:
Old 09-14-2017, 07:38 AM   #3
turbofib
Senior Member
 
Join Date: Sep 2013
Posts: 354
Thanks: 128
Thanked 5 times in 5 posts
Default

Thanks you for pics
turbofib is offline  
Reply With Quote
Old 09-16-2017, 12:29 PM   #4
turbofib
Senior Member
 
Join Date: Sep 2013
Posts: 354
Thanks: 128
Thanked 5 times in 5 posts
Default

You say:
"The only existing method that relates would be CurrentDayOHL which will work historically and live"


but i see there is a problem

i print in the chart this indicator
Quote:
if (CurrentBar > 3) Print(Time[0] + " days 0 " + CurrentDayOHL().CurrentHigh[0] + " days -1 " + CurrentDayOHL().CurrentHigh[1] + " days -2 " + CurrentDayOHL().CurrentHigh[2]);
Look pics

https://gyazo.com/4113988018958bd6b8fa750777f8bfe4

it take High but intraday not daily....Look Ninjascript Output..its intraday not daily
(session begin 9:00 and finish 22:00)

CurrentDayOHL().CurrentHigh[0] is the same of CurrentDayOHL().CurrentHigh[1] and this is the same of CurrentDayOHL().CurrentHigh[2] (we are in last candle in the chart 14/09 17:00)


I want to know for example the HIGH of the last 4 sessions
high of session 14/09...High of session 13/09...High of session 12/09

What do you advise me to use? Thank you
Last edited by turbofib; 09-16-2017 at 12:38 PM.
turbofib is offline  
Reply With Quote
Old 09-18-2017, 07:12 AM   #5
NinjaTrader_Paul
NinjaTrader Customer Service
 
NinjaTrader_Paul's Avatar
 
Join Date: May 2014
Posts: 3,126
Thanks: 361
Thanked 748 times in 723 posts
Default

Hello turbofib,

Thanks for your reply.

The method CurrentDayOHL will return the value of the bar index [n]. If you are applying the indicator to 5 minute bars the [0] will be the current High, [1] will be the current high 1 bar ago, [2] would be the bar before that so your results are as expected IE the current high is the same.

A way to obtain the current high per day would be as this example shows:

protected override void OnBarUpdate()
{
if (CurrentBar < 1) return;

if (Bars.IsFirstBarOfSession)
{
Print ("On : "+Time[1].Day+" the high was: "+CurrentDayOHL().CurrentHigh[1]);
}


In the example, on the first bar of the session, we check the bar index[1] (prior bar) which would provide the CurrentDayOHL high for the prior session. You could then accumulate these into an array that you can then access as needed for the last 4 days.
NinjaTrader_Paul is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Paul 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
Market Analyzer cell alert for new high or low daily and intraday JimCas Platform Technical Support 1 08-01-2013 12:38 PM
High[] has length Bars.Count but it can access only High[CurrentBar] Why trd55 Indicator Development 1 04-21-2013 10:47 AM
Current Weekly Open, High and Low cskrishna Platform Technical Support 1 02-02-2012 01:43 PM
Grabbing the Weekly High Low stefy Indicator Development 1 11-27-2008 12:56 PM
High greater than Highest High of last 20 Bars SamIam Strategy Development 1 08-19-2007 04:58 PM


All times are GMT -6. The time now is 06:06 PM.

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.