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 to Pass DataSeries to Custom Indicator?

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

    How to Pass DataSeries to Custom Indicator?

    I am wondering if it is possible to pass a DataSeries to a Custom Indicator.

    If so, can you please point me to an example?

    I have been trying to do the following
    Code:
            
          #region Variables
    				private DataSeries 		highRef; 	
          
          protected override void Initialize()
          {
    		      highRef 		= new DataSeries(this) ;
          }
          
          #region Properties
    	[Browsable(false)]
            [XmlIgnore()]		
            public DataSeries HighRef
          {
             get { return highRef; }
    	set { highRef.Set(Values); } 
           }


    Thanks,
    ATC
    Last edited by tornadoatc; 02-28-2013, 10:01 AM.

    #2
    Hello ATC,

    By default NinjaTrader will automatically add an overload method that will take a Data Series that can be used your calculations along with all of your other User Defined Variables. See attached image.

    Will that be able to work with what you are trying to accomplish?
    Attached Files
    JCNinjaTrader Customer Service

    Comment


      #3
      I am wondering if more than one (the default) DataSeries can be passed into class ...

      Lets say I want my Indicator to work with two DataSeries called HighRef and LowRef but sometimes I want the HighRef to be based on High and sometimes I want HighRef based on High + 2*ATR(14) . LowRef would be similar, so want to pass in two DataSeries .

      Otherwise I am thinking I could use an int variable and put the logic in the indicator saying something like:
      Code:
      if (highRefType == "H+ATR") HighRef.Set(High[0] + 2 * ATR(14)[0]) ;
      etc ..
      Last edited by tornadoatc; 02-28-2013, 11:24 AM.

      Comment


        #4
        Hello ATC,

        You may use the IDataSeries to be able to pass an array of prices such as a DataSeries to an Indicator. Our Help Guide has an example of this that you may view at the link below.



        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hello JC,

          Is there any way to pass an iDataSeries into Indicator as a Parameter?

          Code:
          		#region Variables 
                          private IDataSeries i_HighRef ; 
          
          
                          [Description("High Reference for Stop Calculations")]
          		[Category("Stop Parameters")]
          		[Gui.Design.DisplayNameAttribute("\t High Reference for Stop Calculations")]
          		public IDataSeries I_HighRef
          		{
          			get { return i_HighRef; }
          			set { i_HighRef = (IDataSeries) value; }  // ???????? 
          		}
          Also, there doesn't seem to be a way to pass in High[0]. Say I change the above to a double. But when I try to enter value for double parameter I can't enter High[0].

          Click image for larger version

Name:	ScreenHunter_01 Mar. 01 12.11.gif
Views:	1
Size:	3.7 KB
ID:	867041
          Last edited by tornadoatc; 03-01-2013, 11:14 AM.

          Comment


            #6
            Hello tornadoatc,

            There would not be a supported way to pass a DataSeries or IDataSeries as a User Defined Parameter. You would have to use a custom method as shown in the example of the IDataSeries Help Guide.
            JCNinjaTrader Customer Service

            Comment


              #7
              you can pass it like a string and then inside code parse the string to the type you want to use.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              3 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              238 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              384 views
              1 like
              Last Post Gavini
              by Gavini
               
              Started by oviejo, Today, 12:28 AM
              0 responses
              4 views
              0 likes
              Last Post oviejo
              by oviejo
               
              Started by pechtri, 06-22-2023, 02:31 AM
              10 responses
              125 views
              0 likes
              Last Post Leeroy_Jenkins  
              Working...
              X