Announcement

Collapse
No announcement yet.

DrawShape

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

  • DrawShape

    I have written an EFS code to recognize specific CandleStick patterns. When I add the EFS to my chart it only shows me the last instance of that pattern. I thought it would mark it for all and every time that pattern occures. If I do a tick replay it will happen however it moves my arrow as new instances of that pattern appear. Is this what I am suppose to get or am I doing something wrong. I would appriciate your advice in this matter.

    Thank you

    Behzad G.

    Here is my code:


    function CandleHammer2(PercentageOfBodytoHighLow,Percentage AboveTheLow)
    {


    var vOpen=open(-1);
    var vHigh=high(-1);
    var vLow=low(-1);
    var vClose=close(-1);
    var vHL;
    var vOC;

    var vPercentageOfBodytoHighLow= .25; //PercentageOfBodytoHighLow;
    var vPercentageAboveTheLow= .75 ; //PercentageAboveTheLow;



    vOC=vOpen-vClose;
    vHL=vHigh-vLow;



    if (Math.abs( vOC) < (vPercentageOfBodytoHighLow*vHL)) /* Diff of Open and close is less than */
    {

    if (vOpen > ((vPercentageAboveTheLow * vHL) + vLow))
    {

    drawShapeRelative(0, low(0) -1, Shape.UPARROW, null, Color.RGB(0,255,0), Shape.BOTTOM, "T4") ;

    }


    }



    }
    Tony Gof

  • #2
    Behzad
    You are only getting one shape drawn (specifically the last one) because you are using only one tagID ie "T4" for all the shapes being drawn.
    You need to use a tagID that will be unique to each shape. Replace this line
    PHP Code:
    drawShapeRelative(0low(0) -1Shape.UPARROWnullColor.RGB(0,255,0), Shape.BOTTOM"T4"); 
    with the following
    PHP Code:
    drawShapeRelative(0low(0) -1Shape.UPARROWnullColor.RGB(0,255,0), Shape.BOTTOM"T4"+rawtime(0)) ; 
    Once you implement this change you should be seeing a shape drawn for each event
    Alex

    Comment


    • #3
      THank you that worked.

      Behzad G.
      Tony Gof

      Comment


      • #4
        Would you also tell me how I can make my indicator to Flash, meaning as the condition is met it will place an arrow and then as the condition changes it would remove the indicator. This is when setComputeOnClose(false) is false.

        Thank you

        Behzad G.
        Tony Gof

        Comment


        • #5
          Behzad
          First of all you need to be aware that setComputeOnClose() does not accept any parameters so even if you use setComputeOnClose(false) it is still enabled.
          As to your question see the example enclosed below.
          Alex

          PHP Code:
          if(myCondition){
              
          drawShapeXxx(...,..., "tagID"+rawtime(0));
          }else{
              
          removeShape("tagID"+rawtime(0));

          Comment

          Working...
          X