Announcement

Collapse
No announcement yet.

drawShapeRelative does not draw a shape.

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

  • drawShapeRelative does not draw a shape.

    I have modified simple BtMovingAverage.efs to draw Up arrow whenever it enters a long position and a down arrow for short.
    I have also added debug statements, that indicate that shapes should have been drawn.
    However, the shapes don't appear on the chart.

    Thank you for your help!

    Vadim.
    Attached Files

  • #2
    Hi chapkva,

    In your drawShapeRelative line:

    drawShapeRelative(0, low(), Shape.UPARROW, null, Color.green, Image.ONTOP, "Buy");

    I believe the correct format for the Shape flag should be Shape.ONTOP.

    Comment


    • #3
      Hi chapkva,

      Also, change the colors of the arrows, they are the same as the background colors.

      Comment


      • #4
        Steve,

        Thanks for the suggestions. Unfortunately the shapes still don't show on the chart.


        Vadim.

        Comment


        • #5
          chapkva,

          Here is a screenshot from my computer where I colored the arrows black. Look at the yellow arrows I placed on the chart and where they point. In each case, the black arrow is at the low or the high of the bar, almost invisible.



          Perhaps that is why you are not seeing them. Please try adding a constant to the upper yValue and subtracting a constant from the lower yValue.

          Also note that you will only have one arrow at any time indicating a buy or a sell. That is because each time you write another shape, it has the same tagID, as a result, the previous one is overwritten.

          Alternatively, if you have version 7.9 or later installed, try this new efs2 command which greatly simplifies this task:

          drawShape( shape, location [, fgColor] )

          here it is inserted into your code:

          PHP Code:
          if(close() >= v) {
                  if(!
          Strategy.isLong()) {
                      
          Strategy.doLong("Crossing Up"Strategy.CLOSEStrategy.THISBAR);
                      
          //drawShapeRelative(0, low(), Shape.UPARROW, null, Color.black, Shape.ONTOP, "Buy");
                      
          drawShapeShape.UPARROW BelowBar1,Color.yellow  
                      
          debugPrintln("UP");
                  }

              } else {
                  if(!
          Strategy.isShort()) {
                      
          Strategy.doShort("Crossing Down"Strategy.CLOSEStrategy.THISBAR);
                      
          drawShapeShape.DOWNARROW AboveBar1Color.yellow  
                      
          //drawShapeRelative(0, high(), Shape.DOWNARROW, null, Color.black, Shape.ONTOP, "Sell");
                      
          debugPrintln("DOWN");
                  }
              } 
          If you try this, you will notice that every arrow that was drawn stays on the chart. One other thing and that is that the color is an optional field, further simplifying things. There is a similar command for drawing text as well:

          drawText( text, location [, fgColor] [, flags])


          For the syntax of the all EFS2 functions, builtin studies, etc see the EFS2 Function Reference in the EFS KnowledgeBase


          I hope this helps.

          Comment


          • #6
            Steve, thank you for your help.
            This was my dumb mistake. When I ran a "backtest" nothing showed up on the char but I've got the results in the Strategy Analyzer. I've had to open this formula as a study to see the UP and DOWN arrows appear.
            However, I see only one Up arrow and one Down arrow. Strategy Analyzer indicates that there were quite a number of trades. Any idea?


            Thanks again!

            Vadim.

            Comment


            • #7
              Hi chapkva,

              Sounds like you are trying to double up, if you catch my drift. ;>)

              I answered your question in my last post... and provided a solution as well.

              Best Regards,

              Comment

              Working...
              X