Announcement

Collapse
No announcement yet.

Changing study color to indicate actual crossover bar

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

  • Changing study color to indicate actual crossover bar

    I would like to have the color of a study bar be a specific color when it passes thru a certain value. For example, if the PercentR passes from below -50 to above -50, I would like that specific bar to be lime. I can get the next bar to be lime but not that bar. It seems that you can only control the next bar color as in the below example.

    function preMain() {
    setStudyTitle("%R Color Line");
    setCursorLabelName("%R", 0);

    var fp1 = new FunctionParameter("nInputLength", FunctionParameter.NUMBER);
    fp1.setName("RSI Length");
    fp1.setLowerLimit(1);
    fp1.setDefault(14);
    }

    var vValue = null;

    function main(nInputLength) {
    if (vValue == null) {
    vValue = efsExternal("/library/WilliamsPercentR.efs", nInputLength);
    }

    if(vValue.getValue(-1) < -50 && vValue.getValue(0) > -50) {
    setBarThickness(2);
    setBarFgColor(Color.lime);
    } else {
    setBarThickness(2);
    setBarFgColor(Color.red);
    }

    return (vValue.getValue(0));

  • #2
    twannster
    Add a setPlotType(PLOTTYPE_INSTANTCOLORLINE, 0) statement in preMain
    For information on the various plot types see this article in the EFS KnolwedgeBase
    Alex.

    Comment


    • #3
      Thank you very much!

      Comment


      • #4
        twannster
        You are most welcome
        Alex

        Comment

        Working...
        X