Announcement

Collapse
No announcement yet.

low volume alarm per bar

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

  • low volume alarm per bar

    I have found many efs studies that will alert (audible) when a bar with a threshold of volume is hit.. I am trying to rewrite it to alarm when volume 10 secs before end of 1 minute bar is below a certain level.. can anyone help.. I changed the symbols.. from greater than to less than .. but now alarm goes off on everybar ..
    thanks
    Jay

  • #2
    please post an example of your code so we can help.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks for the help

      Thank you so much for noticing my post.. I do not care about bar color at all.. and I want to keep it really simple, so I don't even care about the ten seconds before the bar closes. I just want an audible alert at the end of a bar interval.. whether 1 minute or 5 minute etc. Teh alert would only sound if volume was below a threshold i.e... dwo jones one minute chart.. volume of last bar was below 200 contracts.. then soudn audible alarm.. if contracts were 201 then no sound!.. I would like the "low threshold" to be adjustable in the editor formula params.. Thank You

      currently this formula sounds at the beginning of verybar becaseu the voluem is alwasy belwo the threshold at the beginnign of a bar. I need to add something that says look back at the previous bar volume.

      I would also liek the color bar.. deleted from teh formula. thank you so much for yoru time and energy.. the reason for this formula is lthat i like to trade when there is extremely low volume.


      /************************************************** *******
      Alexis C. Montenegro © May 2003
      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 nLastRawTime1;
      var nLastRawTime2;

      function preMain() {

      setPriceStudy(false);
      setStudyTitle("VolumeMA");
      setCursorLabelName("Vol", 0);
      setCursorLabelName("maVol", 1);
      setDefaultBarStyle(PS_SOLID, 0);
      setDefaultBarStyle(PS_SOLID, 1);
      setDefaultBarFgColor(Color.black, 0);
      setDefaultBarFgColor(Color.black, 1);
      setDefaultBarThickness(1, 0);
      setDefaultBarThickness(1, 1);
      setPlotType(PLOTTYPE_HISTOGRAM, 0);
      setPlotType(PLOTTYPE_LINE, 1);
      setColorPriceBars(false);


      var fp1 = new FunctionParameter("MALength", FunctionParameter.NUMBER);
      fp1.setLowerLimit(1);
      fp1.setDefault(30);//Edit this value to set a new default

      var fp2 = new FunctionParameter("Threshold", FunctionParameter.NUMBER);
      fp2.setDefault(2000);//Edit this value to set a new default

      var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
      fp3.addOption("Price");
      fp3.addOption("Volume");
      fp3.setDefault("Volume"); //Edit this value to set a new default

      }

      function main(MALength,Threshold,Source) {

      var nLength = MALength;
      var i;
      var vSum = 0.0;
      var vValue;

      vValue = volume(0, -nLength);

      if(vValue == null) {
      return;
      }

      for(i = 0; i < nLength; i++) {
      vSum += vValue[i];
      }
      var MAofVol = Math.round(vSum/nLength);

      if(Source=="Price"){
      if (close() < close(-1))
      setBarFgColor(Color.RGB(255,0,0));
      else if (close() > close(-1))
      setBarFgColor(Color.RGB(0,0,255));
      else if (close() == close(-1))
      setBarFgColor(Color.RGB(0,0,0));
      }
      if(Source=="Volume"){
      if (volume() < volume(-1))
      setBarFgColor(Color.RGB(255,0,0));
      else if (volume() > volume(-1))
      setBarFgColor(Color.RGB(0,0,255));
      else if (volume() == volume(-1))
      setBarFgColor(Color.RGB(0,0,0));
      }


      if (getValue("rawtime",0) != nLastRawTime1) {
      if(volume()>MAofVol){
      Alert.playSound("ding.wav");
      Alert.addToList(getSymbol()+" "+getInterval(),"Volume Alert 1",Color.black,Color.blue);
      nLastRawTime1 = getValue("rawtime",0);
      }
      }
      if (getValue("rawtime",0) != nLastRawTime2) {
      if(volume()<Threshold){
      Alert.playSound("buzz.wav");
      Alert.addToList(getSymbol()+" "+getInterval(),"Volume Alert 2",Color.black,Color.red);
      nLastRawTime2 = getValue("rawtime",0);
      }
      }

      return new Array (volume(),MAofVol);

      }

      Comment


      • #4
        I believe all you need to do is change the volume() in your conditions to volume(-1) - this checks the previous bar..

        When you use..

        if (getValue("rawtime",0) != nLastRawTime2) {

        This checks the instance of a new bar on the chart (in RT or historical). This means, A NEW BAR (which has an index of 0) is available. So you need to check bar -1 for your condition.

        I've changed your code below.



        PHP Code:
        / **************************************************
        *******
        Alexis CMontenegro © May 2003 
        Use and/or modify this code freely. If you redistribute it
        please 
        include this and/or any other comment blocks and 
        description of any changes you make

        **************************************************
        ********/

        var 
        nLastRawTime1
        var 
        nLastRawTime2;

        function 
        preMain() {

        setPriceStudy(false);
        setStudyTitle("VolumeMA");
        setCursorLabelName("Vol"0);
        setCursorLabelName("maVol"1);
        setDefaultBarStyle(PS_SOLID0);
        setDefaultBarStyle(PS_SOLID1);
        setDefaultBarFgColor(Color.black0);
        setDefaultBarFgColor(Color.black1);
        setDefaultBarThickness(10);
        setDefaultBarThickness(11);
        setPlotType(PLOTTYPE_HISTOGRAM0);
        setPlotType(PLOTTYPE_LINE1);
        setColorPriceBars(false);


        var 
        fp1 = new FunctionParameter("MALength"FunctionParameter.NUMBER);
        fp1.setLowerLimit(1); 
        fp1.setDefault(30);//Edit this value to set a new default

        var fp2 = new FunctionParameter("Threshold"FunctionParameter.NUMBER); 
        fp2.setDefault(2000);//Edit this value to set a new default

        var fp3 = new FunctionParameter("Source"FunctionParameter.STRING);
        fp3.addOption("Price"); 
        fp3.addOption("Volume");
        fp3.setDefault("Volume"); //Edit this value to set a new default

        }

        function 
        main(MALength,Threshold,Source) {

        var 
        nLength MALength;
        var 
        i;
        var 
        vSum 0.0;
        var 
        vValue;

        vValue volume(0, -nLength);

        if(
        vValue == null) {
        return;
        }

        for(
        0nLengthi++) {
        vSum += vValue[i];
        }
        var 
        MAofVol Math.round(vSum/nLength);

        if(
        Source=="Price"){
        if (
        close() < close(-1))
        setBarFgColor(Color.RGB(255,0,0));
        else if (
        close() > close(-1))
        setBarFgColor(Color.RGB(0,0,255));
        else if (
        close() == close(-1))
        setBarFgColor(Color.RGB(0,0,0)); 
        }
        if(
        Source=="Volume"){
        if (
        volume() < volume(-1))
        setBarFgColor(Color.RGB(255,0,0));
        else if (
        volume() > volume(-1))
        setBarFgColor(Color.RGB(0,0,255));
        else if (
        volume() == volume(-1))
        setBarFgColor(Color.RGB(0,0,0));



        if (
        getValue("rawtime",0) != nLastRawTime1) { 
        if(
        volume(-1)>MAofVol){ 
        Alert.playSound("ding.wav");
        Alert.addToList(getSymbol()+" "+getInterval(),"Volume Alert 1",Color.black,Color.blue);
        nLastRawTime1 getValue("rawtime",0);
        }
        }
        if (
        getValue("rawtime",0) != nLastRawTime2) { 
        if(
        volume(-1)<Threshold){
        Alert.playSound("buzz.wav");
        Alert.addToList(getSymbol()+" "+getInterval(),"Volume Alert 2",Color.black,Color.red);
        nLastRawTime2 getValue("rawtime",0);
        }
        }

        return new Array (
        volume(),MAofVol);


        Brad Matheny
        eSignal Solution Provider since 2000

        Comment

        Working...
        X