Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Declaration and initializaion of the timeframe

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

    Declaration and initializaion of the timeframe

    Hello,

    I am struggling with the declaration and initilization of the timeframe in my code.
    Could you please help at this level?

    I want to declare and initialize a timeframe. I did as folloow:

    BarsPeriod myTimeFrame = 0;

    While compiling, I receive the error message that BarsPeriod can not be an "int".

    What would be please the correct declaration and initialization of a timeframe?

    Best regards

    #2
    Hello Stanfillirenfro,

    Thanks for the post.

    Can you provide more details on what you are trying to do? AddDataSeries would be used to add new timeframes.

    If you are trying to define variables for use with AddDataSeries please note that AddDataSeries cannot be dynamic or use variables.

    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse for your reply.

      Well what I want to achieve is to normlize the bars on the chars.
      I have the following code:

      Value = Instrument.MasterInstrument.RoundToTickSize((myBar s / (myTimeFrame/BarsPeriod));

      But here I am failling to declare correctly "myTimeFrame".

      Comment


        #4
        Hello Stanfillirenfro,

        From the given details it seems like you may need a integer:

        int myTimeFrame = 0;

        I look forward to being of further assistance,

        Comment


          #5
          Thanks Jesse for your reply.
          Yes I thought it should be an integer, but the condition in which the normalization should be carried out prints error message.
          Here is the condition:

          if(myTimeFrame == 0)
          {
          myTimeFrame = BarsPeriod;

          Value = Instrument.MasterInstrument.RoundToTickSize((myBar s / (myTimeFrame/BarsPeriod));
          }

          Comment


            #6
            Hello Stanfillirenfro,

            What error message are you seeing after using an int variable?

            I look forward to being of further assistance.

            Comment


              #7
              Thanks Chris for your reply!

              First error message: The conversion of the type BarsPeriod in int is not pssoible.
              Second error message: The operator "/" can not be used for thypes int and BarsPeriod.

              Comment


                #8
                Hello Stanfillirenfro,

                The code you originally provided is not valid so that could not be used. The suggestion I provided in post 2 could be used that is just an int variable

                Its still not clear what you are trying to divide by, the BarsPeriod is a complex type that has multiple properties. Are you trying to get the primary series bars and one of the values from the BarsPeriod or what is your specific goal here?


                Please let me know if I may be of additional assistance.

                Comment


                  #9
                  Many thanks Chris for our reply.

                  In the following code

                  Value = Instrument.MasterInstrument.RoundToTickSize((myBar s / (myTimeFrame/BarsPeriod));
                  I want to change the values of numeric columns in the dataset to a common scale, without distorting differences in the ranges of values.

                  Best regards

                  Comment


                    #10
                    Hello Stanfillirenfro,

                    Unfortunately that does not really help to know what value you are trying to get. What value are you trying to use in your math? BarsPeriod is not a value, that contains multiple different values based on the primary bars. You may want BarsPeriod.Value or Value2, I don't know what math you are trying to achieve here to know what to suggest.

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

                    Comment


                      #11
                      Thanks Chris for your reply.

                      I think I have the solution in your answer.
                      The value I am looking for is just the timeframe. I think BarsPeriod.Value is the solution in my case. But I am wondering what it will return in case of 1 hour for example Should that be 1 (hour) or 60 minutes?

                      Best regards,

                      Comment


                        #12
                        Hello Stanfillirenfro,

                        I would suggest using Prints so you can see what specifically the value reports in each use case you plan to use it. The 1 hours should return 60 as the value if you used 60 minute bars.

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

                        Comment


                          #13
                          Many thanks Chris for your reply!
                          I will work on all informtion obtained today and will revert to you.

                          Thanks again!

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          621 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          359 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          105 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          562 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          566 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X