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

Multi-Time Frame Class

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

    Multi-Time Frame Class

    Hey guys, question is there a way to make an indicator Call a class from Multi-Data Series?

    In other words if I have a Class

    Code:
     
    //CLASS
    protected int CalcTest(Trial.MarketDataType e)
    		{
    			return 
                CalcTest(e.TickType,e.Price,e.Volume,calcMode,backupMode,filterSize,filterMode);
    		}
    and I use that in my indicator

    Code:
    //10 Tick Range Bar Time Frame
    Add(PeriodType.Range, 10);
    ........
    
    protected override void TrialOnMarketData(Trial.MarketDataType e)
    		{
    			int tester= CalcTest(e);
                            testVolume += e.Volume;
    
                     }

    How do I make TrialOnMarketData use the Data from my 10 Tick range Bar??

    #2
    Sample Indicator

    Basically I just want to know how to make the Attached Indicator into Multi_Data Series. So that if I place the Indicator on EUR/USD chart, it can read the MarketDepth from the 6E chart.
    Attached Files

    Comment


      #3
      Hello,

      Thank you for the post.

      You are likely already including this data when running the script, OnMarketData is subscribed for each instrument you add. If you are not currently doing any filtering, each of the event arguments that is passed in should be sent to this method.

      If you want to only use that series for this method, you would need to filter the instruments in the OnMarketData like the following:

      Code:
      if(e.Instrument.FullName == "ES 06-17")
      You could use a better system than just a string of course but you would need to filter the market events for only the series you want to pass to this method if not all events should go to this method.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        I'm so confused, How would the indicator know to take the Data from the Other Data Series Type.

        if I Add(BarType.Range, 5); What do I place in the Code to make it Only Look for Data from DataSeries[1][1]??

        Can you give an example please?




        Code:
          /// </summary>
                protected override void OnMarketDepth(MarketDepthEventArgs e)
                {
        			List<LadderRow> rows = null;
        
        			// Checks to see if the Market Data is of the Ask type
        			//if (e.MarketDataType == MarketDataType.Ask)
                                
                                if(e.Instrument.FullName == "ES 06-17") 
        			{
        				rows = askRows;
        				
        				// Due to race conditions, it is possible the first event is an Update operation instead of an Insert. When this happens, populate your Lists via e.MarketDepth first.
        				if (firstAskEvent)
        				{
        					if (e.Operation == Operation.Update)
        					{
        						// Lock the MarketDepth collection to prevent modification to the collection while we are still processing it
        						lock (e.MarketDepth.Ask)
        						{
        							for (int idx = 0; idx < e.MarketDepth.Ask.Count; idx++)
        								rows.Add(new LadderRow(e.MarketDepth.Ask[idx].Price, e.MarketDepth.Ask[idx].Volume, e.MarketDepth.Ask[idx].MarketMaker));
        						}
        					}
        					firstAskEvent = false;
        				}
        			}

        Comment


          #5
          Hello,

          The prior example was in reference to your statement which included two different instruments:
          So that if I place the Indicator on EUR/USD chart, it can read the MarketDepth from the 6E chart.
          To know a primary versus a secondary that are different instruments I would suggest using the instrument name as this is passed in with the event. You can also use BarsInProgress but both of these items would be irrelevant in the case where the primary and secondary instruments are the same instrument. In that case, you only have one subscription to the market data.

          In your first post, if you are only adding the following series:
          Code:
          Add(PeriodType.Range, 10);
          Then the OnMarketData is already configured to receive data for only the primary instrument. OnMarketData is a tick by tick stream, it doesn't matter what series you are using it would always be the same stream of incoming live data. This is not broken into bricks like a chart but instead, uses tick data.

          If you are adding other instruments for example:
          Code:
          Add(PeriodType.Range, 10);
          Add("ES 06-17", PeriodType.Minute, 1);
          Add("EURUSD", PeriodType.Minute, 1);
          In this situation, because there is more than 1 different instrument, you would need to use a filter in OnMarketData because there are multiple subscriptions now that there is more than 1 different instrument.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            I appreciate the help. However, the filter
            Code:
            if(e.Instrument.FullName == "6E 06-17") 
            			{
            is just giving an error. "Does not contain a definition....."

            I think the "e.Instrument" isn't working. Can you look at the attached indicator, and Please give example?? to filter and ONLY use the Data from 6E 06-17.
            Attached Files
            Last edited by ginx10k; 05-10-2017, 12:22 PM.

            Comment


              #7
              Hello,

              You have already provided a sample of the filtering yourself in post #4, you would just need to use similar syntax to that post to accomplish the filter in your own script. As I am unsure how your script is laid out, I can only suggest that this check needs to go in the OnMarketData override.

              In your first post, you are not using standard NinjaTrader objects so potentially you need to use another syntax, I could not say as this is a custom object in the script you are using.

              Code:
              protected [U]override [/U]void [U]TrialOnMarketData[/U]([B]Trial.MarketDataType[/B] e)
              I'm not sure what a Trial.MarketDataType object is, but based on the use it looks similar to a MarketDataEventArg which is passed with the normal OnMarketData override. The standard object has an Instrument object which you can reference. Potentially the error you are seeing is that the Trial.MarketDataType does not have an instrument object. This would be something you would need to explore further. This may also be a case where it would be easier to create a new empty script and test your filter condition by its self outside of the context of the custom structure you are using.

              Regarding the sample you are attaching, this is using the
              Code:
              protected override void OnMarketDepth(MarketDepthEventArgs e)
              The MarketDepthEventArgs object specifically does not have an Instrument object.

              Are you trying to edit the code you originally posted or trying something else related to this sample? Could you clarify what you are specifically trying to do as these concepts are different?

              If you are trying to edit the existing script or your question in post 1, you would need to check where the Trial.MarketDataType is supplied from and if that object has an Instrument object to complete the check. If you are instead trying to use the
              MarketDepthEventArgs you would need to use the following syntax:

              Code:
              MarketDepth depth = (MarketDepth)e.Sender;
              Print(depth.Instrument.FullName);

              Please let me know if I may be of further assistance.
              Last edited by NinjaTrader_Jesse; 05-10-2017, 12:33 PM.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Ok. Let's please disregard the first post. I uploaded an indicator which was taken from the samples on this forum.

                All I want is to USE THE DATA from 6E on that indicator. While attached to another chart. Filtering out any other data.

                U keep saying I already did that, but I'm telling you. It's not working. Can you look at the attached code. And just show me where and what exactly is supposed to be placed. Please

                Comment


                  #9
                  Hello,

                  I posted a note about the sample you have been providing regarding the syntax needed to get the instrument in my last reply. The overall syntax would be the same to form the if statement, you would just need the instrument, depending on what override you are using it would be accessed differently.

                  In this post, you have posted a few different examples so I am trying to provide answers in line with what you have been asking about. As the example keeps changing this does make it difficult to know what you are specifically trying to do and what syntax I should actually provide.

                  If the override being used is OnMarketDepth, you would need to see the later part of my last reply regarding OnMarketDepth and the syntax provided. In that case, you could create an if statement to check the instrument like the code you quoted.

                  Code:
                  MarketDepth depth = (MarketDepth)e.Sender;
                  if(depth.Instrument.FullName == "ES 06-17")
                  Otherwise, if you are using OnMarketData you would use e.Instrument.FullName as shown in post #3.

                  If you are using the syntax from post 1, it would be different as that has a nonstandard structure. In that situation, I would need to see the actual script to know what syntax to provide.

                  If you are unable to identify which sample you would need to use, please post the script in its entirety that shows what you are trying and I could provide a more direct answer.

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

                  Comment


                    #10
                    Why can't you just use BarsInProgress to tell which series is triggering the event?
                    As far as I know it works just as well in OnMarketDepath as it does in OnBarUpdate.

                    Comment


                      #11
                      Just want to say, Thanks, Took some Reviewing but I understand now what you were saying. Jesse.
                      Last edited by ginx10k; 05-10-2017, 04:59 PM.

                      Comment


                        #12
                        The script uses OnMarketDepth. I don't wanna change the original too much. Just want it to use Another DataSeries.

                        Originally posted by Ricam View Post
                        Why can't you just use BarsInProgress to tell which series is triggering the event?
                        As far as I know it works just as well in OnMarketDepath as it does in OnBarUpdate.

                        Comment


                          #13
                          Hello,

                          if you are specifically using the sample we provide which you have been attaching and are specifically using two different instruments, please see my post # 7 and #9 for the syntax to filter this from OnMarketDepth.

                          If you are using the same instrument for the added series, there is not an additional filter needed as only one subscription exists.


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

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by StrongLikeBull, Yesterday, 04:05 PM
                          1 response
                          12 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by Mestor, 03-10-2023, 01:50 AM
                          14 responses
                          375 views
                          0 likes
                          Last Post z.franck  
                          Started by molecool, 10-09-2017, 10:48 AM
                          5 responses
                          1,621 views
                          0 likes
                          Last Post trader-ap  
                          Started by The_Sec, Yesterday, 03:53 PM
                          1 response
                          12 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by mmenigma, Yesterday, 03:25 PM
                          1 response
                          11 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Working...
                          X