Announcement

Collapse
No announcement yet.

Bandwidth

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

  • Bandwidth

    I made a stab at modifying the bandwidth efs file, as follows:


    function preMain() {
    setStudyTitle("Lowest BandWidth");
    setCursorLabelName("Low BW", 0);
    setCursorLabelName("Floor", 1);
    }

    var bb = new BollingerStudy(20, "Close", 2.0);

    function main() {
    var vUpper = bb.getValue(BollingerStudy.UPPER);
    var vLower = bb.getValue(BollingerStudy.LOWER);
    var vMiddle = bb.getValue(BollingerStudy.BASIS);

    var Bndwidth = efs("/Bollinger/Bandwidth.efs",0);
    var low_bw = llv(50,Bndwidth);


    if(vUpper == null || vLower == null || vMiddle == null)
    return 0.0;

    return new Array((vUpper - vLower) / vMiddle * 100, 0.0, low_bw);
    }

    What I'd like to do, however, is color the line a different color when the bandwidth is equal to the lowest bandwith. Also, I'd like to be able to modify the low_bw (or the lookback number) via the Formula Parameters in Study Properties dialog box.

    What am I missing?

    Thanks.

    Harold Harper
    [email protected]

  • #2
    Harold
    To add a user definable parameter for the lookback add the following lines to preMain()

    PHP Code:
    var fp1 = new FunctionParameter("Lookback"FunctionParameter.NUMBER);
        
    fp1.setLowerLimit(1);        
        
    fp1.setDefault(50); 
    Then add Lookback in the brackets of function main() ie it should become function main(Lookback).
    Lastly replace llv(50,Bndwidth); with llv(Lookback,Bndwidth);
    To color the line based on your condition add the following line just above the return statement

    PHP Code:
    if((vUpper vLower) / vMiddle 100==low_bwsetBarFgColor(Color.red,2); 
    That should provide you with all the changes you wanted
    Hope this helps
    Alex

    Comment

    Working...
    X