• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Solution to use dates within another indicator

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

    Solution to use dates within another indicator

    Hi,

    I was hoping I could get some suggestions as to possible solutions to a problem.

    What I would like to know is can I have X amount of dates in indicator1 and with indicator2 check somehow to see if any of the dates within indicator1 match today's date & if so then do 'code here'? I obviously don't want to use Streamreader or ReadAllText & as there are so many dates I don't want to expose them individually as I'm sure (even though I don't know how) that there is a far better solution?

    Thanks for your kind help,
    suprsnipes

    #2
    Hello suprsnipes,

    Thank you for your post.

    Pass the Time[0].Date as a StringSeries in Indicator one, expose this Series and then call it from the second indicator and compare against Time[0].Date.

    For information on StringSeries please visit the following link: http://www.ninjatrader.com/support/h...ries_class.htm

    For information on exposing variables that are not plots please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=4991
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Thanks for your response. I have read both the links provided and I apologize in advance however I am still confused about how I can utilize this. Do I have to expose each variable on individually? I don't really want to do that.

      Could you please provide additional clarification?

      For example I have 10 dates as follows;

      Code:
                  20070108
                  20070207
                  20070307
                  20070406
                  20070507
                  20070607
                  20070709
                  20070807
                  20070910
                  20071005
      Do you think you could provide some sample code for this?

      Regards,
      suprsnipes
      Last edited by suprsnipes; 05-24-2015, 08:46 PM.

      Comment


        #4
        Hello suprsnipes,

        Thank you for your response.

        Below is the example of the indicator that pulls the time to be compared by the other:
        Code:
                #region Variables
        		private StringSeries myString;
                #endregion
        		
        		protected override void Initialize()
        		{
        			myString = new StringSeries(this);
        		}
        
                protected override void OnBarUpdate()
                {
        			myString[0] = Time[0].Date.ToString();
                }
        		
                #region Properties
                [Browsable(false)]
                [XmlIgnore()]
                public StringSeries MyString
                {
                    get { return myString; }
                }
                #endregion
        Below is how I use a for loop to check against the base indicator's dates by using for loop:
        Code:
                #region Variables
        		private int period = 20;
                #endregion
        		
        		protected override void Initialize()
        		{
        			
        		}
        
                protected override void OnBarUpdate()
                {
        			for(int i = 0; i < period; i++)
        			{
        				if(Time[0].Date.ToString() == Test1().MyString[i])
        				{
        					Print("Match!");
        				}
        			}
                }
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          Thanks very much Patrick, your sample was extremely helpful.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by tvaughan4, Today, 01:02 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by RtelTrade, Today, 01:27 PM
          0 responses
          3 views
          0 likes
          Last Post RtelTrade  
          Started by NinjaTrader_Brandon, Today, 01:19 PM
          0 responses
          8 views
          0 likes
          Last Post NinjaTrader_Brandon  
          Started by nedstrader, Today, 01:01 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by RolloHarper, Today, 12:59 PM
          0 responses
          8 views
          0 likes
          Last Post RolloHarper  
          Working...
          X