Announcement

Collapse
No announcement yet.

Dual setChartBgColor will conflict?

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

  • Dual setChartBgColor will conflict?

    I was using an efs to change background (Bg) color when stochastics was crossing up thru 20 or down thru 80.

    I then added the Near High Low efs to the same chart to change Bg color when new highs or lows were occuring.

    These efs's work well separately, but when loaded in the same chart, the stochastics efs does not change Bg color anymore. When the Bg change conditions are not occuring, each efs defaults to the same default Bg color, so they are not fighting each other during non-triggering times. I assumed (wrongly, it seems?) that whichever triggering event occurred first would control the Bg color.

    Should I be able to make these work together as two separate efs's, or will I have to merge them into one, and include logic to define which one controls?

    Thanks
    shaeffer

  • #2
    shaeffer

    Dual setChartBgColor will conflict?

    Which command are you referring to? setChartBG() or setBarBgColor()?
    FWIW there is no setChartBgColor() command.
    Alex

    Comment


    • #3
      Hi Alex,

      Sorry, its the chart background, setChartBG(), not the bar background color I'm trying to change.

      Thanks
      shaeffer

      Comment


      • #4
        shaeffer

        I assumed (wrongly, it seems?) that whichever triggering event occurred first would control the Bg color

        That depends on how you have set your if statements. If they are set as follows
        if (condition1==true) doX;
        if (condition2==true) doY;
        if (condition3==true) doZ;
        etc

        then when there are two (or more) conditions that return true (as seems to be your case) the last one prevails. What you need to do is set them in series ie
        if(condition1==true) doX;
        else if(condition2==true) doY;
        else if(condition3==true) doZ;
        else doA;

        This way the efs evaluates a condition and passes on to the next condition only if the current one returns false. In this case you need to make sure that the most common conditions are the last ones to be evaluated else they will prevent the other conditions from being verified.
        Alex

        Comment


        • #5
          Hi Alex,

          In the following case:
          if (condition1==true) doX;
          if (condition2==true) doY;
          if (condition3==false) doZ;
          would the efs doX, and then doY, but not doZ (i.e. do all true statements)?

          And in this case:
          if(condition1==true) doX;
          else if(condition2==true) doY;
          else if(condition3==false) doZ;
          else doA;
          would the efs doX only and stop there (i.e. go as far as the first true statement, then do that and stop?

          And lastly, in the case:
          if(condition1==false) doX;
          else if(condition2==true) doY;
          else if(condition3==true) doZ;
          else doA;
          would the efs doY only and stop there?

          If the above is correct, then I think I understand how these statements work.

          Thanks
          shaeffer

          Comment


          • #6
            shaeffer
            In the first example the efs will execute both doX and doY.
            In the second example the efs will execute doX and stop evaluating further conditions
            In the third example it will execute doY and stop evaluating further conditions.
            So, your understanding is correct.
            Hope this helps
            Alex

            Comment

            Working...
            X