Announcement

Collapse
No announcement yet.

VWAP value

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

  • VWAP value

    Hi!

    I am using Alexis' amVWAP.efs and it is working fine. However, I am trying to extract the current value so that I can set up an alert and am not having any luck.
    I added the code after the return xVWAP; statement.

    Thank you, Charley

    /************************************************** *******
    Alexis C. Montenegro © July 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.
    ************************************************** ********/

    // NOTE:
    // This efs requires amStudies.efsLib in the FunctionLibrary folder.
    // If you do not have this file you can download it at the link below.
    // http://share.esignal.com/groupconten...ies&groupid=10

    var fpArray = new Array();

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("VWAP");
    setCursorLabelName("VWAP",0);
    setDefaultBarFgColor(Color.blue,0);
    setPlotType(PLOTTYPE_SQUAREWAVE,0);
    setDefaultBarThickness(1,0);

    var x=0;

    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("Params", FunctionParameter.BOOLEAN);
    with(fpArray[x++]){
    setName("Show Parameters");
    setDefault(false);
    }
    }
    var amLib = addLibrary("amStudies.efsLib");
    var bInit = false;
    var xVWAP = null;
    var vwap = null;

    function main(Symbol,Interval,Params) {

    if(bInit == false) {
    with(amLib) {
    if(Symbol == null) Symbol = getSymbol();
    if(Interval == null) Interval = getInterval();
    var vSymbol = Symbol + "," + Interval;
    xVWAP = getSeries(amVWAP(sym(vSymbol)));
    setShowTitleParameters(eval(Params));
    bInit = true;
    }
    }
    return xVWAP;

    if(vwap == null) vwap = amLib.amVWAP();
    var val = vwap.getValue(0);
    return val; debugPrintln(val);
    }

  • #2
    charley
    Read this post
    FYI I found the thread (and many others on the same topic) by doing a google search on this bulletin board for “after the return statement”
    Alex


    Originally posted by charley View Post
    Hi!

    I am using Alexis' amVWAP.efs and it is working fine. However, I am trying to extract the current value so that I can set up an alert and am not having any luck.
    I added the code after the return xVWAP; statement.

    Thank you, Charley

    /************************************************** *******
    Alexis C. Montenegro © July 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.
    ************************************************** ********/

    // NOTE:
    // This efs requires amStudies.efsLib in the FunctionLibrary folder.
    // If you do not have this file you can download it at the link below.
    // http://share.esignal.com/groupconten...ies&groupid=10

    var fpArray = new Array();

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("VWAP");
    setCursorLabelName("VWAP",0);
    setDefaultBarFgColor(Color.blue,0);
    setPlotType(PLOTTYPE_SQUAREWAVE,0);
    setDefaultBarThickness(1,0);

    var x=0;

    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("Params", FunctionParameter.BOOLEAN);
    with(fpArray[x++]){
    setName("Show Parameters");
    setDefault(false);
    }
    }
    var amLib = addLibrary("amStudies.efsLib");
    var bInit = false;
    var xVWAP = null;
    var vwap = null;

    function main(Symbol,Interval,Params) {

    if(bInit == false) {
    with(amLib) {
    if(Symbol == null) Symbol = getSymbol();
    if(Interval == null) Interval = getInterval();
    var vSymbol = Symbol + "," + Interval;
    xVWAP = getSeries(amVWAP(sym(vSymbol)));
    setShowTitleParameters(eval(Params));
    bInit = true;
    }
    }
    return xVWAP;

    if(vwap == null) vwap = amLib.amVWAP();
    var val = vwap.getValue(0);
    return val; debugPrintln(val);
    }

    Comment


    • #3
      Thanks again Alex.

      Comment


      • #4
        charley
        You are welcome
        Alex


        Originally posted by charley View Post
        Thanks again Alex.

        Comment


        • #5
          Hello Alex,

          I'm trying to get VWAP to display. But haven't been able to do so successfully. Can you please help? Here's my code -

          var amLib = addLibrary("amStudies.efsLib");
          var vwapStudy = null;

          function preMain() {
          setPriceStudy(true);
          }

          function main(){
          if(pShowVWAP && vwapStudy == null) {
          with(amLib) {
          vwapStudy = getSeries(amLib.amVWAP());
          debugPrintln("VWAP = " + vwapStudy.getValue(0)); //THIS IS ALWAYS NULL!!
          }
          }
          }

          Comment


          • #6
            esigtrader
            The study requires at least 2 bars for its calculations and returns null on the first/oldest bar hence the null returned by your debug statement since it is within a conditional statement that executes once only on the first bar
            If you want to retrieve the values on all the bars then you need to move your debug statement out of that conditional statement
            As an aside search the forum as I have a) posted a revised version of the VWAP function and b) have provided examples on its use.
            Alex


            Originally posted by esigtrader View Post
            Hello Alex,

            I'm trying to get VWAP to display. But haven't been able to do so successfully. Can you please help? Here's my code -

            var amLib = addLibrary("amStudies.efsLib");
            var vwapStudy = null;

            function preMain() {
            setPriceStudy(true);
            }

            function main(){
            if(pShowVWAP && vwapStudy == null) {
            with(amLib) {
            vwapStudy = getSeries(amLib.amVWAP());
            debugPrintln("VWAP = " + vwapStudy.getValue(0)); //THIS IS ALWAYS NULL!!
            }
            }
            }

            Comment


            • #7
              Thanks Alex. Appreciate the prompt response and correction. I have moved the debug statement out of the conditional as follows, bit it still returns null each time it's called -

              var amLib = addLibrary("amStudies.efsLib");
              var vwapStudy = null;

              function preMain() {
              setPriceStudy(true);
              }

              function main(){
              if(vwapStudy == null) {
              with(amLib) {
              vwapStudy = getSeries(amLib.amVWAP());
              }
              }
              debugPrintln("VWAP = " + vwapStudy.getValue(0)); //STILL ALWAYS NULL!!
              }

              I'm on the latest eSignal build, does that matter? In other words, do I need to update VWAP to make it work?

              EDIT- I downloaded the library just a couple of weeks back and believe have the latest file.

              Thanks again.

              eSigTrader.
              Last edited by esigtrader; 09-30-2015, 02:26 PM. Reason: Addition information

              Comment


              • #8
                esigtrader
                As far as I can see the script is returning values (see enclosed screenshot)
                FYI I am on the latest build also and the library has not changed in a while
                Alex




                Originally posted by esigtrader View Post
                Thanks Alex. Appreciate the prompt response and correction. I have moved the debug statement out of the conditional as follows, bit it still returns null each time it's called -

                var amLib = addLibrary("amStudies.efsLib");
                var vwapStudy = null;

                function preMain() {
                setPriceStudy(true);
                }

                function main(){
                if(vwapStudy == null) {
                with(amLib) {
                vwapStudy = getSeries(amLib.amVWAP());
                }
                }
                debugPrintln("VWAP = " + vwapStudy.getValue(0)); //STILL ALWAYS NULL!!
                }

                I'm on the latest eSignal build, does that matter? In other words, do I need to update VWAP to make it work?

                EDIT- I downloaded the library just a couple of weeks back and believe have the latest file.

                Thanks again.

                eSigTrader.

                Comment


                • #9
                  Thanks Alex. Appreciate the detailed follow-up. I believe amVWAP does not work with Tick and Volume charts (which is what I was running the study on). Once I changed the chart to be a time (1Min, 5Min) chart, the VWAP values are returned. Is this a bug or something that can't be done with amVWAP? Thanks, _esigtrader

                  Comment


                  • #10
                    esigtrader

                    I believe amVWAP does not work with Tick and Volume charts
                    The documentation I provide for the amStudies library as well as the related thread in this forum clearly state that the amVWAP() function - and the amVWAP2() revision - are for minute based intervals only.
                    Alex


                    Originally posted by esigtrader View Post
                    Thanks Alex. Appreciate the detailed follow-up. I believe amVWAP does not work with Tick and Volume charts (which is what I was running the study on). Once I changed the chart to be a time (1Min, 5Min) chart, the VWAP values are returned. Is this a bug or something that can't be done with amVWAP? Thanks, _esigtrader

                    Comment


                    • #11
                      Thanks Alex. My apologies for missing that in the documentation (generally skip reading description of optional params that I don't intend to use - in this case the inv() param) - my bad. Just curious if there is a reason for not supporting Tick charts? Is it a matter of more code or inherent VWAP limitation. Thanks, esigtrader.

                      Comment


                      • #12
                        esigtrader

                        (generally skip reading description of optional params that I don't intend to use - in this case the inv() param)
                        Actually you may want to consider using it since that would allow you to calculate the VWAP on a minute based interval and plot it on a tick based chart. I appreciate that it would not be based on the tick interval itself but from experience the difference is marginal at best

                        Just curious if there is a reason for not supporting Tick charts?
                        Simply that I have no need for it. Keep in mind that even though I share the functions included in this and other libraries, I developed them almost exclusively to satisfy my needs and/or interest.
                        Alex


                        Originally posted by esigtrader View Post
                        Thanks Alex. My apologies for missing that in the documentation (generally skip reading description of optional params that I don't intend to use - in this case the inv() param) - my bad. Just curious if there is a reason for not supporting Tick charts? Is it a matter of more code or inherent VWAP limitation. Thanks, esigtrader.

                        Comment


                        • #13
                          That's a great point Alex! Thanks for the tip. Understood about the motivation for the code. Appreciate you sharing with all.

                          Off topic - I've found the eSignal support for EFS and related areas dismal and don't get any response to my queries. Not sure if your experience has been different. I've been trying to get an answer to the following issue through different channels but haven't been successful yet. If you have any pointer for me - I'd love to hear your take on it. Thanks again - esigtrader.

                          http://forum.esignal.com/showthread....956#post148956

                          Comment

                          Working...
                          X