Announcement

Collapse
No announcement yet.

Need help with a Global Variable problem

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help with a Global Variable problem

    Hello,

    I have been stuck for many days now trying to solve a GV problem and have searched the forum for hours but could not find a solution. Any help would be very much appreciated. This is my problem:

    I have 2 different charts running in 2 different pages. Chart 1 which is ES #F symbol runs on a 1 min chart in Page 1. Chart 2 which is ES U8 symbol on a 1 min chart runs in Page 2.

    In real-time, Im trying to call the current price in chart 1 from chart 2 using Global variables.

    This is the code i have applied to chart 1 in page 1:

    function main() {
    Close1 = Close(0);
    setGlobalValue("val",Close1);
    return null;
    }

    This is the code i have applied to chart 2 which runs in page 2 workspace:

    function main() {
    var vValue=getGlobalValue("val");
    debugPrintln("current price = " + vValue);
    return null;
    }

    when the above 2 codes are attached to each chart in each different page workspace, with chart 2 active to see the print output, i do not see the "chart 1" price update in real-time. I am making a mistake somewhere but cant work it out.

    Any help would be very much appreciated.

    Regards

    Rod
    Last edited by Rocket130713; 09-04-2008, 05:41 AM.

  • #2
    Re: Need help with a Global Variable problem

    Rod
    Assuming I correctly understood the description of your setup the main issue is that you are running the scripts in different Pages. When you close a Page or Layout [by virtue of opening another Page or Layout] all objects contained in it ie charts, etc are also closed hence any efs loaded in those charts will not be executing
    Another issue is that the syntax of Close(0) in the following line of your code example
    Close1 = Close(0);
    is incorrect and should be close(0) Keep in mind that JavaScript is a case sensitive language
    Alex


    Originally posted by Rocket130713
    Hello,

    I have been stuck for many days now trying to solve a GV problem and have searched the forum for hours but could not find a solution. Any help would be very much appreciated. This is my problem:

    I have 2 different charts running in 2 different pages. Chart 1 which is ES #F symbol runs on a 1 min chart in Page 1. Chart 2 which is ES U8 symbol on a 1 min chart runs in Page 2.

    In real-time, Im trying to call the current price in chart 1 from chart 2 using Global variables.

    This is the code i have applied to chart 1 in page 1:

    function main() {
    Close1 = Close(0);
    setGlobalValue("val",Close1);
    return null;
    }

    This is the code i have applied to chart 2 which runs in page 2 workspace:

    function main() {
    var vValue=getGlobalValue("val");
    debugPrintln("current price = " + vValue);
    return null;
    }

    when the above 2 codes are attached to each chart in each different page workspace, with chart 2 active to see the print output, i do not see the "chart 1" price update in real-time. I am making a mistake somewhere but cant work it out.

    Any help would be very much appreciated.

    Regards

    Rod

    Comment


    • #3
      Hi Alex,

      Thank you so much for your help. You were spot on. I need to run all my strategies in the 1 page. Given this do you know of a way to label each window so that when you click on "Window" tab you can see a list of all your strategies ie strat 1, strat 2, strat 3, ......, stratN, etc. then you can locate quickly which chart your strategy is attached to. this could be good if you say have 10 strategies on say 20 diff markets. or do you have to open and close each window one-by-one to find the window and chart that relates to strategy 14 for example?

      This post is not aimed at Alex but if anyone else would like to reply that would be much appreciated. But thank you immensely Alex for your help.

      regards

      Rod

      Comment


      • #4
        Rod
        You are most welcome.
        With regards to your question see my reply in this thread on a similar topic
        Alex


        Originally posted by Rocket130713
        Hi Alex,

        Thank you so much for your help. You were spot on. I need to run all my strategies in the 1 page. Given this do you know of a way to label each window so that when you click on "Window" tab you can see a list of all your strategies ie strat 1, strat 2, strat 3, ......, stratN, etc. then you can locate quickly which chart your strategy is attached to. this could be good if you say have 10 strategies on say 20 diff markets. or do you have to open and close each window one-by-one to find the window and chart that relates to strategy 14 for example?

        This post is not aimed at Alex but if anyone else would like to reply that would be much appreciated. But thank you immensely Alex for your help.

        regards

        Rod

        Comment

        Working...
        X