Announcement

Collapse
No announcement yet.

Displaying 5 minute Tick value on a chart

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

  • Displaying 5 minute Tick value on a chart

    Hello,

    I need help with a basic script. All I want to do is display the 5 minute TICK value in the middle of the screen. I don't really want to have a study created but just draw it on the graph so I can always see it. I also want it to continously update every 5 minutes. Here is what I have so far....can someone tell me what I am doing wrong?


    function main() {

    var nTickHigh_1 = high( -1, sym("$TICK,5"));
    var nTickLow_1 = low( -1, sym("$TICK,5"));
    var nTickClose_1 = close( -1, sym("$TICK,5"));


    drawTextAbsolute(0,55.0,nTickClose_1,Color.blue,nu ll,Text.ONTOP
    return null;

  • #2
    Hello edhecht,

    The code you posted was incomplete. Please post the rest of your drawTextAbsolute() function.

    In general, this should work as you want if the formula is running on a 5-minute chart. If running on any other interval you can encapsulate the drawing function inside a conditional if() statement that looks for the BARSTATE_NEWBAR of the 5-minute interval using getBarStateInterval("5");.

    PHP Code:
    if (getBarStateInterval("5") == BARSTATE_NEWBAR) {
        
    drawTextAbsolute(/*  your parameters */);

    Also I see that your first parameter for the x-axis location is 0. Depending on what your chart right margin offset is set to, you may not be able to see the text. Try something like -5 or -10 instead. Also the hard coded value of 55 for the y-axis location will only allow you to see the text label on chart symbols that are trading at that price level. Try passing close(0) for that parameter instead.
    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
      TICK DISPLAY

      Hello,

      Sorry for half. I have incorporated your changes and it looks as follows. I have also included the output. What it did was create a study at the bottom and put the value in the study. I want to have this number within the graph instead of a new study. I don't even mind putting it above the bars or somewhere on the screen towards the middle.

      function main() {

      var nTickHigh_1 = high( -1, sym("$TICK,5"));
      var nTickLow_1 = low( -1, sym("$TICK,5"));
      var nTickClose_1 = close( -1, sym("$TICK,5"));



      if (getBarStateInterval("5") == BARSTATE_NEWBAR) {
      drawTextAbsolute(-10,close(0),nTickHigh_1,Color.blue,null,Text.ONTOP | Text.CENTER, "Courier New",10);
      }
      return null;
      }

      Comment


      • #4
        edhecht

        What it did was create a study at the bottom and put the value in the study. I want to have this number within the graph instead of a new study.
        By default a script will plot as a non price study (ie in a separate window). In order to plot it as a price study you need to add a preMain() function and in it include a setPriceStudy(true) statement.
        For a detailed explanation of preMain() and all the statements that can be used in it please see the Tutorial 3: Introduction to preMain() and main() in the EFS KnowledgeBase
        Alex

        Comment

        Working...
        X