Announcement

Collapse
No announcement yet.

preserving variable values

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

  • preserving variable values

    If I switch timeframes in a chart, any loaded studies have their global variables re-initialized right?

    Is there anyway of preserving these values when the timeframe is switched?

    The only way that I can think of doing this at the moment is to use parameters but I'm trying to do this without parameters.
    Standing on the shoulders of giants.

  • #2
    Wild,

    I think I know why you want it and I hope you cannot do it.

    What you probably want to do is what we all do: use multiple time-frames in your efs. I am using four of them.

    Declare all your studies and vars in all time intervals [EFS2 allows you to do it very simple], then apply your algorithms to each one of them and draw your conclusions.

    Note: you can preserve global variables using reloadefs [but this will be in the same time interval].


    Good Luck!
    Last edited by mbuta; 10-15-2006, 06:18 PM.
    Mihai Buta

    Comment


    • #3
      No that's not what I want to do. I want to be able to click buttons to change the values of some global variables and then switch time frames.

      Say I have a true/false flag that is controlled by a button. Each time I toggle it, it changes something in the study. I call reloadEFS() and it recalcs. Now when I switch timeframes I want to preserve the current values...
      Standing on the shoulders of giants.

      Comment


      • #4
        Hello wildfiction,

        There are two ways to accomplish this task. I would recommend using the application global scope to store these values using setGlobalValue(), getGlobalValue() and removeGlobalValue(). In your functions that set the values based on a button click, also pass that value to an application global variable with setGlobalValue(). Then, within an initialization routine in main(), set the formula globals to the current values stored in the application globals with getGlobalValue() if they are not null. This will reset them to the values you had set before changing the chart interval. If you want to remove the application globals when the formula is removed from the chart add the corresponding removeGlobalValue() calls to the postMain() function.

        The other option is to store the values in a text file using File I/O. The process would be the same except the formula globals will be populated in the initialization routine from the text file.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Many thanks for your response Jason.

          I was thinking about the file I/O option before but thought that if the study is loaded on 2 charts then there would be a clash of values.

          I am guessing that this will also apply to the use of Global Variables? Global Variables are not study specific but available to all studies correct?

          I was thinking of generating a unique identifier for each time the indicator was initially loaded onto the chart (to use file I/O) but I am guessing that the only way to preserve this unique identifier between timeframe switches would be to use the global variables or file I/O and there you run into the same problem. In other words the technique to solve the problem is part of the problem...

          Let me know if my logic above is sound...
          Standing on the shoulders of giants.

          Comment


          • #6
            Hello wildfiction,

            You're most welcome.

            To avoid the problem you've described, you can use the getInvokerID() function to build a unique identifier. Each chart gets assigned a unique ID, which can be accessed with this function.
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Many thanks Jason - that should solve the problem.
              Standing on the shoulders of giants.

              Comment


              • #8
                Are the GlobalValues in EFS secure inasmuch as they cannot be listed or discovered by another EFS which does not know their name?
                Standing on the shoulders of giants.

                Comment


                • #9
                  Hello wildfiction,

                  That's correct. Other formulas would not be able to access the application globals unless they knew the names. There are no other methods for accessing them other than getGlobalValue(), which requires the name of the variable.
                  Jason K.
                  Project Manager
                  eSignal - an Interactive Data company

                  EFS KnowledgeBase
                  JavaScript for EFS Video Series
                  EFS Beginner Tutorial Series
                  EFS Glossary
                  Custom EFS Development Policy

                  New User Orientation

                  Comment


                  • #10
                    Many thanks Jason - If I was to fill out a survey about your help in this thread I'd mark you excellent in all questions - thanks again.
                    Standing on the shoulders of giants.

                    Comment


                    • #11
                      You're most welcome. Thank you for the compliment.
                      Jason K.
                      Project Manager
                      eSignal - an Interactive Data company

                      EFS KnowledgeBase
                      JavaScript for EFS Video Series
                      EFS Beginner Tutorial Series
                      EFS Glossary
                      Custom EFS Development Policy

                      New User Orientation

                      Comment


                      • #12
                        Originally posted by mbuta
                        Wild,

                        I think I know why you want it and I hope you cannot do it.

                        What you probably want to do is what we all do: use multiple time-frames in your efs. I am using four of them.

                        Declare all your studies and vars in all time intervals [EFS2 allows you to do it very simple], then apply your algorithms to each one of them and draw your conclusions.

                        Note: you can preserve global variables using reloadefs [but this will be in the same time interval].


                        Good Luck!
                        Hi mbuta,

                        Do you have any samples of strategies that you have developed using multiple time intervals. I was having trouble getting over inflated backtested profits due to the "forward looking" issue.

                        I gave up to work on other single time strategies and would love to see some examples. I'm not concerned with your entry/exit criteria so much as the synchronization techniques across time intervals.
                        Glen Demarco
                        [email protected]

                        Comment


                        • #13
                          Glen,

                          Sorry for the late reply to this. I don't check the board too often and I did not get any email alert.

                          I see that you got some advice on using external time intervals.

                          The "synchronization" you refer to is [I guess, because it is not clear] how to access historical values that refer to the same bar in your chart.

                          This can be done by calculating the number of bars back in your external interval, based on the number of bars back in your base interval.
                          For example, if you want to access value 10 bars back and your external time interval is 3x base interval, you need to go only 3 bars back in expertnal interval.

                          This is rather time consuming, specially in real time.
                          This is one reason I fake my external time intervals with equivalent periods in base interval. This gives a quite accurate representation for all studies that do not use Wilder's Sum [ADX, RSI, True Range, etc].
                          I also use external time intervals for studies that require a lot of bars, like CCI, which needs 3x bars to calculate. I already use 600 bars charts, which is a lot to chew.

                          Note: If you get this message, please send me an email to confirm.
                          Good Luck!
                          Mihai
                          Mihai Buta

                          Comment

                          Working...
                          X