Announcement

Collapse
No announcement yet.

draw a shape once

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • draw a shape once

    I know this is a stupid question but here goes. I want to draw a shape on a chart when a condition happens. High(0) > SwingHigh.

    However I only want the shape to print once or twice. So I have added a counter, c, to control it.

    if (High(0) > SwingHigh && counter < 7) draw

    I then reset the counter when the initial condition is not true

    if (High(0) < SwingHigh)
    counter = 0;

    but for some reason I cant get it to draw anything when I put my counter in. I think it has to do with declaring var c in the main section.

    here is the full code. Thanks

    PHP Code:
    function preMain() {
     
        
    setPriceStudy(true);
        
    setStudyTitle("BreakSwings");
        
    setShowTitleParameters(false
        
    setComputeOnClose()    
      
    setShowSeries(true0);
      
    setShowSeries(true1);
        var 
    c=0;


    }

    function 
    main() 
    {  
    //m opening bracket
        
    var c;
        var 
    vSwings5 efsExternal("Swings.efs"2inv(5) );
        var 
    vSwingHigh5 getSeries(vSwings5,0);
        var 
    vSwingLow5 getSeries(vSwings5,1);
        
        var 
    vSwings30 efsExternal("Swings.efs"2inv(30) );
        var 
    vSwingHigh30 getSeries(vSwings30,0);
        var 
    vSwingLow30 getSeries(vSwings30,1);   
        
        var 
    lastswinghigh;
        if( (
    high(0) > vSwingHigh5)   ) 
           if (
    3)
    {    
    drawShape(Shape.UPARROWAboveBar1Color.RGB(0,0,255));
    1;
    }    

        if (
    high(0) < vSwingHigh5)
        
    0;  // reset counter
        
        
    return new Array (vSwingHigh5vSwingLow5);
      } 
    Last edited by eurostoxx; 12-27-2010, 07:38 PM.

  • #2
    i figured it out.. you can delete this post if you want

    Comment

    Working...
    X