Announcement

Collapse
No announcement yet.

Problem with BarColor after Restart eSignal

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

  • Problem with BarColor after Restart eSignal

    Hi,

    I have a BarColor-problem, after I restart eSignal. If I insert the indicator in a new chart, all ok, but if I restart eSignal with the saved chart, the Bars "Receiving", but the Bars are not colored correctly. If I reload the indicator, nothing happens.

    PB.efs
    PHP Code:
    function preMain()
    {
        
    setPriceStudy(true);
        
    setStudyTitle("PB");    
    }

    function 
    main()
    {
        var 
    PB;
        
        if (
    cci(20) >= 100PB 1;
        else if ((
    cci(20) < 100) && (cci(20) > -100)) PB 0;
        else 
    PB = -1;
        
        
    //...

        
    return PB;    


    PB_load.efs
    PHP Code:
    function preMain()
    {
        
    setPriceStudy(true);
        
    setStudyTitle("PB_load");    
    }

    var 
    bInit false;
    function 
    main()
    {
        if (
    bInit == false)
        {
            
    PB efs("PB.efs");        
            
            
    bInit true;
        }
        
        if (
    PB.getValue(0) == 1setPriceBarColor(Color.blue);
        else if (
    PB.getValue(0) == 0setPriceBarColor(Color.yellow);
        else 
    setPriceBarColor(Color.red);
        
        return;

    Attached Files
    Last edited by Roman76; 02-01-2006, 12:30 AM.

  • #2
    Roman76
    When using setPriceBarColor() you need to include the setColorPriceBars() and setDefaultPriceBarColor() statements in preMain(). See the corresponding links for the required syntax
    Alex

    Comment


    • #3
      Hi Alex,

      with setColorPriceBars(true) in preMain it works great!

      I am only surprised, why it works without the setColorPriceBars-setting, if I inserted the indicator new and after restart eSignal not.

      Comment


      • #4
        Hi,

        I have also trouble with the setColorPriceBars. With:

        PHP Code:
        function preMain()
        {
            
        setPriceStudy(true);
            
        setColorPriceBars(true);

            
        fp1 = new FunctionParameter("PB"FunctionParameter.STRING);
            
        with(fp1)
            {
                
        fp1.addOption("T");
                
        fp1.addOption("F");        
                
        setDefault("T");
            }

        }

        function 
        main(PB)
        {
            if (
        PB == "T")
            {
                
        setColorPriceBars(true);
                if (
        close(0) > close(-1)) {setPriceBarColor(Color.blue);}
                else {
        setPriceBarColor(Color.red);}
            }
            else {
        setColorPriceBars(false);}
            

        I get only white candles, if I have PB = F after restart. I know the setDefaultPriceBarColor(), but I dont know the color of each customers for the paintbar...


        Edit: If I use in the else-section (setColorPriceBars(false):

        PHP Code:
                if (close(0) >= open(0)) setPriceBarColor(Color.green,0);
        if (
        close(0) < open(0)) setPriceBarColor(Color.red,0); 
        the color ist not ever correctly realtime like in the original-chart!
        Last edited by franzmey; 05-18-2006, 01:59 AM.
        Franz

        Comment


        • #5
          Franz
          As indicated in the Help files if you use setColorPriceBars(true) you also need to define a default color for the price bars using setDefaultPriceBarColor(Color.xxx)
          In your case what you can do is the following. First declare a global variable called for example bInit and set it initially to false. Then at the beginning of main add the following section of code
          PHP Code:
          if(bInit==false){
                  
          setDefaultPriceBarColor(Color.cyan);
                  
          bInit=true;

          In that section you can replace the color with a user selected color parameter that you will define in preMain with a FunctionParameter.
          Then you can write your section of code as shown below (this includes also the second code sample you added in your message)
          Alex

          PHP Code:
          if (PB == "T"){
                  if (
          close(0) > close(-1)) {
                      
          setPriceBarColor(Color.blue);
                  }
                  else if (
          close(0) < close(-1)) {
                      
          setPriceBarColor(Color.red);
                  }
              } else {
                  if (
          close(0) > open(0)) {
                      
          setPriceBarColor(Color.green,0);
                  }
                  else if (
          close(0) < open(0)) {
                      
          setPriceBarColor(Color.red,0);
                  }

          Comment


          • #6
            is the problem maybe because of the activated "Make all formulas compute on close (rather than tick-by-tick)" under Formula Engine Settings?
            Attached Files
            Franz

            Comment


            • #7
              Franz
              When that setting is enabled the color of the current bar is carried forward from the last bar that has been computed which is bar index -1
              Alex

              Comment

              Working...
              X