Announcement

Collapse
No announcement yet.

Flashing the "drawTextRelative

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

  • Flashing the "drawTextRelative

    Hi, is it possible to flash the red backround , if "mybgColor" is red?
    Thanks



    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<=700) myColor = Color.black;
    if (myValue<=700) mybgColor = Color.red;
    if (myValue>700 && myValue <= 1800) myColor = Color.black;
    if (myValue>700 && myValue <= 1800) mybgColor = Color.lime;
    if (myValue>1800) myColor = myColor = Color.white;
    if (myValue>1800) mybgColor = Color.navy;
    drawTextRelative( 0, AboveBar1, myValue , myColor, mybgColor, Text.PRESET | Text.BOLD, null, 24, "text" );
    return;

  • #2
    Hello Bügeleisen,

    We don't have a built-in flash or blink option for drawn objects, but you can create a simulated flash process by allowing the conditions to be evaluated on every other trade with the use of a global flag (see bFlash variable below). Also, your color variables will need to be declared globally (i.e. outside of main) in order for this to work. On the trade updates that are prevented from evaluating the conditions based on the value of bFlash, set the background color for the text object back to white (or desired default color). This will create the appearance of flashing as trades occur. Be aware that if the chart symbol is not trading, you will not see any "flashing" because main() will not be executing. A similar situation will occur for symbols that may be trading infrequently as the color can only be changed on every other trade update.

    PHP Code:
    var bFlash true;
    var 
    myColor Color.white;
    var 
    mybgColor Color.green;

    function 
    main() {
        var 
    myValue = ((1/atr(100)).toFixed(2))*100;
        
    mybgColor Color.white;
        
        if (
    bFlash == false) {
            if (
    myValue<=700) {
                
    //myColor = Color.black;
                
    mybgColor Color.red;
            } else if (
    myValue>700 && myValue <= 1800) {
                
    //myColor = Color.black;
                
    mybgColor Color.lime;
            } else if (
    myValue>1800) {
                
    //myColor = Color.white;
                
    mybgColor Color.navy;
            }
            
    bFlash true;
        } else if (
    bFlash == true) {
            
    bFlash false;
        }
        
        
        
    drawTextRelative0AboveBar1myValue Color.blackmybgColorText.PRESET Text.BOLDnull24"text" );
        
        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


    • #3
      Thanks,
      i have tried your efs. Looks good but: The flashing.efs is drawn in a new window under the chart-window. Before "myvalue" has been drawn at the right side of the chartwindow.
      How to change this?
      Thanks



      Originally posted by JasonK
      Hello Bügeleisen,

      We don't have a built-in flash or blink option for drawn objects, but you can create a simulated flash process by allowing the conditions to be evaluated on every other trade with the use of a global flag (see bFlash variable below). Also, your color variables will need to be declared globally (i.e. outside of main) in order for this to work. On the trade updates that are prevented from evaluating the conditions based on the value of bFlash, set the background color for the text object back to white (or desired default color). This will create the appearance of flashing as trades occur. Be aware that if the chart symbol is not trading, you will not see any "flashing" because main() will not be executing. A similar situation will occur for symbols that may be trading infrequently as the color can only be changed on every other trade update.

      PHP Code:
      var bFlash true;
      var 
      myColor Color.white;
      var 
      mybgColor Color.green;

      function 
      main() {
          var 
      myValue = ((1/atr(100)).toFixed(2))*100;
          
      mybgColor Color.white;
          
          if (
      bFlash == false) {
              if (
      myValue<=700) {
                  
      //myColor = Color.black;
                  
      mybgColor Color.red;
              } else if (
      myValue>700 && myValue <= 1800) {
                  
      //myColor = Color.black;
                  
      mybgColor Color.lime;
              } else if (
      myValue>1800) {
                  
      //myColor = Color.white;
                  
      mybgColor Color.navy;
              }
              
      bFlash true;
          } else if (
      bFlash == true) {
              
      bFlash false;
          }
          
          
          
      drawTextRelative0AboveBar1myValue Color.blackmybgColorText.PRESET Text.BOLDnull24"text" );
          
          return;

      Comment


      • #4
        Hello Bügeleisen,

        You just need to add your preMain() code from your original formula, which contains setPriceStudy(true).
        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

        Working...
        X