Announcement

Collapse
No announcement yet.

Replay Mode Issue - Functions returning zero or null values.

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

  • Replay Mode Issue - Functions returning zero or null values.

    I am getting null values from series functions getMonth etc and
    zero values from open, high, close, low functions when in replay mode and using sym(...).

    Here is the test script: TestReplay.efs

    // replay test
    /* Instructions to reproduce issue:
    Open the $DAX-XET,5 in an advanced chart.
    Open the Formula Output window.
    Add this formula.
    See the correct output of date/time and close for DAX and Continuous Contract
    Now go into Bar Replay Mode.
    The date/time are now null and the open/high/low/close for the Contract is zero.
    The value for the current symbol in the chart is correct.
    */

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Replay Test");
    setShowCursorLabel(false);
    }

    function main() {
    if (getCurrentBarIndex() != 0) return(NaN);
    var Symbol = "AX 1!-DT,5";
    var BarIndex = 0;
    debugPrintln(getYear(BarIndex, sym(Symbol)) + "/" + getMonth(BarIndex, sym(Symbol)) + "/" + getDay(BarIndex, sym(Symbol)) + " " +
    getHour(BarIndex, sym(Symbol)) + ":" + getMinute(BarIndex, sym(Symbol)));
    debugPrintln("Index Open = " + open(BarIndex).toFixed(2) + " Contract Open = " + (open(BarIndex, sym(Symbol)) + 0).toFixed(2));
    debugPrintln("Index High = " + high(BarIndex).toFixed(2) + " Contract High = " + (high(BarIndex, sym(Symbol)) + 0).toFixed(2));
    debugPrintln("Index Low = " + low(BarIndex).toFixed(2) + " Contract Low = " + (low(BarIndex, sym(Symbol)) + 0).toFixed(2));
    debugPrintln("Index Close = " + close(BarIndex).toFixed(2) + " Contract Close = " + (close(BarIndex, sym(Symbol)) + 0).toFixed(2));
    }

    You will get data when in live mode for all function calls.

    In Replay Mode you only get data when there is no “sym(Symbol)” in the function call. The date/time functions return null and the open, high,low, close functions return zero.

    See attached file for output.

    Is this a bug? Is there something else I'm missing or not doing correctly?

    Thanks,
    Ivan
    Attached Files
    Last edited by icvidler; 09-13-2009, 04:53 PM.

  • #2
    Here is your problem...

    if (getCurrentBarIndex() != 0) return(NaN);

    With this statement at the beginning of your main() function, you are instructing the script to return a "Non-Available Number" and quit.

    If you remove this line from your code it might work the way you want. At least is will work is replay mode.

    In replay mode (I believe), the efs engine already has all the bars in memory and it updates the RT price also. Thus, you are scrolling thru historical data while the RT data (new bars) are being maintained in memory.

    This is why while you are running a replay chart, you'll still see new TICKS come in (causing your efs to execute as well).

    Give it a try and see what happens.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks for that Brad.

      I have run it again with and without the statement
      if (getCurrentBarIndex() != 0) return(NaN);

      It seems to work fine now either way.

      Thanks for the info on how the efs engine works.

      Ivan

      Comment

      Working...
      X