Announcement

Collapse
No announcement yet.

Fixing plotted lines when changing intervals

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

  • Fixing plotted lines when changing intervals

    Can anyone help me with this?

    I am trying to plot the first 60 minute bar of a chart with the following code (It has taken he all weekend to get this far but it seems to work)

    function preMain() {

    setPriceStudy(true);

    setDefaultBarFgColor(Color.grey,0);
    setDefaultBarFgColor(Color.grey,1);
    setDefaultBarFgColor(Color.grey,2);

    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    setDefaultBarThickness(1,2);

    setPlotType(PLOTTYPE_FLATLINES,0);
    setPlotType(PLOTTYPE_FLATLINES,1);
    setPlotType(PLOTTYPE_FLATLINES,2);

    }

    function main(){

    var vTime = getValue("Time");

    if (vTime != null) {
    var vFirstBar = getFirstBarIndexOfDay( vTime );
    if (vFirstBar != null) {
    v60minHigh = getValueAbsolute( "high", vFirstBar );
    v60minLow = getValueAbsolute( "low", vFirstBar );
    v60minClose = getValueAbsolute( "close", vFirstBar );
    }
    }


    drawLineRelative( -20, v60minHigh, 0, v60minHigh, PS_DASH, 1, Color.green, 0) // First bar high

    drawLineRelative( -20, v60minClose, 0, v60minClose, PS_DASH, 1, Color.green, 1) // First bar low

    drawLineRelative( -20, v60minLow, 0, v60minLow, PS_DASH, 1, Color.green, 2) // First bar close

    }



    However, when I change the chart interval the lines are plotted using the new time interval, which I don't want to happen. Is there anyway I can plot the lines on a 60 minute chart so that when I change intervals, the plotted lines stay put?

    Thank you

  • #2
    Hello Highfield,

    Here's an alternative for you to try. It will work on any intra-day interval. You don't have to start with a 60 min chart. I also added some text labels to the right of the price bars to display the values as well. Let me know if this works for you.


    First60minHLC.efs



    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
      They don't call you super moderator nothing do they! That is pure genius. Thank you Jason K.

      Comment


      • #4
        I've just applied the script to a chart an it works fantastic. Many many thanks to you.

        I especially like the values being printed. This is very helpful.

        Is it possible to print the values at the beginning and on top of the line, rather than at the end of the line in the center?
        Attached Files

        Comment


        • #5
          Hello Highfield,

          Sure. In the drawTextRelative() functions on lines 36, 38 and 40 change the first parameter, which is currently 2, to FirstBar. Also change Text.VCENTER to Text.BOTTOM.
          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


          • #6
            JasonK - I really appreciate the time you have spent working on this. Thank you.

            Comment

            Working...
            X