Announcement

Collapse
No announcement yet.

Global Variables

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

  • Global Variables

    I'm having a little trouble with global variables and can't seem to find an answer in the boards.

    eval("var top"+getSymbol());
    setGlobalValue (eval("top"+getSymbol()),xHigh);
    eval("var btm"+getSymbol());
    setGlobalValue (eval("btm"+getSymbol()),xLow);

    These statements seem to work fine, and all variables are defined and have values. When I try to reference the global variables in another script (same chart for the moment), I get "undefined."

    I am testing this after hours using 1-minute charts, but it is intended to run during the day. How do I reference the global variables in separate scripts? Any help will be appreciated. Thanks.

  • #2
    You don't need the eval as var as I can tell..

    Just create a Global Variable ID (label) and then 'Feed' it the data.

    PHP Code:
    var GV1ID "var top"+getSymbol();
    setGlobalValue (GV1ID,xHigh);

    var 
    GV1ID "var btm"+getSymbol();
    setGlobalValue (GV2ID,xLow); 
    Then, to pull the Gvars...

    PHP Code:

    var GV1ID "var top"+getSymbol();
    //  IDs have to match EXACTLY.
      
    getGlobalValue(GV1ID);

    var 
    GV1ID "var btm"+getSymbol();
      
    getGlobalValue(GV2ID); 
    Hope this helps.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks, Brad. This was helpful.


      Originally posted by Doji3333
      You don't need the eval as var as I can tell..

      Just create a Global Variable ID (label) and then 'Feed' it the data.

      PHP Code:
      var GV1ID "var top"+getSymbol();
      setGlobalValue (GV1ID,xHigh);

      var 
      GV1ID "var btm"+getSymbol();
      setGlobalValue (GV2ID,xLow); 
      Then, to pull the Gvars...

      PHP Code:

      var GV1ID "var top"+getSymbol();
      //  IDs have to match EXACTLY.
        
      getGlobalValue(GV1ID);

      var 
      GV1ID "var btm"+getSymbol();
        
      getGlobalValue(GV2ID); 
      Hope this helps.

      Comment

      Working...
      X