Announcement

Collapse
No announcement yet.

DDE Question

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

  • DDE Question

    Currently the script below is returning #NAME?. I have multiples dde scripts opened on a few charts working perfectly but for the life of me can't crack this one.

    Is it because the data for Ask and Bid vol are being returned in an array???

    Any help greatly appreciated.

    William

    function preMain() {
    setStudyTitle("Bid\/Ask Volume ");
    setCursorLabelName("Ask Vol", 0);
    setCursorLabelName("Inside Vol", 1);
    setCursorLabelName("Bid Vol", 2);
    setDefaultBarFgColor(Color.green, 0);
    setDefaultBarFgColor(Color.black, 1);
    setDefaultBarFgColor(Color.red, 2);
    setDefaultBarThickness(8, 0);
    setDefaultBarThickness(6, 1);
    setDefaultBarThickness(4, 2);
    setPlotType(PLOTTYPE_HISTOGRAM, 0);
    setPlotType(PLOTTYPE_HISTOGRAM, 1);
    setPlotType(PLOTTYPE_HISTOGRAM, 2);

    var fp0 = new FunctionParameter("sType", FunctionParameter.STRING);
    fp0.setName("Analysis");
    fp0.addOption("Bar");
    fp0.addOption("Cumulative");
    fp0.setDefault("Bar");
    }

    var nBidVol = null;
    var nInsideVol = null;
    var nAskVol = null;
    var vVol = null;
    var bPrimed = false;
    var nAsk = null;
    var nBid = null;
    var bEdit = true;
    var ddeup = null;
    var ddedown = null;

    function main(sType) {
    if (getCurrentBarIndex() < 0) return;

    var nState = getBarState();
    if (nState == BARSTATE_NEWBAR) {
    if (sType == "Bar" || day(0) != day(-1)) {
    nBidVol = 0;
    nInsideVol = 0;
    nAskVol = 0;
    }
    vVol = 0;
    }

    var vPrevVol = null;
    if (vVol != null && bPrimed == true) vPrevVol = vVol;

    var nTempAsk = getMostRecentAsk();
    var nTempBid = getMostRecentBid();
    if (nTempAsk != null && nTempAsk != 0) nAsk = nTempAsk;
    if (nTempBid != null && nTempBid != 0) nBid = nTempBid;

    var vClose = close();
    vVol = volume();

    var vTradeVol = vVol - vPrevVol;

    if (bPrimed == false && vVol != null) {
    bPrimed = true;
    return;
    } else {
    if (vClose <= nBid) {
    nBidVol += vTradeVol;
    } else if (vClose >= nAsk) {
    nAskVol += vTradeVol;
    } else {
    nInsideVol += vTradeVol;
    }
    }

    return new Array(nAskVol, nInsideVol, nBidVol);

    if (bEdit == true) {
    var sym = getSymbol();
    sym = sym.replace(" #F", "");
    sym = sym.replace(" ", "_");
    debugPrintln("Example DDE link: '=eSignal|EFS!" + sym + "_ask");
    ddeup = new DDEOutput(sym + "_ask" + getInterval());
    ddedown = new DDEOutput(sym + "_bid" + getInterval());
    bEdit = false;

    retVal = nAskVol.getValue(0)
    xretVal = nBidVol.getValue(0)


    if(retVal != null) ddeup.set(retVal);
    if(xretVal != null) ddedown.set(xretVal);
    }

    return;

    }
    Last edited by WilliamV; 12-01-2011, 09:09 AM.

  • #2
    More info. This is what I currently have in the excel cell: =eSignal|EFS!ES_ask5

    Special thanks to Jason K for the original BidAskVolume efs script!!

    Comment


    • #3
      You might want to rethink putting:

      return new Array(nAskVol, nInsideVol, nBidVol);

      below your:

      if (bEdit == true) { ... }

      [doh!]

      William, on something less obvious:

      This is very important. Always, always put your local var declarations just after the 1st "{" of the function. There is no local variable scoping rule in Javascript. All local vars get hoisted to the top of the function regardless of where you declare them. This can produce some nasty initialization bugs if you start pasting other code which references those vars above the declarations.

      Also, always put your global var declarations above ALL of your function definitions (first one in an EFS is usually the preMain()). Same hoisting issue. Same kinds of bugs may result.
      Last edited by SteveH; 12-01-2011, 04:49 PM.

      Comment


      • #4
        Changed the location returning the array, below the dde code, at the end of the if(bEdit == true), now returning 0.00.

        Looking at var declaration locations...

        Comment


        • #5
          Looking over your script, you have the code:
          PHP Code:
                  if (retVal != nullddeup.set(retVal);
          if (
          xretVal != nullddedown.set(xretVal); 
          inside the bEdit brackets which means it executes only once on the first getCurrentBarIndex() == 0. I would place the bEdit code near the top after local variable declarations and only include code which gives the values to the ddeup and ddedown variables as I believe you inteded to do.

          Also, you are retrieving the values for retVal and xretVal as if they were series (retVal = nAskVol.getValue(0)) when in fact they are single cummulative values calculated just above, not arrays. The variables retVal and xretVal are not needed, just use nAskVol and bBidVol respectively. Also, to avoid other potential issues, terminate each complete line of regular code with a semicolon ( retVal = nAskVol.getValue(0); ).

          Last consider using something to correctly indent your code, it makes it easier to read and find errors. A good resource is found at: http://jsbeautifier.org/

          I did not test this code because the markets are now closed and this script only runs on real time but here are my untested revisions.

          PHP Code:
          //http://forum.esignal.com/showthread.php?s=&threadid=36990


          function preMain() {
              
          setStudyTitle("Bid\/Ask Volume ");
              
          setCursorLabelName("Ask Vol"0);
              
          setCursorLabelName("Inside Vol"1);
              
          setCursorLabelName("Bid Vol"2);
              
          setDefaultBarFgColor(Color.green0);
              
          setDefaultBarFgColor(Color.black1);
              
          setDefaultBarFgColor(Color.red2);
              
          setDefaultBarThickness(80);
              
          setDefaultBarThickness(61);
              
          setDefaultBarThickness(42);
              
          setPlotType(PLOTTYPE_HISTOGRAM0);
              
          setPlotType(PLOTTYPE_HISTOGRAM1);
              
          setPlotType(PLOTTYPE_HISTOGRAM2);

              var 
          fp0 = new FunctionParameter("sType"FunctionParameter.STRING);
              
          fp0.setName("Analysis");
              
          fp0.addOption("Bar");
              
          fp0.addOption("Cumulative");
              
          fp0.setDefault("Bar");
          }

          var 
          nBidVol null;
          var 
          nInsideVol null;
          var 
          nAskVol null;
          var 
          vVol null;
          var 
          bPrimed false;
          var 
          nAsk null;
          var 
          nBid null;
          var 
          bEdit true;
          var 
          ddeup null;
          var 
          ddedown null;

          function 
          main(sType) {
              var 
          vPrevVol null;
              var 
          nTempAsk null;
              var 
          nTempBid null;
              if (
          getCurrentBarIndex() < 0) return;

              if (
          bEdit == true) {
                  var 
          symb getSymbol();
                  
          symb symb.replace(" #F""");
                  
          symb symb.replace(" ""_");
                  
          ddeup = new DDEOutput(symb "_ask" getInterval());
                  
          ddedown = new DDEOutput(symb "_bid" getInterval());
                  
          debugPrintln("Example DDE link: '=eSignal|EFS!" symb "_ask" getInterval());
                  
          bEdit false;
              }
              var 
          nState getBarState();
              if (
          nState == BARSTATE_NEWBAR) {
                  if (
          sType == "Bar" || day(0) != day(-1)) {
                      
          nBidVol 0;
                      
          nInsideVol 0;
                      
          nAskVol 0;
                  }
                  
          vVol 0;
              }

              if (
          vVol != null && bPrimed == truevPrevVol vVol;

              
          nTempAsk getMostRecentAsk();
              
          nTempBid getMostRecentBid();
              if (
          nTempAsk != null && nTempAsk != 0nAsk nTempAsk;
              if (
          nTempBid != null && nTempBid != 0nBid nTempBid;

              var 
          vClose close(0);
              
          vVol volume(0);

              var 
          vTradeVol vVol vPrevVol;

              if (
          bPrimed == false && vVol != null) {
                  
          bPrimed true;
                  return;
              } else {
                  if (
          vClose <= nBid) {
                      
          nBidVol += vTradeVol;
                  } else if (
          vClose >= nAsk) {
                      
          nAskVol += vTradeVol;
                  } else {
                      
          nInsideVol += vTradeVol;
                  }
              }
              if (
          nAskVol != nullddeup.set(nAskVol);
              if (
          nBidVol != nullddedown.set(nBidVol);

              return new Array(
          nAskVolnInsideVolnBidVol);

          Wayne
          Last edited by waynecd; 12-03-2011, 04:45 AM.

          Comment


          • #6
            Special thanks to Jason again, Steve and Wayne.

            Merry Xmas and happy holidays to all.

            Comment


            • #7
              What if you want to return the values for the previous bar, nAskVol(-1), nBidVol(-1) knowing that everytime the efs is reloaded, it populates current bar, erasing historic values?

              Comment


              • #8
                The easier coding way is to use "ref()".

                I had already done this for the Bid/Ask study using efs intermal to create a series from it. I just added some value retrieval examples and comments for your benefit.

                I think the eSignal tutorials cover efsInternal() in addition to the knowledge base and forum search. A good sample explanation from Stevehare2003 can be found at :


                PHP Code:
                //http://forum.esignal.com/showthread.php?s=&threadid=36990
                debugClear();

                function 
                preMain() {
                    
                setStudyTitle("Bid/Ask Volume ");
                    
                setCursorLabelName("Ask Vol"0);
                    
                setCursorLabelName("Inside Vol"1);
                    
                setCursorLabelName("Bid Vol"2);
                    
                setDefaultBarFgColor(Color.green0);
                    
                setDefaultBarFgColor(Color.black1);
                    
                setDefaultBarFgColor(Color.red2);
                    
                setDefaultBarThickness(80);
                    
                setDefaultBarThickness(61);
                    
                setDefaultBarThickness(42);
                    
                setPlotType(PLOTTYPE_HISTOGRAM0);
                    
                setPlotType(PLOTTYPE_HISTOGRAM1);
                    
                setPlotType(PLOTTYPE_HISTOGRAM2);

                    var 
                fp0 = new FunctionParameter("sType"FunctionParameter.STRING);
                    
                fp0.setName("Analysis");
                    
                fp0.addOption("Bar");
                    
                fp0.addOption("Cumulative");
                    
                fp0.setDefault("Bar");
                }
                var 
                bInit false;
                var 
                bidaskArray;
                var 
                ddeup_1 null;
                var 
                ddedown_1 null;

                function 
                main(sType){
                    var 
                ask1_0,ask1_1,bid1_0,bid1_1,inside1_0,inside1_1;
                    if(!
                bInit){
                        var 
                symb_ getSymbol();
                        
                symb_ symb_.replace(" #F""");
                        
                symb_ symb_.replace(" ""_");
                        
                bidaskArray efsInternal("bidask_",sType);
                        
                ask1=getSeries(bidaskArray,0);
                        
                inside1=getSeries(bidaskArray,1);
                        
                bid1=getSeries(bidaskArray,2);
                        
                ddeup_1 = new DDEOutput(symb_ "_ask_1" getInterval());
                        
                ddedown_1 = new DDEOutput(symb_ "_bid_1" getInterval());
                        
                debugPrintln("Example DDE link: '=eSignal|EFS!" symb_ "_ask_1" getInterval());
                        
                debugPrintln("Example DDE link: '=eSignal|EFS!" symb_ "_bid_1" getInterval());
                        
                bInit true;
                    }
                    
                ask1_0 ask1.getValue(0);//(0) returns current value 
                    
                ask1_1 ask1.getValue(-1);//(-1) returns previous value 
                    
                bid1_0 bid1.getValue(0);
                    
                bid1_1 bid1.getValue(0);
                    
                inside1_0 inside1.getValue(0);
                    
                inside1_1 inside1.getValue(-1);
                    
                //debugPrintln(ask1_0+", "+ask1_1);
                    //consider/test using a null check when retrieving individual values, i.e.,
                    //if(ask1_1 != null) "then do something";
                    
                if (ask1_1 != nullddeup_1.set(ask1_1);
                    if (
                bid1_1 != nullddedown_1.set(bid1_1);

                    
                    return new Array(
                ask1,inside1,bid1);
                    
                //return new Array(ask1_0,inside1_0,bid1_0);//could be used instead of the above return statement
                }

                var 
                nBidVol null;
                var 
                nInsideVol null;
                var 
                nAskVol null;
                var 
                vVol null;
                var 
                bPrimed false;
                var 
                nAsk null;
                var 
                nBid null;
                var 
                bEdit true;
                var 
                ddeup null;
                var 
                ddedown null;

                function 
                bidask_(xType) {
                    var 
                vPrevVol null;
                    var 
                nTempAsk null;
                    var 
                nTempBid null;
                    if (
                getCurrentBarIndex() < 0) return;

                    if (
                bEdit == true) {
                        var 
                symb getSymbol();
                        
                symb symb.replace(" #F""");
                        
                symb symb.replace(" ""_");
                        
                ddeup = new DDEOutput(symb "_ask" getInterval());
                        
                ddedown = new DDEOutput(symb "_bid" getInterval());
                        
                debugPrintln("Example DDE link: '=eSignal|EFS!" symb "_ask" getInterval());
                        
                debugPrintln("Example DDE link: '=eSignal|EFS!" symb "_bid" getInterval());
                        
                bEdit false;
                    }
                    var 
                nState getBarState();
                    if (
                nState == BARSTATE_NEWBAR) {
                        if (
                xType == "Bar" || day(0) != day(-1)) {
                            
                nBidVol 0;
                            
                nInsideVol 0;
                            
                nAskVol 0;
                        }
                        
                vVol 0;
                    }

                    if (
                vVol != null && bPrimed == truevPrevVol vVol;

                    
                nTempAsk getMostRecentAsk();
                    
                nTempBid getMostRecentBid();
                    if (
                nTempAsk != null && nTempAsk != 0nAsk nTempAsk;
                    if (
                nTempBid != null && nTempBid != 0nBid nTempBid;

                    var 
                vClose close(0);
                    
                vVol volume(0);

                    var 
                vTradeVol vVol vPrevVol;

                    if (
                bPrimed == false && vVol != null) {
                        
                bPrimed true;
                        return;
                    } else {
                        if (
                vClose <= nBid) {
                            
                nBidVol += vTradeVol;
                        } else if (
                vClose >= nAsk) {
                            
                nAskVol += vTradeVol;
                        } else {
                            
                nInsideVol += vTradeVol;
                        }
                    }
                    if (
                nAskVol != nullddeup.set(nAskVol);
                    if (
                nBidVol != nullddedown.set(nBidVol);

                    return new Array(
                nAskVolnInsideVolnBidVol);

                Wayne
                Last edited by waynecd; 12-06-2011, 04:33 AM.

                Comment


                • #9
                  Line 33 originally formula not found, changed it to:
                  bidaskArray = efsInternal("bidask_"(sType));

                  Do not know whether this was necessary but in Line 37, in order to avoid interval confusion, changed it to
                  ddeup_1 = new DDEOutput(symb_ + "_xask" + getInterval()); instead of ask_1 followed by interval.

                  Now No syntax errors but returning #name?

                  Reading up on the links posted.

                  Comment


                  • #10
                    It works fine on my end and returns:

                    Example DDE link: '=eSignal|EFS!6E_bid_1100T
                    Example DDE link: '=eSignal|EFS!6E_ask_1100T
                    Example DDE link: '=eSignal|EFS!6E_bid100T
                    Example DDE link: '=eSignal|EFS!6E_ask100T
                    Post what you have once again to see what's going on.

                    Wayne

                    Comment


                    • #11
                      Now with the code below, is returning all the appropriates values with the exception of the previous bids which is also returning the current bar instead of the previous. Obviously when more than one bar has formed.

                      I think I had too many different efs versions running on different charts which was giving me the problems originally posted.

                      debugClear();

                      function preMain() {
                      setStudyTitle("Bid/Ask Volume ");
                      setCursorLabelName("Ask Vol", 0);
                      setCursorLabelName("Inside Vol", 1);
                      setCursorLabelName("Bid Vol", 2);
                      setDefaultBarFgColor(Color.green, 0);
                      setDefaultBarFgColor(Color.black, 1);
                      setDefaultBarFgColor(Color.red, 2);
                      setDefaultBarThickness(8, 0);
                      setDefaultBarThickness(6, 1);
                      setDefaultBarThickness(4, 2);
                      setPlotType(PLOTTYPE_HISTOGRAM, 0);
                      setPlotType(PLOTTYPE_HISTOGRAM, 1);
                      setPlotType(PLOTTYPE_HISTOGRAM, 2);

                      var fp0 = new FunctionParameter("sType", FunctionParameter.STRING);
                      fp0.setName("Analysis");
                      fp0.addOption("Bar");
                      fp0.addOption("Cumulative");
                      fp0.setDefault("Bar");
                      }
                      var bInit = false;
                      var bidaskArray;
                      var ddeup_1 = null;
                      var ddedown_1 = null;

                      function main(sType){
                      var ask1_0,ask1_1,bid1_0,bid1_1,inside1_0,inside1_1;
                      if(!bInit){
                      var symb_ = getSymbol();
                      symb_ = symb_.replace(" #F", "");
                      symb_ = symb_.replace(" ", "_");
                      bidaskArray = efsInternal("bidask_",sType);
                      ask1=getSeries(bidaskArray,0);
                      inside1=getSeries(bidaskArray,1);
                      bid1=getSeries(bidaskArray,2);
                      ddeup_1 = new DDEOutput(symb_ + "_ask_1" + getInterval());
                      ddedown_1 = new DDEOutput(symb_ + "_bid_1" + getInterval());
                      debugPrintln("Example DDE link: '=eSignal|EFS!" + symb_ + "_ask_1" + getInterval());
                      debugPrintln("Example DDE link: '=eSignal|EFS!" + symb_ + "_bid_1" + getInterval());
                      bInit = true;
                      }
                      ask1_0 = ask1.getValue(0);//(0) returns current value
                      ask1_1 = ask1.getValue(-1);//(-1) returns previous value
                      bid1_0 = bid1.getValue(0);
                      bid1_1 = bid1.getValue(0);
                      inside1_0 = inside1.getValue(0);
                      inside1_1 = inside1.getValue(-1);
                      //debugPrintln(ask1_0+", "+ask1_1);
                      //consider/test using a null check when retrieving individual values, i.e.,
                      //if(ask1_1 != null) "then do something";
                      if (ask1_1 != null) ddeup_1.set(ask1_1);
                      if (bid1_1 != null) ddedown_1.set(bid1_1);


                      return new Array(ask1,inside1,bid1);
                      //return new Array(ask1_0,inside1_0,bid1_0);//could be used instead of the above return statement
                      }

                      var nBidVol = null;
                      var nInsideVol = null;
                      var nAskVol = null;
                      var vVol = null;
                      var bPrimed = false;
                      var nAsk = null;
                      var nBid = null;
                      var bEdit = true;
                      var ddeup = null;
                      var ddedown = null;

                      function bidask_(xType) {
                      var vPrevVol = null;
                      var nTempAsk = null;
                      var nTempBid = null;
                      if (getCurrentBarIndex() < 0) return;

                      if (bEdit == true) {
                      var symb = getSymbol();
                      symb = symb.replace(" #F", "");
                      symb = symb.replace(" ", "_");
                      ddeup = new DDEOutput(symb + "_ask" + getInterval());
                      ddedown = new DDEOutput(symb + "_bid" + getInterval());
                      debugPrintln("Example DDE link: '=eSignal|EFS!" + symb + "_ask" + getInterval());
                      debugPrintln("Example DDE link: '=eSignal|EFS!" + symb + "_bid" + getInterval());
                      bEdit = false;
                      }
                      var nState = getBarState();
                      if (nState == BARSTATE_NEWBAR) {
                      if (xType == "Bar" || day(0) != day(-1)) {
                      nBidVol = 0;
                      nInsideVol = 0;
                      nAskVol = 0;
                      }
                      vVol = 0;
                      }

                      if (vVol != null && bPrimed == true) vPrevVol = vVol;

                      nTempAsk = getMostRecentAsk();
                      nTempBid = getMostRecentBid();
                      if (nTempAsk != null && nTempAsk != 0) nAsk = nTempAsk;
                      if (nTempBid != null && nTempBid != 0) nBid = nTempBid;

                      var vClose = close(0);
                      vVol = volume(0);

                      var vTradeVol = vVol - vPrevVol;

                      if (bPrimed == false && vVol != null) {
                      bPrimed = true;
                      return;
                      } else {
                      if (vClose <= nBid) {
                      nBidVol += vTradeVol;
                      } else if (vClose >= nAsk) {
                      nAskVol += vTradeVol;
                      } else {
                      nInsideVol += vTradeVol;
                      }
                      }
                      if (nAskVol != null) ddeup.set(nAskVol);
                      if (nBidVol != null) ddedown.set(nBidVol);

                      return new Array(nAskVol, nInsideVol, nBidVol);
                      }
                      Last edited by WilliamV; 12-06-2011, 07:25 PM.

                      Comment


                      • #12
                        Also when I change return new Array(ask1,inside1,bid1);
                        to return new Array(ask1_1,inside1_1,bid1_1);
                        the chart stops being fed the array alltogether, after the proper reload of efs.

                        Comment


                        • #13
                          My "12-06-2011 05:41 AM " post code included the incorrect code:
                          PHP Code:
                              bid1_1 bid1.getValue(0); 
                          which should have been:
                          PHP Code:
                              bid1_1 bid1.getValue(-1); 
                          to retrieve the previous value.

                          Also, the previous value retrieved [*.getValue(-1)] is not the last bid/ask for the last tick but the total bid/ask for the last bar. So "return new Array(ask1_1,inside1_1,bid1_1);" won't update the plot for the current bar with incoming data. Instead when a new bar comes in it plots the values for the cumulative bid/ask from the previous bar.

                          Also when I change return new Array(ask1,inside1,bid1);
                          to return new Array(ask1_1,inside1_1,bid1_1);
                          the chart stops being fed the array alltogether, after the proper reload of efs.
                          If you need the last bid/ask value for the current tick you need to capture it from "vTradeVol" in the conditionals for the respective cummulative "nAskVol" etc. above or below the cummulative formula in each conditional, i.e., above "nBidVol += vTradeVol;" for the last tick bid volume etc. I am assuming you're not interested in individual bid/ask values.

                          Another way to get the previous bars cummulative bid/ask values is to use the "ref()" function.

                          For the previous cummulative value of the same bar, before the current tick volume is added, I coded an example below, using a simple variable to capture the previous cumulative value (variables ending in "_1", like "nBidVol_1"). Note that these are still cumulative values but just the one before the incoming tick bid/ask is added.

                          Good resources for DDE are:





                          I'm curious what you would use the previous bid/ask value for?

                          PHP Code:
                          //http://forum.esignal.com/showthread.php?s=&threadid=36990


                          function preMain() {
                              
                          setStudyTitle("Bid/Ask Volume ");
                              
                          setCursorLabelName("Ask Vol"0);
                              
                          setCursorLabelName("Inside Vol"1);
                              
                          setCursorLabelName("Bid Vol"2);
                              
                          setDefaultBarFgColor(Color.green0);
                              
                          setDefaultBarFgColor(Color.black1);
                              
                          setDefaultBarFgColor(Color.red2);
                              
                          setDefaultBarThickness(80);
                              
                          setDefaultBarThickness(61);
                              
                          setDefaultBarThickness(42);
                              
                          setPlotType(PLOTTYPE_HISTOGRAM0);
                              
                          setPlotType(PLOTTYPE_HISTOGRAM1);
                              
                          setPlotType(PLOTTYPE_HISTOGRAM2);

                              var 
                          fp0 = new FunctionParameter("sType"FunctionParameter.STRING);
                              
                          fp0.setName("Analysis");
                              
                          fp0.addOption("Bar");
                              
                          fp0.addOption("Cumulative");
                              
                          fp0.setDefault("Bar");
                          }

                          var 
                          nBidVol null;
                          var 
                          nInsideVol null;
                          var 
                          nAskVol null;
                          var 
                          nBidVol_1 null;
                          var 
                          nInsideVol_1 null;
                          var 
                          nAskVol_1 null;
                          var 
                          vVol null;
                          var 
                          bPrimed false;
                          var 
                          nAsk null;
                          var 
                          nBid null;
                          var 
                          bEdit true;
                          var 
                          ddeup null;
                          var 
                          ddedown null;
                          var 
                          ddeInside null;
                          var 
                          ddeup_1 null;
                          var 
                          ddedown_1 null;
                          var 
                          ddeInside_1 null;

                          function 
                          main(sType) {
                              var 
                          vPrevVol null;
                              var 
                          nTempAsk null;
                              var 
                          nTempBid null;
                              if (
                          getCurrentBarIndex() < 0) return;

                              if (
                          bEdit == true) {
                                  var 
                          symb getSymbol();
                                  
                          symb symb.replace(" #F""");
                                  
                          symb symb.replace(" ""_");debugPrintln("symb; "+symb);
                                  
                          ddeup = new DDEOutput(symb "ask0_" getInterval());
                                  
                          ddedown = new DDEOutput(symb "bid0_" getInterval());
                                  
                          ddeInside = new DDEOutput(symb "Inside0_" getInterval());
                                  
                          ddeup_1 = new DDEOutput(symb "ask1_" getInterval());
                                  
                          ddedown_1 = new DDEOutput(symb "bid1_" getInterval());
                                  
                          ddeInside_1 = new DDEOutput(symb "Inside1_" getInterval());
                                  
                          debugPrintln("Example DDE link: '=eSignal|EFS!" symb "ask0_" getInterval());
                                  
                          debugPrintln("Example DDE link: '=eSignal|EFS!" symb "bid0_" getInterval());
                                  
                          debugPrintln("Example DDE link: '=eSignal|EFS!" symb "Inside0_" getInterval());
                                  
                          debugPrintln("Example DDE link: '=eSignal|EFS!" symb "ask1_" getInterval());
                                  
                          debugPrintln("Example DDE link: '=eSignal|EFS!" symb "bid1_" getInterval());
                                  
                          debugPrintln("Example DDE link: '=eSignal|EFS!" symb "Inside1_" getInterval());
                                  
                          bEdit false;
                              }
                              var 
                          nState getBarState();
                              if (
                          nState == BARSTATE_NEWBAR) {
                                  if (
                          sType == "Bar" || day(0) != day(-1)) {//resets values to 0
                                      
                          nBidVol 0;
                                      
                          nInsideVol 0;
                                      
                          nAskVol 0;
                                      
                          nBidVol_1 0;
                                      
                          nInsideVol_1 0;
                                      
                          nAskVol_1 0;
                                  }
                                  
                          vVol 0;
                              }

                              if (
                          vVol != null && bPrimed == truevPrevVol vVol;

                              
                          nTempAsk getMostRecentAsk();
                              
                          nTempBid getMostRecentBid();
                              if (
                          nTempAsk != null && nTempAsk != 0nAsk nTempAsk;
                              if (
                          nTempBid != null && nTempBid != 0nBid nTempBid;

                              var 
                          vClose close(0);
                              
                          vVol volume(0);

                              var 
                          vTradeVol vVol vPrevVol;

                              if (
                          bPrimed == false && vVol != null) {
                                  
                          bPrimed true;
                                  return;
                              } else {
                                  if (
                          vClose <= nBid) {
                          //if you need the previous single bid/ask value instead of the cummulative one
                          //just use a variable to capture the "vTradeVol" here and in the respective conditional below

                                      
                          nBidVol_1 nBidVol;
                                      
                          nBidVol += vTradeVol;
                          //for every bar each of these with "+=" adds the previous total to the incoming value and 
                          //all are reset above under the code with "BARSTATE_NEWBAR"
                                  
                          } else if (vClose >= nAsk) {
                                      
                          nAskVol_1 nAskVol;
                                      
                          nAskVol += vTradeVol;
                                  } else {
                                      
                          nInsideVol_1 nInsideVol;
                                      
                          nInsideVol += vTradeVol;
                                  }
                              }
                              if (
                          nAskVol != nullddeup.set(nAskVol);
                              if (
                          nBidVol != nullddedown.set(nBidVol);
                              if (
                          nInsideVol != nullddeInside.set(nInsideVol);
                              if (
                          nAskVol_1 != nullddeup_1.set(nAskVol_1);
                              if (
                          nBidVol_1 != nullddedown_1.set(nBidVol_1);
                              if (
                          nInsideVol_1 != nullddeInside_1.set(nInsideVol_1);
                          debugPrintln("0000::  "+nAskVol+", "+nInsideVol+", "+nBidVol);
                          debugPrintln("1111::  "+nAskVol_1+", "+nInsideVol_1+", "+nBidVol_1);

                              return new Array(
                          nAskVolnInsideVolnBidVol);

                          Wayne
                          Last edited by waynecd; 12-07-2011, 03:10 PM.

                          Comment


                          • #14
                            Waynecd,

                            It is secondary to the current value of bid and ask, but it helps me with my decisionmaking.

                            You have been an invaluable help! If for some reason you may need my help in the future, I'll do my best to provide you with the answers you may need.

                            Thanks again. Happy Holidays!! God bless.

                            Comment


                            • #15
                              Glad it helped.

                              Wayne

                              Comment

                              Working...
                              X