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

The use of loose bar series

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

    The use of loose bar series

    I am trying to implement the use of bars that are decoupled from the primary bars and any additional bars added by calling AddDataSeries. In my indicator, I created a Bars class instance and calculated its SMA. It appears that I mostly got it working, but the behavior is questionable and it could indicate a bug in NT. It works only when SMA.Calculate = Calculate.OnEachTick .
    Please review the attached code.
    I would appreciate any comments.
    Attached Files

    #2
    Hello YuriyGulyayev,

    It does not appear you are using either of the supported methods for adding a secondary series in the attached document.

    When using AddDataSeries you would not create a separate Bars object. This is done automatically by NinjaTrader in background.

    Below I am providing a link to the help guide on AddDataSeries().


    As well as a link to a reference sample that demonstrates using this.
    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by



    If you instead would like to perform a BarsRequest to request data that is not synchronized with the primary series, you can also do this by creating a BarsPeriod object and supplying this to BarsRequest.Request().

    Below is a link to the help guide on BarsRequest.


    I have an older example of this created while NinjaTrader 8 was in Beta 10, which I am linking below.
    Please let me know if this needs to be updated or causes any errors.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your response, Chelsea.
      All those supported methods, apparently including BarsRequest, require an actual market data, historical or real time. What I am trying to do is to create a Bars instance, populate it with arbitrary data, and execute an arbitrary indicator, such as SMA, based on the bar series. And it kinda works, unless SMA.Calculate==OnBarClose .
      So is it correct to do it this way?
      Is it an NT bug that it doesn't work when SMA.Calculate==OnBarClose ?

      Comment


        #4
        Hello YuriyGulyayev,

        I'm not certain of how to achieve this. It is supported to have a custom series synchronized with the primary series (providing a slot for each bar on the chart for you to populate with arbitrary data) and not with a bars object. With the custom series this can be supplied to an indicator.


        However, creating a new Bars object is not documented in the help guide. Supplying a custom created bars object to an indicator is not documented. As there is no documentation for this, there is no expected behavior for what would happen when doing this.

        To confirm, you've mention that the script does not work when the indicator this bar object is being supplied to has the Calculate property set to .OnBarClose. To confirm, the indicator does not return a value and instead you are getting the close price, and when using .ContainsValue, this is returning false, is this correct?

        Would you like to submit a feature request to allow custom unsynchronized bar objects to be created, populated with arbitrary data, and then supplied to and indicator and have this return a value when the indicator Calculate property is set to .OnBarClose?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The use of data series bound to a "real" bar series is not a very adequate solution.

          The code I sent works and plots a "step ladder". But it will no longer work if you comment out the assignment to sma1.Calculate . It appears that the SMA indicator forgets to increment its CurrentBar , but still increments its Value.Count . As a result, the SMA indicator's OnBarUpdate is called for the 1st time only when its input custom bar series contains at least 2 items and its Value[0] always remains not set.

          Yes, I'd like to submit the feature request. Thank you.

          Comment


            #6
            Hello YuriyGulyayev,

            I've submitted a feature request to allow for a new bar object to be created with an arbitrary amount of bars that can be supplied to an indicator.
            (If this is currently possible, I will request for this to be documented)

            Thanks for taking the time to make the request.
            It is up to our development to decide when and if a request will be implemented.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello YuriyGulyayev,

              I've received a tracking ID for future reference regarding your feature request.
              Your request to allow the creation of an non-synchronized bar option and populate this custom data points and supply this as an input series to an indicator is being tracked with ID #SFT-1753.

              We highly appreciate your feedback. Please let me know of any other suggestions you have for the NinjaTrader platform.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              26 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, Yesterday, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              192 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,234 views
              0 likes
              Last Post xiinteractive  
              Working...
              X