Announcement

Collapse
No announcement yet.

Atr

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

  • #16
    Hello Bügeleisen,

    Compare your current parameters to those described in the EFS KB for drawTextRelative(). The 10th parameter is the optional cx parameter, which is expecting a number. Currently your intended tagID string of "text" is being passed as the 10th parameter. The first null parameter that is being passed is the problem, which is what buhrmaster was referring to. Remove the first instance of , null and it should work.
    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


    • #17
      Thanks.
      i have deleted the first null and i have got "no syntax error" message in the formular output. Nice.
      But in the chart, there is the sign on the top left "ATR, 'Formula Error*. I have never seen such a message. And there`s no result printed of the "ATR"-Code.


      function preMain() {

      setPriceStudy(true);
      setStudyTitle("ATR");



      }

      function main() {
      var myValue = ((1/atr(10)).toFixed(2))*100;
      var myColor = Color.white;
      var mybgColor = Color.green;
      if (myValue<=7) myColor = Color.aqua;
      if (myValue<=7) mybgColor = bgColor.yellow;
      if (myValue>7 && myValue <= 18) myColor = Color.olive;
      if (myValue>7 && myValue <= 18) mybgColor = bgColor.green;
      if (myValue>18) myColor = myColor = Color.navy;
      if (myValue>18) mybgColor = bgColor.white;
      drawTextRelative( 0, AboveBar1, myValue , myColor, mybgColor, Text.PRESET | Text.BOLD, null, 14, "text" );
      return;
      }

      Comment


      • #18
        I may be wrong but I don't recall there being a "bgColor" object. Why not use the Color object when you do all the color assignments.

        Comment


        • #19
          I want to draw the result of the ATR like the quote on the right side: Different color of the backround of the ATR-field and different color of the numer of the field.

          Comment


          • #20
            Example:
            The EMA-study draws the result at the right side of the chart(plus the line). Which line of the code draws this result at the right?

            thanks

            function preMain() {

            setPriceStudy(true);
            setStudyTitle("EMA");
            setCursorLabelName("EMA",0);
            setDefaultBarFgColor(Color.blue,0);
            setPlotType(PLOTTYPE_LINE,0);
            setDefaultBarThickness(1,0);
            }

            function main() {

            return ema(10);
            }

            Comment


            • #21
              Bugeleisen

              The EMA-study draws the result at the right side of the chart(plus the line). Which line of the code draws this result at the right?
              None of them. The label in the Y-axis is returned by the formula engine.

              I want to draw the result of the ATR like the quote on the right side:
              The Y-axis label will only display if you are plotting the value of a study on the chart. Because in your case you are not plotting the value but only writing it the Y-axis label will not be displayed.

              Different color of the backround of the ATR-field and different color of the numer of the field.
              You can replicate that by using the appropriate parameters in the drawTextRelative() command (for the complete syntax of the command see the link that Jason provided in an earlier reply)
              As buhrmaster already indicated to you the syntax you are using to set the background color is incorrect ie.
              PHP Code:
              mybgColor bgColor.xxxx;//bgColor is not valid syntax 
              should be
              PHP Code:
              mybgColor Color.xxxx
              Also to simplify your code [and make it slightly more efficient] you should group together the commands that are executed by the same conditional statement (see example enclosed below)
              Alex

              PHP Code:
              if (myValue<=7) {
                  
              myColor Color.aqua;
                  
              mybgColor Color.teal;

              Comment

              Working...
              X