Announcement

Collapse
No announcement yet.

alert pop up and sound for efs2

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

  • alert pop up and sound for efs2

    Is it possible to create an alert pop up and/or sound every time it hits or is outside of channel? thanks!

    /************************************************** *******
    Alexis C. Montenegro © June 2005
    Use and/or modify this code freely. If you redistribute it
    please include this and/or any other comment blocks and a
    description of any changes you make.
    ************************************************** ********/

    var fpArray = new Array();

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("MAChannel");
    setCursorLabelName("Upper", 0);
    setCursorLabelName("MA", 1);
    setCursorLabelName("Lower", 2);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarFgColor(Color.blue, 2);
    setPlotType(PLOTTYPE_LINE,0);
    setPlotType(PLOTTYPE_LINE,1);
    setPlotType(PLOTTYPE_LINE,2);
    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    setDefaultBarThickness(1,2);
    var x=0;
    fpArray[x] = new FunctionParameter("Type", FunctionParameter.STRING);
    with(fpArray[x++]){
    addOption("sma");
    addOption("ema");
    addOption("wma");
    addOption("vwma");
    setDefault("sma");
    }
    fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(10);
    }
    fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
    with(fpArray[x++]){
    addOption("open");
    addOption("high");
    addOption("low");
    addOption("close");
    addOption("hl2");
    addOption("hlc3");
    addOption("ohlc4");
    setDefault("close");
    }
    fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
    with(fpArray[x++]){
    setDefault();
    }
    fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
    with(fpArray[x++]){
    setDefault();
    }
    fpArray[x] = new FunctionParameter("Bands", FunctionParameter.STRING);
    with(fpArray[x++]){
    setName("Bands based on");
    addOption("Points");
    addOption("Percent");
    addOption("Std Deviation");
    addOption("ATR");
    setDefault("Points");
    }
    fpArray[x] = new FunctionParameter("Value", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setName("Value/Multiple");
    setLowerLimit(0);
    setDefault(0);
    }
    fpArray[x] = new FunctionParameter("Offset", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0);
    }
    fpArray[x] = new FunctionParameter("LineColor1", FunctionParameter.COLOR);
    with(fpArray[x++]){
    setName("Channel Color");
    setDefault(Color.blue);
    }
    fpArray[x] = new FunctionParameter("LineColor2", FunctionParameter.COLOR);
    with(fpArray[x++]){
    setName("Basis Color");
    setDefault(Color.red);
    }
    fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
    with(fpArray[x++]){
    setName("Show Parameters");
    setDefault(false);
    }
    }

    var bInit = false;
    var xMA = null;
    var xBands = null;
    var xBandsUpper = 0;
    var xBandsBasis = 0;
    var xBandsLower = 0;

    function main(Type,Length,Source,Symbol,Interval,Bands,Valu e,Offset,LineColor1,LineColor2,Params) {
    if(bInit == false){
    if(Symbol == null) Symbol = getSymbol();
    if(Interval == null) Interval = getInterval();
    var vSymbol = Symbol+","+Interval;
    xBands = efsInternal("calcBands",Type,Length,Source,Bands,V alue,Offset,sym(vSymbol));
    xBandsUpper = getSeries(xBands,0);
    xBandsBasis = getSeries(xBands,1);
    xBandsLower = getSeries(xBands,2);
    setDefaultBarFgColor(LineColor1,0);
    setDefaultBarFgColor(LineColor2,1);
    setDefaultBarFgColor(LineColor1,2);
    setShowTitleParameters(eval(Params));
    bInit = true;
    }
    return new Array (xBandsUpper,xBandsBasis,xBandsLower);
    }

    var xInit = false;
    var xValue = null;
    var xMA = null
    var xATR = null;

    function calcBands(type,length,source,bands,value,offset,se ries){
    var nATR = null;
    var nUpper = null;
    var nLower = null;
    var ySum = 0;
    var vStdDev = 0;
    if(xInit==false){
    xValue = offsetSeries(eval(source)(),offset);
    xMA = offsetSeries(eval(type)(length,eval(source)()),off set);
    xATR = offsetSeries(atr(length),offset);
    xInit=true;
    }
    if(bands == "Points"){
    var nMA = xMA.getValue(0)
    if(nMA == null) return;
    nUpper = nMA+value;
    nLower = nMA-value;
    }
    else if(bands == "Percent"){
    var nMA = xMA.getValue(0)
    if(nMA == null) return;
    nUpper = nMA*(1+(value/100));
    nLower = nMA*(1-(value/100));
    }
    else if(bands == "ATR"){
    var nMA = xMA.getValue(0)
    var nATR = xATR.getValue(0);
    if(nMA == null || nATR == null) return;
    nUpper = nMA+(nATR*value);
    nLower = nMA-(nATR*value);
    }
    else if(bands == "Std Deviation"){
    var nMA = xMA.getValue(0)
    if(nMA == null) return;

    for(var i=0; i<length; i++){
    ySum += (xValue.getValue(-i)-nMA)*(xValue.getValue(-i)-nMA);
    }
    vStdDev=Math.sqrt(ySum/(length));
    nUpper = nMA+(value*vStdDev);
    nLower = nMA-(value*vStdDev);
    }
    return new Array (nUpper,nMA,nLower);
    }
Working...
X