NexusFi: Find Your Edge


Home Menu

 





Ninjascript help Please


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one GraDman with 5 posts (3 thanks)
    2. looks_two trendisyourfriend with 4 posts (6 thanks)
    3. looks_3 Jasonnator with 4 posts (9 thanks)
    4. looks_4 JonnyBoy with 1 posts (3 thanks)
      Best Posters
    1. looks_one JonnyBoy with 3 thanks per post
    2. looks_two Jasonnator with 2.3 thanks per post
    3. looks_3 trendisyourfriend with 1.5 thanks per post
    4. looks_4 GraDman with 0.6 thanks per post
    1. trending_up 4,600 views
    2. thumb_up 21 thanks given
    3. group 7 followers
    1. forum 13 posts
    2. attach_file 3 attachments




 
Search this Thread

Ninjascript help Please

  #11 (permalink)
 
Jasonnator's Avatar
 Jasonnator 
Denver, Colorado United States
 
Experience: Intermediate
Platform: NT8 + Custom
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166

SessionIterator is something I use in almost every indicator and strategy I make so I definitely plan to cover it (hopefully soon). Once you figure out how it works, it's such a simple but useful mechanism. In the meantime, here is a code snippet to hopefully get you running:

 
Code
private SessionIterator sessionIterator;
private DateTime sessionBegin;
private DateTime sessionEnd;

protected override void OnBarUpdate()
{
    base.OnBarUpdate();

    if (base.CurrentBars[0] < base.BarsRequiredToPlot)
    {
        return;
    }

    if (this.sessionIterator != null)
    {
        if (base.IsFirstTickOfBar && base.Bars.IsFirstBarOfSession)
        {
            if (this.sessionIterator.GetNextSession(base.Time[0], false))
            {
                this.sessionBegin = this.sessionIterator.ActualSessionBegin;
                this.sessionEnd = this.sessionIterator.ActualSessionEnd;
            }
        }
    }
}

I "new up" my sessionIterator field in the DataLoaded state because it requires a Bars object. So however you handle NT8's different states in OnStateChange (I use a switch statement, I've seen others use if/else), you'll need this:

 
Code
if (this.Bars != null)
{
    this.sessionIterator = new SessionIterator(this.Bars);
}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
  #12 (permalink)
 
Jasonnator's Avatar
 Jasonnator 
Denver, Colorado United States
 
Experience: Intermediate
Platform: NT8 + Custom
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166


GraDman View Post
Thanks you, I just watched your new video, I hope you cover this sometime in a video

It took a little longer than expected to edit the video tutorial, but I also decided to create a how to article. Links to both

Video:

Article:

Reply With Quote
Thanked by:
  #13 (permalink)
 
Jasonnator's Avatar
 Jasonnator 
Denver, Colorado United States
 
Experience: Intermediate
Platform: NT8 + Custom
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166


I'm not sure why the article thumbnail is showing "Some highly recommended books" but it is in fact the session iterator + trading hours how-to.

Reply With Quote
  #14 (permalink)
GraDman
Tennessee
 
Posts: 6 since Aug 2020
Thanks Given: 9
Thanks Received: 4


Jasonnator View Post
I'm not sure why the article thumbnail is showing "Some highly recommended books" but it is in fact the session iterator + trading hours how-to.

I think the article block is kind of like an advertisement from futures.io

Reply With Quote
Thanked by:




Last Updated on August 28, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts