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

“call an indicator” ?

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

    “call an indicator” ?

    Hello, is it possible to loop all instrument in an instrument list, and for each instrument “call an indicator” with that instruments data?

    I have an indicator making a file (unique for each instrument), and it is very time consuming to change instrument manually by the menu.

    Any suggestions … ?

    Thank you/ AndBro

    #2
    Hello AndBro,

    Thanks for opening the thread.

    You could loop through an instrument list to add the data series to a "parent" indicator, and you could then call each "child" indicator within that indicator referencing one, or each of your added data series. Referencing another indicator within another indicator is easy to do, while adding the indicator so you can see plots requires accessing those plots manually.

    Here is a rough example of looping through an instrument list.
    Code:
    ICollection<Instrument> list = NinjaTrader.Cbi.InstrumentList.GetInstruments("My Instrument List"); // you will want to change the "My Instrument List" string to the name of your instrument list
    foreach (Instrument instrument in list)
    {
        AddDataSeries(instrument.FullName, BarsPeriod);
    }
    You will need to add the Collections namespace to use the ICollection. Collections: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    When referencing your indicators, you will have to reference the BarsArray for the additional data series you wish to calculate it with. For example:

    Code:
    EMA(BarsArray[1], 20);
    BarsArray, and using multiple data series can be referenced in the documentation here: https://ninjatrader.com/support/help...nstruments.htm

    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jim; 05-17-2017, 08:15 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello Jim, thank you for the code and explanations. I think I understand how it should work but obviously, I do not! I have made two mini-mini indicators, A and B.

      Indicator A is the “parent”, and my intention is that indicator B will be called for every instrument I my instrument list. In my test-case I only go for one instrument (BarsInProgress == 1).

      This is my trace print:
      - Indicator A, Instrument name: ABB_ST CurrentBar: 0 BarsInProgress: 1 BarsArray[1].Count: 7738
      - BarsInProgress == 1
      - Indicator 'A': Error on calling 'OnBarUpdate' method on bar 1823: Index was outside the bounds of the array

      I attached my two indicators.

      I can’t figure out what is wrong here? (The debug from VS doesn’t give me any clue either …)


      Thank you/ AndBro
      Attached Files

      Comment


        #4
        Hello AndBro,

        In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

        That being said, I have looked at your code briefly, and I have noticed that you are referencing a barsAgo from your "B" indicator, which does not have any plots. You should be able to see your prints if you call the B indicator instead of referencing a barsAgo.

        If you would like to look into debugging services, you can write in to platformsupport[at]ninjatrader[dot]com with the thread URL and the text "Attention Jim." I will be able to get you connected with a member of our Business Development team who can provide a list of NinjaScript Consultants who would be happy to develop and debug your code.

        Please let me know if I may be of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hello Jim,
          Yes of course the problem is the plot. I was so much focusing on possible multi-series errors …
          Anyway, it works fine now.
          Thank you /AndBro

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          27 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, 04-23-2024, 09:53 PM
          2 responses
          49 views
          0 likes
          Last Post wzgy0920  
          Started by Kensonprib, 04-28-2021, 10:11 AM
          5 responses
          193 views
          0 likes
          Last Post Hasadafa  
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,235 views
          0 likes
          Last Post xiinteractive  
          Working...
          X