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

Indicator works on 1-Tick but not on other timeframes

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

    Indicator works on 1-Tick but not on other timeframes

    Hello.

    I am writing an indicator that calculates the cumulative delta for the day. The input data is in the Tick timeframe and consists of Date, Time, Price, Volume and Direction (Long or Short). Since NinjaTrader has no field for Direction, I created a PostgreSQL database to hold all this information. I calculate the cumulative delta and plot the result.

    The indicator works fine if I use the 1-Tick timeframe on the Chart. In any other timeframe, the results are wrong. NinjaTrader is doing everything as if it was on the 1-Tick timeframe. For instance, if I use a 1-minute Chart, it thinks the first minute candle has the volume of the first Tick on the database, the second minute candle has the volume of the second Tick on the database and so on.

    What can I do so NinjaTrader deals with the information of Cumulative Delta the same way it deals with any data that is native to NinjaTrader (such as Date, Time, Price or Volume)? Is there any way to synchronize a variable to the Tick timetrame in such a way that when we change the timeframe, the information is adjusted to fit the new timeframe? Should I use something to accumulate the results depending on the chart type? What if I use Renko?”

    Thank you.
    Claudio

    #2
    Hello ccbiasi,

    Thanks for opening the thread.

    Since you manage your own database that is supposed to be built off of tick data, I would suggest to use a single tick data series added to your indicator to produce the correct data for your database, and then to pull this data for different intervals based on the primary data series.

    This way, your database is built with the highest resolution of data, and then you can use that underlying data to create information relative to another bar type.

    We don't have any resources for using SQL databases in NinjaScript, but the Multi-Series NinjaScripts documentation should give enough insight to build this database and use it as described above. This information is publicly available.

    Multi Series NinjaScripts - https://ninjatrader.com/support/help...nstruments.htm

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you. I am already using the given link. My code changed and now I am not in the 1-Tick anymore, but on the 1-Second. I want this 1-Second cumulative delta to work in any timeframe. So, I am trying to sync the current timeframe as the primary series and the 1-Second as the secondary one. I have a problem with the section Initializing Series<T>. In the example given, the secondary Series is initialized this way:

      secondarySeries = new Series<double>(SMA(BarsArray[1], 50));

      How can I create an Indicator that receives parameters and returns values? I always thought of Indicators as receiving no parameters and returning no values... We just run them... How could I send a parameter or receive a value?

      Well, I looked up the code for SMA and found the lines where parameters are sent and values are returned. However, it was in the "NinjaScript generated code. Neither change nor remove" section. So, if this is not the right place to change them, where it is?

      I looked up my own SecondCumulativeDelta indicator and noticed that there is already an input parameter (Input) and a return value. What is this Input and what is this return value? How can I use the time as Input and the cumulative delta as return value?

      Thank you

      Comment


        #4
        Hello ccbiasi,

        The NinjaScript generated code has to do with creating overloads for the indicator. Within the scope of an indicator, they generally should be built to receive an input series (of doubles) and any input parameters to give the desired output.

        "Input" will refer to the input price series given to the indicator.

        Input: https://ninjatrader.com/support/help...n-us/input.htm

        In the line mentioned, you have are creating a new data series that is synchronized to the output series of the SMA "SMA(BarsArray[1], 50)" which is essentially built off of BarsArray[1].

        It is possible to expose other variables of an indicator publicly so they can be accessed similarly to the output series' (plots.) You could also create public methods to return values.

        An example can show you how that would be done with exposing public variables here: https://ninjatrader.com/support/foru...ead.php?t=4991

        I am not sure the advantage this would have to meeting your goal.

        I want this 1-Second cumulative delta to work in any timeframe. So, I am trying to sync the current timeframe as the primary series and the 1-Second as the secondary one.
        You should be able to build bars of a higher time frame by looking for a "tick-though" of the smaller series. For example, the tick or second used to form the new bar will close the last bar and start the new bar. The BusSellPressure and BuySellVolume indicator can be used as an example of indicators that build a bar with tick data. The same concept can be applied to building bars of a higher timer frame using underlying data. Information based off of the primary data series can be read from the main BarsPeriod object.

        BarsPeriod - https://ninjatrader.com/support/help...barsperiod.htm

        Please let me know if there is anything else I can do to help out.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hi, at last I made the indicator work in every timeframe. I used Time[0] to look at the bar close, and combined it with looking in my database with timestamps for every second of data to syncronize the data.

          However, it still doesn't seem to work on Renko. As a matter of fact, my Renko Chart is really weird. It shows only 1 second of data on the Chart window at a time! I think there is too much data...

          Is there any way I can change the Chart so I can view more data in the Chart window? Zooming out does't help. I am already at the maximum level of zoom out.

          Thanks

          Claudio

          Comment


            #6
            Hello ccbiasi,

            I'm glad you have made progress.

            There will only be as much data in the chart that gets loaded from the data series' added to it and the days/bars to load. I may not be understanding your question fully. You can change the x scale to view more data, but this would not effect OnBarUpdate() operations. It also would not be possible to "zoom out" from a chart's loaded data to as finer set of data.

            The X scale can be adjusted by clicking on the X margin and dragged to the left and to the right.

            Changing X Scale - https://ninjatrader.com/support/help...dRangeOfAChart

            If this information does not resolve your inquiry, could you elaborate on what you are trying to accomplish?

            If you are having an issue with a particular bar type, I would consider how that bar type is built and how it is reacting with your code differently. As Renko bars will form based on price movement, I could imagine issues where direction may change multiple times before a brick is formed, and there being difficulties depending on the chart it is plotted to.

            You may also be able to use the Renko Bar type source code to take a closer look at how the bars are formed and how you can devise a solution. Without taking debugging steps to analyze what is happening exactly with your code, I could not offer much further insight.

            Please let us know if we can be of further assistance.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by gentlebenthebear, Today, 01:30 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by Aviram Y, Today, 05:29 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by cls71, Today, 04:45 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by TradeForge, Today, 02:09 AM
            1 response
            22 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by elirion, Today, 01:36 AM
            2 responses
            14 views
            0 likes
            Last Post elirion
            by elirion
             
            Working...
            X