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

How can I use my own indicator in a multitimeframe indicator

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

    How can I use my own indicator in a multitimeframe indicator

    Hi.

    I am trying to create a Multitimeframe indicator. I read the Multi-Time Frame & Instruments section and I have some questions.

    In the section Initializing Series<T> with an Indicator Method, it is shown how to use a secondary series and how to sync this series:

    /* Syncs another Series object to the secondary bar object.
    We use an arbitrary indicator overloaded with an ISeries<double> input to achieve the sync.
    The indicator can be any indicator. The Series<double> will be synced to whatever the
    BarsArray[] is provided.*/
    secondarySeries=newSeries<double>(SMA(BarsArray[1],50));


    The problem is that the example shown uses SMA as an example. Curiosly, SampleMultiTimeFrame uses SMA too. It seems SMA is used to illustrate everything!



    What if I want to use an indicator of mine? I tried to replace SMA with my own indicator, but it didn't work! In the case of SampleMultiTimeFrame, the variable used to store

    SMA is of type private SMA. Therefore, I guess the only indicator which will fit here is... well... SMA!



    Is there a generic "indicator type" which I can use to hold my own indicator? Or there is another way to tackle the problem? What should I do to make the code work with my own indicator? What if my indicator expects a parameter? What do I have to do to use a parameter?


    Thank you,
    Claudio

    #2
    Hello Claudio,

    Thanks for your post.

    What happens is that if you create series<T> it will, by default, create the series with the same number of slots as the chart bars. If you want instead for the series to sync with a secondary data series then you use the simple SMA to let the system know to create the same number of slots as the secondary series. There is no need to use any other indicator and it is only for this initializing/syncronizing purpose that the SMA is used. The SMA has no other purpose here and there is no need to use your indicator or any other.

    Once the series<T> is correctly synchronized with the secondary data series, you can then use your indicator with the series<T> if you wish.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello and thank you for your answer.

      I will describe what I am trying to do, so you can tell me if multitimeframe is really the way to go.

      I am writing a Cumulative Delta indicator. I already have tick data on date, time, price and directional volume per tick and cumulative directional volume. This data is in a PostgreSQL Database (instrument, date, time, price, volume, directional, cumulative delta). I did manage to plot it directly into a chart within NT8.

      However... If a change the timeframe on NT8, the indicator windows doesn't change! I can't figure out a way to sync the chart timeframe to the indicator timeframe and that’s why I am not sure the multitimeframe solution would work for me...

      The data source of each series is given by AddDataSeries, which expects as parameters a periodtype and a period. This way, we can add any series, as long as it is part of the regular periodtypes of NinjaTrader.

      How about my Cumulative Delta Indicator? Which uses an external Postgres Database and reads the data into DataSets and DataTables? Is there a way to put this information into AddDataSeries? If not, any other idea of how can I make my indicator work not only in Tick but in any timeframe? It is very important that it works not only in the temporal timeframes, but in Renko too.

      Thank you very much,
      Claudio

      Comment


        #4
        Hello Claudio,

        Thanks for your reply.

        To use AddDataSeries, you would need to create a custom instrument and load your data into the historical data manager. NinjaTrader stores 3 types of data, Tick bars, Minute bars, Day bars. I am unsure that this would be the correct solution to use. Here are helpguide references on editing instruments and importing data:



        I'm not sure I understand what you are doing with your indicator or database data but it seems like an appropriate solution may be to read the bar close time of the chart bars data series and calculate what you need to between bar close times and produce a plot value. If the bars change, the close times will also change. Plots are aligned with the chart bars.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello and thanks again.

          From what you said, multitimeframe will not help me.

          But I guess your proposed solution might be on the right track. I am using onEachTick as a Calculate method. Since the code is working only on the tick, I thought that maybe the solution is to update the Plot on the Close, not on the Tick.

          To achieve this, I used if(IsFirstTickOfBar) around the main portion of my code. To my surprise, nothing changed! To see if I could enforce the calculation on the Close, not on the tick, I changed Calculate from OnEachTick to OnBarClose. No effect. Then I changed it to OnPriceChange. Nothing happened!

          My two questions are: is this a viable solution to my problem (Using IsFirstTickOfBar)? What am I doing wrong that the changes I make have no effect at all?

          Thank you,
          Claudio

          Comment


            #6
            Hello Claudio,

            Thanks for your reply.

            To further assist I would need to understand what you are doing with your code along with a screenshot (that shows what instrument, bar type and time base).

            If you do not wish to share your code on-line, you are welcome to send into PlatformSupport[at]NinjaTrader[dot]com, mark the e-mail atten: Paul and include a link to this thread for reference.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Barry Milan, Yesterday, 10:35 PM
            5 responses
            16 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Started by DJ888, 04-16-2024, 06:09 PM
            4 responses
            13 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by terofs, Today, 04:18 PM
            0 responses
            12 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            8 views
            0 likes
            Last Post nandhumca  
            Working...
            X