Announcement

Collapse
No announcement yet.

Global Variables and Multiple Timeframes

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

  • Global Variables and Multiple Timeframes

    I am looking for examples on how to use GlobalValues to pass information from one chart to another . Any example will do or tips appreciated . For example I want to use a condition on a 5 minute chart to filter trades on a 1 minute chart so I would set a Global Variable with an EFS file on the 5 minute that would then be picked up by a strategy EFS on the lower timeframe .

    Is it as simple as having an EFS on the 5 minute call setGlobalValue and an EFS on the 1 minute call getGlobalValue ?

    Thanks in Advance

  • #2
    Hello Billmini,

    Yes, it is just that simple.

    Use setGlobalValue() in your first chart:

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
    }

    function 
    main() {
        var 
    vValue close(-2);
        
    setGlobalValue("vPrice"vValue);
        
        return;

    Use getGlobalValue() in your second chart:

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
    }

    function 
    main() {
        var 
    myValue getGlobalValue("vPrice");
        if (
    getCurrentBarIndex() == 0
            
    debugPrintln(myValue);  // Open the formula output window to view results.
        
        
    return;

    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


    • #3
      There is a possible glitch here, in that there is no way to prioritze the loading of the charts except by loading them by hand, and no way to sych the charts up for the historical data displayed. So while doing globals will work with RT data with reasonable accuracy (understanding that you might always be a tick or so off, or a bar off if using ComputeOnClose()), for historical data it could be entirely possible that one chart could finish populating before the other even starts...

      Backtesting is also impossible with such a setup.
      Garth

      Comment


      • #4
        Re: Reply to post 'Global Variables and Multiple Timeframes'

        Now taking suggestions on possible solutions to this dilemna? What it comes
        down to is how to tell one EFS not to run until some 'event' has occurred.

        Anyone have thoughts?

        m.

        --- [email protected] wrote:
        > Hello mattgundersen,
        >
        > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        >
        Matt Gundersen

        Comment


        • #5
          All good points . It comes down to a master strategy controlling 2 minor strategies I think . Think of a scheduler in a real time operating system or even a Windows task scheduler or sequencer . I don't have a problem loading the charts in the right sequence assuming that the higher timeframe chart is not doing anything but setting flags for the lower timeframe chart to act on . It is the critical animal in real time operation as it is likely the one placing orders and monitoring stops etc. for us mechanical system folks and the higher time frame is only supplying information to guide the decision making of the lower timeframe . As for backtesting it would be marvellous to have such an animal and I suggest that you not think of it as trying to test 2 strategies but testing one strategy that has 2 inputs . You of course have to have a sound strategy to begin with and it should be able to run by itself espcially taking the case where you are comparing 2 markets . Data delays etc. on 1 symbol would drive a multiple chart strategy crazy I expect .

          P.S. Thanks Jason for the speedy response

          Comment


          • #6
            Matt,

            I private mailed you a number of possible implementation to fix this. I know these will not be trivial improvements (whichever way you go), but feel they are critical for implementing some strategies.
            Garth

            Comment

            Working...
            X