Announcement

Collapse
No announcement yet.

Help with setPriceBarColor EFS

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

  • Help with setPriceBarColor EFS

    I'm writing the below EFS that basically colors the price bar grey when the chop indicator is above 61.8.

    My 1st EFS and got far enough with the below code but the problem i'm having is that i'm not able to find a way to leave the price bars color as is when the chop indicator is not above 61.80. See my comment in the code that says " //Leave regular price bar color. How can i do that?" Can some one give me hand please?


    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Test");

    //activate the price bar coloring feature
    setColorPriceBars(true);

    }

    function main() {

    var nChopValue = chop(14, 0); // Current Bar Index
    if ( nChopValue > 61.8 ) {
    setPriceBarColor( Color.green );
    }
    else {
    //Leave regular price bar color. How can i do that?
    }

    return;
    }

  • #2
    Re: Help with setPriceBarColor EFS

    maher_a_79
    Once you color any price bar using efs the efs engine overrides the chart's price bar coloring.
    If you do not specify a color for each bar this will be painted in the color defined either by a setDefaultPriceBarColor() statement if this is used or by the efs engine's default.
    Assuming that by “regular price color” you mean the colors used for the Up/Down bars then to replicate those you will need to add the necessary conditional statements and corresponding commands as illustrated in the enclosed image
    If instead in your charts you do not differentiate between Up/Down bars then all you need to do is add a setDefaultPriceBarColor() statement in preMain
    Alex





    Originally posted by maher_a_79
    I'm writing the below EFS that basically colors the price bar grey when the chop indicator is above 61.8.

    My 1st EFS and got far enough with the below code but the problem i'm having is that i'm not able to find a way to leave the price bars color as is when the chop indicator is not above 61.80. See my comment in the code that says " //Leave regular price bar color. How can i do that?" Can some one give me hand please?


    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Test");

    //activate the price bar coloring feature
    setColorPriceBars(true);

    }

    function main() {

    var nChopValue = chop(14, 0); // Current Bar Index
    if ( nChopValue > 61.8 ) {
    setPriceBarColor( Color.green );
    }
    else {
    //Leave regular price bar color. How can i do that?
    }

    return;
    }

    Comment


    • #3
      Hmmm, too bad that EFS doesn't just leave untouched bars the way they are.

      Any you, thanks Alexis, I got my 1st EFS working!

      Comment

      Working...
      X