Announcement

Collapse
No announcement yet.

HH and LL's

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

  • HH and LL's

    Hi, I was wondering if there was a way to achieve this in a chart with labels, like in Ensign?
    Attached Files
    Last edited by atlas; 12-01-2007, 02:17 PM.

  • #2
    I tried to modify zig-zag, but it seems like a few labels are missing:

    PHP Code:
    /*******************************************************************
    Description    : This Indicator plots ZigZag indicator
    Provided By    : Developed by TS Support, LLC for eSignal. (c) Copyright 2002
    ********************************************************************/

    function preMain()
    {
        
    setPriceStudy(true);
        
    setStudyTitle("ZigZag");

    }
    var 
    First true;
    var 
    RP null;
    var 
    RPPoint null;
    var 
    RP1 null;
    var 
    RPPoint1 null;
    var Switch = 
    0;
    var 
    Condition1 false;
    var 
    Condition2 false;
    var 
    "X";
    var 
    SH_1 0SL_1 0;
    var 
    label 0;
    var 
    text_high ""text_low "";

    function 
    main(WavePcntSwingHighSwingLowThicknessnColor)
    {
        if (
    WavePcnt == nullWavePcnt .02;
        if (
    SwingHigh == nullSwingHigh "High";
        if (
    SwingLow == nullSwingLow "Low";
        if (
    Thickness == nullThickness 2;
        if (
    nColor == nullnColor Color.RGB(0,145,0);
        if (
    nColor == "red"nColor Color.red;
        if (
    nColor == "black"nColor Color.black;
        if (
    nColor == "blue"nColor Color.blue;
        if (
    nColor == "cyan"nColor Color.cyan;
        if (
    nColor == "green"nColor Color.green;
        if (
    nColor == "magenta"nColor Color.magenta;
        
        if (
    nColor == "white"nColor Color.white;
        
        if (
    nColor == "yellow"nColor Color.yellow;
        
        if (
    nColor == "purple"nColor Color.purple;
        if (
    First)
        {
            
    First false;
            
    RP = (high(0) + low(0)) / 2;
            
    RPPoint getCurrentBarIndex();
            
    RP1 RP;
            
    RPPoint1 RPPoint;
        }
        var 
    SH 0.0;
        var 
    SL 0.0;
        
    //SwingHigh
        
    var Occur 1;
        var 
    Strength 1;
        var 
    Length 2;
        var 
    Price SwingHigh;
        var 
    vPrice getValue(Price0, -(Strength Length Occur 1));
        var 
    Price1 0.0;
        var 
    Strength;
        var 
    Found false;
        var 
    Counter 0;
        var 
    0;
        var 
    XX 0;
        var 
    YY 0;
        var 
    Truth true;
        for (
    Strength; (Length)&&(Found == false); J++)
        {
            
    Price1 vPrice[J];
            
    1;
            
    Truth true;
            for (
    = (1); ((J) <= Strength)&&(Truth); X++)
            {
                if (
    Price1 vPrice[X]) Truth false;
            }
            
    1;
            for (
    = (1); ((X) <= Strength)&&(Truth); X--)
            {
                if (
    Price1 <= vPrice[X]) Truth false;
            }
            if (
    TruthCounter++;
            if (
    Counter >= OccurFound true;
        }
        if (
    FoundSH Price1;
        else 
    SH = -1;
        
    //SwingLow
        
    Price SwingLow;
        
    vPrice getValue(Price0, -(Strength Length Occur 1));
        
    Strength;
        
    Found false;
        
    Counter 0;
        for (
    Strength; (Length)&&(Found == false);J++)
        {
            
    Price1 vPrice[J];
            
    1;
            
    Truth true;
            for (
    = (1); ((J) <= Strength)&&(Truth); X++)
            {
                if (
    Price1 vPrice[X]) Truth false;
            }
            
    1;
            for (
    = (1); ((X) <= Strength)&&(Truth); X--)
            {
                if (
    Price1 >= vPrice[X]) Truth false;
            }
            if (
    TruthCounter++;
            if (
    Counter >= OccurFound true;
        }
        if (
    FoundSL Price1;
        else 
    SL = -1;
        
    //ZigZag
        
    if (SH != -1)
        {
            if ((Switch != 
    1)&&(SH >= (RP * (1+(WavePcnt*.01)))))
            {
                
    += "X"label++;
                
    RPPoint1 RPPoint;
                
    RP1 RP;
                
    RPPoint getCurrentBarIndex() - 1;
                
    RP SH;
                
    //drawLineAbsolute(RPPoint,RP,RPPoint1,RP1, PS_SOLID, Thickness, nColor, s);
                
    if (SH_1 != SH
                    
    text_high SH_1 SH "HH" "LH";
                
    drawTextAbsoluteRPPoint,  RP+0.18text_highColor.greennullText.ONTOP Text.CENTER Text.BOLD Text.TOP"Arial"12label );
                Switch = 
    1;
            }
            else 
            if ((Switch == 
    1)&&(SH >= RP))
            {
                
    RPPoint getCurrentBarIndex() - 1;
                
    RP SH;
                
    //drawLineAbsolute(RPPoint,RP,RPPoint1,RP1, PS_SOLID, Thickness, nColor, s);
                
    if (SH_1 != SH
                    
    text_high SH_1 SH "HH" "LH";
                
    drawTextAbsoluteRPPoint,  RP+0.18text_highColor.greennullText.ONTOP Text.CENTER Text.BOLD Text.TOP"Arial"12label++ );
            }
                
    SH_1 SH;
        }  
        if (
    SL != -1)
        {
            if ((Switch != -
    1)&&(SL <= (RP - (RP*(WavePcnt*.01)))))
            {
                
    += "X"label++;
                
    RPPoint1 RPPoint;
                
    RP1 RP;
                
    RPPoint getCurrentBarIndex() - 1;
                
    RP SL;
                
    //drawLineAbsolute(RPPoint,RP,RPPoint1,RP1, PS_SOLID, Thickness, nColor, s);
                
    if (SL_1 != SL
                    
    text_low SL_1 SL "LL" "HL";
                
    drawTextAbsoluteRPPoint,  RP-0.18text_lowColor.rednullText.ONTOP Text.CENTER Text.BOLD Text.BOTTOM"Arial"12label++ );
                Switch = -
    1;
            }
            else
            if ((Switch == -
    1)&&(SL <= RP))
            {
                
    RPPoint getCurrentBarIndex() - 1;
                
    RP SL;
                
    //drawLineAbsolute(RPPoint,RP,RPPoint1,RP1, PS_SOLID, Thickness, nColor, s);
                
    if (SL_1 != SL
                    
    text_low SL_1 SL "LL" "HL";
                
    drawTextAbsoluteRPPoint,  RP-0.18text_lowColor.rednullText.ONTOP Text.CENTER Text.BOLD Text.BOTTOM"Arial"12label );
            }
                
    SL_1 SL;
        }
        return;

    Attached Files
    Last edited by atlas; 12-01-2007, 05:08 PM.

    Comment


    • #3
      Hello Atlas,

      The bars you have circled in your image simply did not meet any of the criteria that draws the labels. If you add a debug statement and print out the bar index when each condition in the formula draws a label, you will see that they match the bar index locations of the labels that appear on the chart.



      To have the extra bars you've highlighted receive a label, you need to either add another condition or modify the existing conditions.
      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


      • #4
        Hmm...It doesn't work in real-time. The HH and LL's are correct, but the labels get shifted if I reload. Each time I reload, and there is a new bar, the labels get shifted to left by one. I tried drawTextRelative and it is worse.

        Comment


        • #5
          Hello atlas,

          Doesn't look like the original code was written for real time updating. Try changing all of the drawTextAbsolute() calls to drawTextRelative() and replace the variable used for the x-coordinate from RPPoint to 0.

          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