Announcement

Collapse
No announcement yet.

setColorPriceBars()??

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

  • setColorPriceBars()??

    I have an EFS that I wrote for a client that includes a user input (true/false) for coloring price bars....

    When the user uses the EDIT STUDIES (from the right-click menu), it appears to work (sometimes). When the user uses the EDIT button, I get a chart (like below) when the switch is off.

    The odd part is, if I resize the chart, it draws the chart normally - but then the color switch does not work again. I think this is a bug - has anyone else experienced this?? I'm including some code to try too..
    Attached Files
    Brad Matheny
    eSignal Solution Provider since 2000

  • #2
    Here is the code..

    this is the example code (unprotected).

    B
    Attached Files
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      efs is protected

      Comment


      • #4
        Hello Brad,

        There is a bug related to the BOOLEAN type of the FunctionParameter class. Are you using the boolean type by chance? If so, I would use a string type instead and use "T" and "F" strings. The problem with the boolean type is that the result gets passed to main as a string and not a true boolean variable.
        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


        • #5
          oops....

          Here is the unprotected code...

          You'll notice that I'm handling the string issue for the boolean variable..

          PHP Code:
          /*---------------------------------------------------------------------------------------------------
          Developed by Matheny Enterprises ([url]www.ment.com[/url])
          ----------------------------------------------------------------------------------------------------*/

          var cPrePTPColor;
          var 
          cBullPTPColor;
          var 
          cBearPTPColor;
          var 
          cDefTextColor;
          var 
          cDefTextBGColor;

          function 
          preMain() {
              var 
          i;
              var 
          nLastRawTime 0;
              var 
          BLBarOffset 0;
                  
              var 
          fp1 = new FunctionParameter("ColorBars"FunctionParameter.BOOLEAN);
                  
          fp1.setDefault(true);

              var 
          fp2 = new FunctionParameter("DefBarColor"FunctionParameter.STRING);
                  
          fp2.addOption("white");
                  
          fp2.addOption("black");
                  
          fp2.addOption("darkgrey");
                  
          fp2.addOption("grey");
                  
          fp2.addOption("lightgrey");
                  
          fp2.addOption("navy");
                  
          fp2.addOption("blue");
                  
          fp2.addOption("aqua");
                  
          fp2.addOption("cyan");
                  
          fp2.addOption("teal");
                  
          fp2.addOption("darkgreen");
                  
          fp2.addOption("green");
                  
          fp2.addOption("lime");
                  
          fp2.addOption("olive");
                  
          fp2.addOption("khaki");
                  
          fp2.addOption("brown");
                  
          fp2.addOption("purple");
                  
          fp2.addOption("red");
                  
          fp2.addOption("magenta");
                  
          fp2.addOption("maroon");
                  
          fp2.addOption("yellow");
                  
          fp2.addOption("lightyellow");
                  
          fp2.addOption("paleyellow");
                  
          fp2.setDefault("black"); //Edit this value to set a new default
                  
              
          setStudyTitle("Color Tester");
              
          setShowTitleParameters(false);
              
          setShowCursorLabel(false);
              
          setPriceStudy(true);
          }


          function 
          main(ColorBarsDefBarColor) {

            
          drawTextPixel(4,33" Edit "+"@URL=EFS:Editbutton" Color.blackColor.RGB(0xE00xE00xE0), Text.FRAME Text.ONTOP Text.RELATIVETOLEFT Text.RELATIVETOBOTTOMnullnull"ARTPTP");

          cBullPTPColor Color.green;
          cBearPTPColor Color.red;

          if (
          ColorBars == "false") { ColorBars false; }
          if (
          ColorBars == "true") { ColorBars true; }

          //debugPrintln(PTPColorBars);
          if (ColorBars) {
            
          setColorPriceBars(true);
            
          setDefaultPriceBarColor(eval("Color." DefBarColor) );
          } else {
            
          setColorPriceBars(false);
          }

             if (
          ColorBars) {
              
          setColorPriceBars(true);
               if (
          close()>open()) {
                 
          setPriceBarColor(cBullPTPColor);
               }
               if (
          close()<open()) {
                 
          setPriceBarColor(cBearPTPColor);
               }
             } else {
              
          setColorPriceBars(false);
             }
              
              return;
          }


          function 
          Editbutton()
          {
           
          askForInput("Edit Color Settings");

          Brad Matheny
          eSignal Solution Provider since 2000

          Comment


          • #6
            Brad
            If you add a setDefaultPriceBarColor(Color.black) in preMain() it seems to work fine
            Alex

            Comment


            • #7
              Thanks Alex...

              I was trying to avoid forcing a bar color when ColorBar is false. I wanted it to use the default esignal color scheme. I guess there is no way around the problem - huh??

              B
              Brad Matheny
              eSignal Solution Provider since 2000

              Comment


              • #8
                Hello Brad,

                Yes, once you start with setColorPriceBars(true), you can't turn back to the advanced chart's default color scheme. You would have to do the default coloring within your code.

                PHP Code:
                var cPrePTPColor;
                var 
                cBullPTPColor;
                var 
                cBearPTPColor;
                var 
                cDefTextColor;
                var 
                cDefTextBGColor;

                function 
                preMain() {
                    var 
                i;
                    var 
                nLastRawTime 0;
                    var 
                BLBarOffset 0;
                        
                    var 
                fp1 = new FunctionParameter("ColorBars"FunctionParameter.BOOLEAN);
                        
                fp1.setDefault(true);

                    var 
                fp2 = new FunctionParameter("DefBarColor"FunctionParameter.STRING);
                        
                fp2.addOption("white");
                        
                fp2.addOption("black");
                        
                fp2.addOption("darkgrey");
                        
                fp2.addOption("grey");
                        
                fp2.addOption("lightgrey");
                        
                fp2.addOption("navy");
                        
                fp2.addOption("blue");
                        
                fp2.addOption("aqua");
                        
                fp2.addOption("cyan");
                        
                fp2.addOption("teal");
                        
                fp2.addOption("darkgreen");
                        
                fp2.addOption("green");
                        
                fp2.addOption("lime");
                        
                fp2.addOption("olive");
                        
                fp2.addOption("khaki");
                        
                fp2.addOption("brown");
                        
                fp2.addOption("purple");
                        
                fp2.addOption("red");
                        
                fp2.addOption("magenta");
                        
                fp2.addOption("maroon");
                        
                fp2.addOption("yellow");
                        
                fp2.addOption("lightyellow");
                        
                fp2.addOption("paleyellow");
                        
                fp2.setDefault("black"); //Edit this value to set a new default
                        
                    
                setStudyTitle("Color Tester");
                    
                setShowTitleParameters(false);
                    
                setShowCursorLabel(false);
                    
                setPriceStudy(true);
                }


                function 
                main(ColorBarsDefBarColor) {

                  
                drawTextPixel(4,33" Edit "+"@URL=EFS:Editbutton" Color.blackColor.RGB(0xE00xE00xE0), Text.FRAME Text.ONTOP Text.RELATIVETOLEFT Text.RELATIVETOBOTTOMnullnull"ARTPTP");

                cBullPTPColor Color.green;
                cBearPTPColor Color.red;

                if (
                ColorBars == "false") { ColorBars false; }
                if (
                ColorBars == "true") { ColorBars true; }


                   if (
                ColorBars) {
                     if (
                close()>open()) {
                       
                setPriceBarColor(cBullPTPColor);
                     } else if (
                close()<open()) {
                       
                setPriceBarColor(cBearPTPColor);
                     } else {
                       
                setPriceBarColor(eval("Color." DefBarColor) );
                     }
                   } else {
                     if (
                close()>open()) {
                       
                setPriceBarColor(cBullPTPColorColor.black);
                     } else if (
                close()<open()) {
                       
                setPriceBarColor(cBearPTPColorColor.black);
                     } else {
                       
                setPriceBarColor(eval("Color." DefBarColor), Color.black);
                     }
                   }
                    
                    return;
                }


                function 
                Editbutton()
                {
                 
                askForInput("Edit Color Settings");

                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


                • #9
                  Thanks everyone..

                  You have completely answered my questions...

                  B
                  Brad Matheny
                  eSignal Solution Provider since 2000

                  Comment

                  Working...
                  X