Announcement

Collapse
No announcement yet.

Help to change the bars colors

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

  • Help to change the bars colors

    Please, can someone help to modifie this formula to change the bars colors, too?

    /************************************************** *****************
    Provided By : TS Support, LLC for eSignal. (c) Copyright 2002
    ************************************************** ******************/


    function preMain()
    {
    setStudyTitle("Movtrend");
    setCursorLabelName("Movtrend", 0);
    setDefaultBarFgColor(Color.white, 0);
    setPlotType(PLOTTYPE_INSTANTCOLORLINE);
    setDefaultBarThickness(2, 0);
    setPriceStudy(true);

    }

    var wt = null;
    var wt_1 = null;

    function main(n) {

    if(n == null)
    n = 34;
    var sum = 0;
    var i = 0;

    if(getBarState()==BARSTATE_NEWBAR){
    wt_1 = wt;
    }

    for(i = n; i > 0; i--)
    sum += (i - (n + 1) / 3) * close(i - n);
    wt = 6 / (n * (n + 1)) * sum;

    if(wt>wt_1)
    setBarFgColor(Color.lime);
    if(wt<wt_1)
    setBarFgColor(Color.red);


    return wt;
    }

  • #2
    Barros
    To paint the price bars you need to add setPriceBarColor(Color.xxx) in place of - or in addition to - setBarFgColor(Color.xxx). If you want to add it then you need to consider that when you want to execute multiple commands for the same condition you need to enclose these commands in brackets ie { } (see the following example created using your code)
    if(wt>wt_1){
    setBarFgColor(Color.lime);
    setPriceBarColor(Color.lime);
    }

    Repeat as required for the other condition(s)
    You will also need to add setColorPriceBars(true) and setDefaultPriceBarColor(Color.your_color) in preMain (replace your_color with a valid color type)
    Since you seem to be increasingly using efs I would strongly suggest that you take some time to go through the Help Guides and Tutorials available in the EFS KnowledgeBase. If you are interested in learning more about JavaScript which is the basis for EFS then you may want to also review the Core JavaScript Video Series.
    Alex

    Comment


    • #3
      Thank you very much

      Hi Alex,
      Once more, thank you very much for you excellent help.

      Comment

      Working...
      X