Announcement

Collapse
No announcement yet.

Drawing text ... need help

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

  • Drawing text ... need help

    Hi everybody... long time i didnt post anything but here i am
    with a new question...
    i want to add a new feature to my formulas... this should display text... "Enter" and "Exit" ... maybe how many points there were between...

    i want to display this at the enteringpoint (green -> red ; red -> green[Trendchange]) and also at the exitpoint...
    i also want it to be displayed 10 points over the close...
    but i dont get it working... i tried it with the onlinemanual but this doesnt work...

    maybe you can help or post some scripts where i can learn from.

    Thank you!

    cheers erilein

  • #2
    you'll need to do the following..

    Within your code, you'll need to track the entry price and exit price of the trading system you are using.

    Then, you'll need to include the TEXT functions in the same area as your code issues the BUY/SELL signals (and possibly the EXIT signals - if the EXITS are separate from the reversal signals).

    Now, within your entry/exit/reversal code, you need to include the following (type) of code.

    drawTextRelative(0,high()+10.0,"your text here", Color.blue, Color.cyan, Text.ONTOP | Text.CENTER, "Courier", 10,getValue("rawtime") + "text1" );

    You will need to include values into your text - like this...

    var vtext1 = "my text "+close();
    drawTextRelative(0,high()+10.0,vtext1 , Color.blue, Color.cyan, Text.ONTOP | Text.CENTER, "Courier", 10,getValue("rawtime") + "text1" );

    Hope this helps...

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      i will test this ... and after that i will give you a reply...

      thanks for help...

      regards erilein

      Comment


      • #4
        this works realy nice but there is a little problem... my candlesticks are over the text... and so sometimes i cant read it ... is there a way to get the text in the foreground ?

        and another question: is it possible to display only 2 decimals...
        sometimes its 4700,0000000000 or so... i want it like this 4700,00

        thank you
        regards erilein

        Comment


        • #5
          Hello erilein,

          You can't draw text over the price bars. I would recommend placing your text at the high or low of the bar plus a fixed increment for spacing.

          Use .toFixed(nNumber) to control the number of decimals in a number. Keep in mind that this method converts the number to a string, so if you are returning this result to your chart, you'll need to convert the result back to a number. A quick way to do that is to just multiply it by 1.

          Example:
          PHP Code:

          var vVar 47000.123456789
          vVar 
          vVar.toFixed(2) * 1;

          // vVar will be 47000.12 
          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


          • #6
            JasonK

            you wrote -
            You can't draw text over the price bars. I would recommend placing your text at the high or low of the bar plus a fixed increment for spacing

            I have a similar problem. My strategy is in the mkt 100% of the time so often in a chop ill get signal over signal and each covers candles - worse is if the signal is right it will cover the next candle. Is there a way to have 2 rows on the bottom of the chart, one for buys and one for sells, with the buys above the sells by the width of the box? right now they are posted similar to the ones listed in formula/alert/alertbutton.efs except the signal prices are in with the candles. they dont have to be near the candle - can be way above or below - cause the chart changes colors - grey or green background when a signal is issued from where it is issued

            here is how it is coded now -
            drawTextRelative(0, low(), "B "+pricestr, Color.white,
            Color.green, Text.FRAME | Text.BOLD | Text.ONTOP, null, null, textIndex++);

            if i make the 1st # in the code, which is a 0 now, to a 20, they no longer cover but they are not lined up anywhere near the candle they are called on.

            thanks a ton

            super

            Comment


            • #7
              Hello super,

              Use the Text.RELATIVETOBOTTOM flag. When this flag is used, the second parameter of drawText... becomes the number of pixels from the bottom of the chart. For your bottom row, use a number like 5 and use something like 25 for the top row. Leave the 0 in the first parameter. That tells it to draw on the current bar. 20 will draw the text 20 bars into the future.

              Also, I would recommend changing the logic you're using for the tag name (i.e. textIndex++). In streaming mode this could be drawing multiple text labels on top of each other. This can become a bit of a performance problem after some time goes by. I've modified your code example below to incorporate a more efficient method for the tag name usage. If you want the chart to display more historical labels, increase the value for textBars. This method essentially redraws the label on each bar if the drawText... function gets called multiple times during the interval.


              PHP Code:

              var textBars 200;
              var 
              textIndex 0;

              function 
              main() {
                  if (
              getBarState() == BARSTATE_NEWBAR) {
                      
              textIndex++;
                      if (
              textIndex textBarstextIndex 0;
                  }
                  
                  
              // your formula code here

                  
              drawTextRelative(05"S "+pricestrColor.whiteColor.green
                      
              Text.FRAME Text.BOLD Text.ONTOP Text.RELATIVETOBOTTOM Text.RIGHT
                      
              nullnull"sells"+textIndex); 
                  
              drawTextRelative(025"B "+pricestrColor.whiteColor.green
                      
              Text.FRAME Text.BOLD Text.ONTOP Text.RELATIVETOBOTTOM Text.RIGHT
                      
              nullnull"buys"+textIndex); 

                  return;

              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


              • #8
                So you alerts are not on the bars:

                drawTextRelative(0, low()-.03, "B", Color.RGB(255,255,0), Color.RGB(0,0,255), Text.BOLD|Text.CENTER, "Arial", 8);

                drawTextRelative(0, high()+.03, "S", Color.RGB(255,255,0), Color.RGB(0,0,255), Text.BOLD|Text.CENTER, "Arial", 8);

                See the -.03 after low() or the + .03 after high()

                That will offset the letter B 3 cents above or below the candle.

                In this case the B or buy signal would show up below the candle and the S or Sell would show up above the candle.

                hope this helps.

                B

                Comment


                • #9
                  Thanks for the help - over the weekend I will try both - really appreciate it.

                  Comment

                  Working...
                  X