Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Steps for Intrabar Functionality

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Steps for Intrabar Functionality

    Hello support staff and helpful readers,

    I am looking to find out specifically what steps I need to take in order to give my script the ability to execute trades in the middle of a 15-minute bar, triggered by conditions set on a tick series or range(1) series.

    I have added the data series I want to use like so..
    [CODE/]
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    }
    [/CODE]

    I need to change the following code to accommodate a secondary series I think, but to what?
    [CODE/]
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;
    [/CODE]

    And do I need to sync the secondary series in DataLoaded? I'm not even entirely sure what is meant by this, but it kept coming up.

    From the research I've done in other relevant posts, it seems like in order to call the secondary series for an indicator calculation, the BarsArray is used, but for my condition I need to call the Close of the secondary series. In the posts I found it stated that this can be done by something like this "Close[1][0]" which would call the close of the secondary series current/last bar. But all of this literature was from NT7, would the same syntax be used for NT8? How would I implement it so that it's functional?

    THE RELEVANT PART OF THE CONDITION WOULD JUST TRIGGER AN ACTION WHEN THE CLOSE OF THE TICK SERIES IS ABOVE THE CLOSE OF THE PRIOR 15 MINUTE BAR(primary series). Sorry for caps, but that is really, broad strokes, all I am trying to do, so if you can walk me through that without any additional information, then you can probably ignore the rest of my post.

    Any specified help you can offer would be greatly appreciated, as well as any reference to detailed literature regarding the implementation of intrabar functionality/granularity in NT8.

    Thank you!

    #2
    Hello lunardiplomacy,

    Thank you for your post.

    You're on the right general track, but here's a few resources that should help:

    This example from our help guide illustrates how to enter on one time frame and exit on another - this could easily be modified to do all your exits and entries on the secondary series.



    This help guide article goes into detail on making sure you have enough bars of both series to process correctly.



    Last, here's a link to our help guide on Multi-series scripts:



    The section on "Accessing the Price Data in a Multi-Bars NinjaScript" may be particularly helpful.

    To specifically answer your question as to how to trigger an action when the close of the tick series is above the close of the prior 15 minute bar, you could do something like below:


    Code:
    protected override voide OnBarUpdate()
    {
         // check to make sure we're processing the secondary tick series currently
         if (BarsInProgress == 1)
         {
             // if the close of the currently forming tick bar is greater than the close of the prior 15 minute bar, then do something
             if (Closes[1][0] > Closes[0][1])
             {
                  // do something here
             }
    
         }
    }
    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by llanqui, Today, 03:51 PM
    0 responses
    4 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by Quanto, 04-17-2024, 10:43 AM
    2 responses
    22 views
    0 likes
    Last Post Quanto
    by Quanto
     
    Started by Irukandji, Today, 03:06 PM
    0 responses
    6 views
    0 likes
    Last Post Irukandji  
    Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
    17 responses
    95 views
    0 likes
    Last Post cmtjoancolmenero  
    Started by nleitman, Today, 11:46 AM
    8 responses
    20 views
    0 likes
    Last Post nleitman  
    Working...
    X