Announcement

Collapse
No announcement yet.

refUsage.efs & refUsage2.efs in bar replay mode

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

  • refUsage.efs & refUsage2.efs in bar replay mode

    Hi,
    I am trying to create a study using the ref() function. When I try to run any EFS function using ref(), including the examples refUsage.efs and refUsage2.efs, in Bar Replay Mode, I encounter an error that prevents execution. It appears that the last call to ref(-1) returns a null vs. the study values of the previous bar. I have only my ref() EFS study on the chart, and am only selecting 30-40 bars for the replay, and looking at a daily chart of the OEX. Is there something I'm doing incorrectly that causes the examples to fail in Bar Replay Mode? Perhaps some eSignal configuration setting (ver. 7.6)? Any help will be appreciated.
    Last edited by trader_joe; 12-15-2004, 07:04 AM.

  • #2
    Hello Trader_Joe,

    Thanks for the report. The BarCntr logic doesn't properly validate our return for ref(-1) in Bar Replay mode. What needs to be added is a null check. Immediately after the line where we set myRef = ref(-1), add the null check like below for both formulas. I'll update our library to reflect this null check as well.

    PHP Code:
    var myRef ref(-1);
    if (
    myRef == null) 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
      Thanks, Jason. I haven't figured exactly how bar replay works, and what restrictions apply. I have tried the code you supplied and did not get favorable results. Experimenting, I have tried this code:

      var myRef = ref(-1);
      debugPrintln("BarCtr= "+BarCntr+" Bar Index: " + getCurrentBarIndex() + " BarState= "+getBarState()+" ref(-1) " + ref(-1) );
      if (ref(-1) == null) return new Array(vMA1, vMA2); //displays study on chart
      // if (myRef == null) return; //doesn't display study on chart

      It seems that the Bar Replay goes through the study twice...once normally, then once again after ref(-1) = null, incrementing BarCtr each time. Function getBarState() also seems to behave differently in Bar Replay.

      Would it be better to abandon the use of ref() and use another method to create a EFS study that works identically in real time and Bar Replay?

      Comment


      • #4
        Hello trader_joe,

        I added your code snippet to the formula on my end and from what I'm seeing it is working properly. No formula errors at least. I'm not sure what you are expecting to see, so maybe you can provide some more details as to what you are trying to accomplish. One thing that you should do, which might be the solution for you, is to reload the formula after you've entered Bar Replay mode. After you've seleced the historical bar to start the replay from, reload the formula before you start the playback, which will properly reset all the global variables. Try that first. If that doesn't produce the results you're expecting I would suggest trying Tick Replay.

        For both Bar and Tick Replay, the main factor that determines whether the formula will work properly is if the formula depends only on the main chart symbol's data to produce results. If a formula requests prices from external symbols or intervals, there will be a synchronization problem.
        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


        • #5
          I guess I wasn't too clear. Overall, I was trying to determine if there was a defect in ref() since the results are different between real time and Bar Replay, or whether I was using ref() or Bar Replay incorrectly. If you add the snippet previously sent, with values returned (if (ref(-1) == null) return new Array(vMA1, vMA2); ), the study will display in Bar Replay. Swapping the commented lines around thusly :

          ---------snip snip ------------
          var myRef = ref(-1);
          debugPrintln("BarCtr= "+BarCntr+" Bar Index: " + getCurrentBarIndex() + " BarState= "+getBarState()+" ref(-1) " + ref(-1) );
          // if (ref(-1) == null) return new Array(vMA1, vMA2); //displays study on chart
          if (myRef == null) return; //doesn't display study on chart

          -----------------------------
          causes the study to fail in Bar Replay (when no study values are returned). The formulas I've been working on don't require any external symbols or intervals.

          I was looking for a simple method to reference previous study values without creating unique variables of global scope for each EFS study, and will work in both real time and Bar Replay. I haven't experimented with EFS functions enough to know if there would be problems similar to ref() by using global variables in Bar Replay. Any known issues on globals in Bar Replay vs. real time?

          Thanks!

          Comment


          • #6
            Hello trader_joe,

            Your logic is correct. To return the vMA1 and vMA2 values to the chart when myRef is null works. The ref(-1) function should work fine in Bar Replay. It's going to return null only if on the previous bar there were no values for vMA1 and vMA2 returned to the chart. Without using some global variables, the ref() function is the only method to reference historical indicator values that are custom calculations. However, with the built-in study objects you can alternatively use the offset parameter of the .getValue() method like below.

            PHP Code:
            var vMA1_1 study1.getValue(MAStudy.MA, -1);
            if (
            vMA1_1 == null) return; 
            It's always a good idea to use null check when referencing historical values this way as well.
            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

            Working...
            X