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

Period Type

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

    Period Type

    Hi,

    How can i know indicator added chart period type in script?

    Thanks.

    #2
    aytacasan, you can work with BarsPeriod Id and Value to access the interval and charttype used -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hello,

      I tryed get the chart period type like exaple but i receive an error. I think this error reason is i try to get this value in initialize method. I need this because indicator have to timeframes string parameter that user set wich time frames must work in indicator. For example user can set timeframes parameter like "233, 610". Than I try to add this time frames in initialize. How can i do this in Ninja?

      Regards.
      Last edited by aytacasan; 11-23-2010, 05:43 PM.

      Comment


        #4
        aytacasan,

        Please post exact code of what you currently have and the exact error message you receive. Thank you.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I receive an error like this "you can not use BarsInProgress in initialize". However already i don't use it in initialize. I think code not compile exactly and compiler don't see initialize end sign. If you change Add(Bars.Period.Id, int.Parse(timeFrame)); via Add(PeriodType.Tick, int.Parse(timeFrame)); everything looks good but actually this is not what i want to do.

          #region Variables
          // Wizard generated variables
          private string extraTimeFrames = "377,610"; // Default setting for ExtraTimeFrames
          // User defined variables (add any user defined variables below)
          #endregion

          protected override void Initialize()
          {
          string[] timeFrames = ExtraTimeFrames.Split(',');
          foreach(string timeFrame in timeFrames)
          if (!string.IsNullOrEmpty(timeFrame.Trim()))
          Add(Bars.Period.Id, int.Parse(timeFrame));

          CalculateOnBarClose = true;
          AutoScale = false;
          Overlay = true;
          }

          protected override void OnBarUpdate()
          {
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.
          if (BarsInProgress == 0)
          {
          }
          }

          #region Properties
          [Description("Extra Time Frames")]
          [GridCategory("Parameters")]
          public string ExtraTimeFrames
          {
          get { return extraTimeFrames; }
          set { extraTimeFrames = value; }
          }
          #endregion
          Last edited by aytacasan; 11-23-2010, 06:09 PM.

          Comment


            #6
            Please remove your logic (loop) from the Initialize() and just try BarsPeriod.Id / BarsPeriod.Value - this should not result in any errors, if yes please send me the full script to our support email at I will give it a quick run here on my end.

            Thanks
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hello Bertrand,

              Sory I don't understand you exactly. But I attached my sample indicator that make up the error.

              Thanks.
              Attached Files

              Comment


                #8
                What I meant was try using BarsPeriod.Id instead of Bars.Period.Id - would you then see the same log entry?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Sory, i understand you now exactly. And I tryed this and yes now working my indicator.

                  Thanks for your help.
                  Last edited by aytacasan; 11-24-2010, 12:42 PM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Rapine Heihei, Today, 08:19 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Rapine Heihei, Today, 08:25 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post Rapine Heihei  
                  Started by f.saeidi, Today, 08:01 PM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Rapine Heihei, Today, 07:51 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Rapine Heihei  
                  Started by frslvr, 04-11-2024, 07:26 AM
                  5 responses
                  98 views
                  1 like
                  Last Post caryc123  
                  Working...
                  X