Announcement

Collapse
No announcement yet.

Drawing Shapes

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

  • Drawing Shapes

    Hi,

    I have nearly completed my EFS, but have got a little stuck on drawing arrows. I have succesfully got the software to trigger the arrow and draw it in the right place, however, when a new bar is created, the arrow just dissappears and the whole thing starts over again. What I want is for the arrow to stay at its relative X-axis position and remain there at that bar. I have tried both Absolute and Relative but neither give me the results I am looking for, so I guess I am doing something wrong. Below is the section of code I am referring to, all help would be appreciated:


    if (getBarState () == BARSTATE_NEWBAR)
    vFlag = false;

    if (sDisplayPrice < DnDegrees){
    setBar(Bar.FgColor,-1, Color.black);}

    if (sDisplayPrice > DnDegrees && sDisplayPrice < UpDegrees){
    setBar(Bar.FgColor, -1, Color.blue);}

    if (sDisplayPrice > UpDegrees){
    setBar(Bar.FgColor,-1, Color.white);
    }

    if ( vClose > HighLinearRegValue && sDisplayPrice > DnDegrees){
    drawShapeRelative(0, vLow - (1 / Multi), Shape.UPARROW, null, Color.lime, Image.ONTOP, "up");
    if (vFlag == false) Alert.playSound("warning.wav")
    vFlag = true
    }

    if ( vClose < LowLinearRegValue && sDisplayPrice < UpDegrees){
    drawShapeRelative(0, vHigh + (1 / Multi), Shape.DOWNARROW, null, Color.red, Image.ONTOP, "dn");
    if (vFlag == false) Alert.playSound("warning.wav")
    vFlag = true
    }

    if ( vClose > LowLinearRegValue && vClose < HighLinearRegValue){
    removeShape("up")
    removeShape("dn")}

  • #2
    rogerha
    A guess would be that on a new bar the last condition returns true and therefore removes the Shape
    Alex

    Comment


    • #3
      Thats was quick

      The last condition is used because I run the script on a tic-by-tic basis in realtime, so if the condition changes the arrow is removed.

      However in testing it appears to me that the bar closes correctly and the arrow is printed, but rather than move to the left with that bar when a new bar begins printing it simply dissappears.

      I have attached the EFS to see if you can help further.

      Thanks for the prompt response incidentally.
      Attached Files

      Comment


      • #4
        rogerha
        It disappears because on the very first tick of a new bar the Close is higher than LowLinearRegValue and lower than HighLinearRegValue hence that condition returns true and removes any Shape that has a Tag Name of "up" or "dn".
        If you wish to maintain the historical arrows plotted you need to give them a unique Tag Name. This could be done with a bar counter for example that increases its value by 1 at every new bar.
        Alex

        Comment


        • #5
          Perfect, added counter, problem fixed.

          Thank you for a very prompt and thorough service.

          Comment

          Working...
          X