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

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

    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!");
        				}
        			}
                }

        Comment


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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ZenCortexAuCost, Today, 04:24 AM
          0 responses
          3 views
          0 likes
          Last Post ZenCortexAuCost  
          Started by ZenCortexAuCost, Today, 04:22 AM
          0 responses
          0 views
          0 likes
          Last Post ZenCortexAuCost  
          Started by SantoshXX, Today, 03:09 AM
          0 responses
          13 views
          0 likes
          Last Post SantoshXX  
          Started by DanielTynera, Today, 01:14 AM
          0 responses
          2 views
          0 likes
          Last Post DanielTynera  
          Started by yertle, 04-18-2024, 08:38 AM
          9 responses
          42 views
          0 likes
          Last Post yertle
          by yertle
           
          Working...
          X