Announcement

Collapse
No announcement yet.

Retrieve close of prior bar for different index

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

  • Retrieve close of prior bar for different index

    Greetings:

    I'm running a formula in a one-minute ES advanced chart and wish to retrieve the close of the prior three price bars for the DAX (for which I'm receiving the data feed), and load them into an array. The formula is using setComputeOnClose(). To do this I'm using the following:

    if (getBarState() == BARSTATE_NEWBAR)
    {
    LastDAXclose = close(-1, sym("$DAX-XET"));
    DAXcloseArray[0] = DAXcloseArray[1];
    DAXcloseArray[1] = DAXcloseArray[2];
    DAXcloseArray[2] = LastDAXclose;
    }


    debugClear();
    debugPrintln(" LastDAXclose: " + LastDAXclose);
    debugPrintln(" DAXcloseArray[0]: " + DAXcloseArray[0]);
    debugPrintln(" DAXcloseArray[1]: " + DAXcloseArray[1]);
    debugPrintln(" DAXcloseArray[2]: " + DAXcloseArray[2]);

    The Formula Output Window is returning:

    DAXcloseArray [2]: 7421.81
    DAXcloseArray [1]: 7421.81
    DAXcloseArray [0]: 7421.81
    LastDAXclose: 7421.81

    Unfortunately, the values for the close of the last three price bars on my one-minute DAX chart are:

    Bar (-1): 7423.51
    Bar (-2): 7422.19
    Bar (-3): 7423.59

    My research to resolve the issue has failed miserably. Can anyone see my error? I can of course set the closing prices I need as Global variables in the DAX chart and pull them into the ES chart, but then I lose my backtesting capabilities.

    Thanks,
    Warren

  • #2
    Warren,

    This is off the top of my head since I haven't taken the time to write a script to prove it out, but try this:

    Comment out the line in your ES script that calls setComputeOnClose(). Use getBarStateSymbol("$DAX-XET, 1") in your ES script and then check the return value from that function call to see when you get a BARSTATE_NEWBAR return code (for the DAX symbol *within* your ES running script) Once you get that BARSTATE_NEWBAR (for the DAX 1 min), looking at the previous close should line up.

    Here's a link to the getBarStateSymbol() function call in the online EFS function reference:



    Go to Function Reference -> Utility Functions and it's on the 1st function listings page.

    There's a solution to your problem but I think the answer is going to rely on setComputeOnClose() not being called within your 1 min ES script.
    Last edited by SteveH; 02-16-2011, 01:27 PM.

    Comment


    • #3
      Thanks Steve! You are exactly correct. I came across that function in my continued research and determined that I needed to turn computeonclose in my testing. Your help is much appreciated though.

      Comment

      Working...
      X