Announcement

Collapse
No announcement yet.

isPlayBackMode() example does not compile

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

  • isPlayBackMode() example does not compile

    The online KB 2176 for isPlayBackMode() has an example.
    I copied it into a script, but the syntax checker fails it (on the isPlayBackMode() line).

    PHP Code:
          if ( isPlayBackMode$PLAYBACK getSymbol() ) == true ) {
             
    debugPrint"Sorry. This script does not run in playback mode.\n" );
             
    bBail=true;
             return;
          } 
    Is this for Bar Replay? Neither this article, nor 2178 "isReplayMode() " say what "Replay" they mean.


    Also, I've not got far testing a script in Bar Replay mode, but as far as I can tell:

    1) BARSTATE_NEWBAR is not sent for Replay'ed Bars (any bar drawn when I click a "Right Arrow, single step or "Play"). I see state == 1 (CURRENTBAR I suppose)

    2) Relative Annotation (drawTextRelative(0,AboveBar1....)" produces a letter that does not move with the bars as I advance the bars using the replay buttons.

    Is there a problem testing scripts with Bar Replay, or am I missing something?

    Thanks

  • #2
    Hello Dave,

    I've updated the KB article to correct the code example and description. The isPlayBackMode() function is for detecting Tick Replay and the isReplayMode() function is for detecting Bar Replay.

    In Bar Replay mode, getBarState() returns BARSTATE_NEWBAR for each bar. There won't be a BARSTATE_CURRENTBAR. That state refers to trades that occur after the opening trade during a bar in tick-by-tick processing, which does not occur with Bar Replay mode.

    You can verify this with the following code example, which also has a drawTextRelative() example. Run it as a price study. The labels drawn by this function will stay with the bars as they move back in the history as long as you're using a unique tag name for each one. If you use the same tag name for the function, it will redraw the label at the specified location each time the formula executes. This may be what you are seeing with your code example. Hope this helps.

    PHP Code:
    var nCntr 0;

    function_main()_
        if (
    getBarState() == BARSTATE_NEWBAR) {
            
    debugPrintln("new bar " nCntr++);
        }
        
        
    drawTextRelative(0AboveBar2nCntr
                        
    Color.bluenullText.PRESET|Text.CENTER
                        
    null12nCntr);
        
        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

    Working...
    X