Announcement

Collapse
No announcement yet.

BidAskVolume.efs

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

  • BidAskVolume.efs

    I can’t find it anymore but there was a BidAsk2.efs awhile back that plotted the bid and ask on the price chart. The box would move up and down and change color as the bid and ask changed. I’ve been using this and after seeing some of your recent additions like this one and the BidAskSize I thought it would be nice to combine them. However, I had trouble combining a price study with a non price study in the same efs. Also, I didn’t see a way to change the size of the box in the drawTextRelative command. And just drawing a thick line looked rather strange. Could you combine that BidAsk.efs study with this BidAskVolume study? Also, change the way the BidAsk on the price chart works so that the box changes size based on the size of the bid and ask.

  • #2
    BidAsk3

    Here's the first part:

    /**************************************************
    Provided By : eSignal. (c) Copyright 2003

    Version 3 modified by PJS909

    07/30/2003 added Bid/Ask Size

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


    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Bid/Ask ");
    setShowCursorLabel(false);
    }

    var b = null;
    var b1 = null;
    var a = null;
    var a1 = null;
    var aColor = Color.grey;
    var bColor = Color.grey;

    var nTotSize=0;
    var nBidSize=0;
    var nAskSize=0;
    var nAskHt=0;
    var nBidHt=0;
    var x=0;
    var nH=0;
    var nL=0;
    var vTime=0;
    var vFirstIndex=0;
    var GR=Color.RGB(196, 255, 196); //light green
    var RD=Color.RGB(255, 196, 196); //light red
    var LG=Color.RGB(224, 224, 224); //light grey
    var bHc=LG;
    var aHc=LG;
    var nPrevAskSize=0;
    var nPrevBidSize=0;

    function main() {
    if (getBuildNumber() <608 ) {
    drawTextRelative(-5, close(), " Must upgrade to a build number of 608 or higher. ",
    Color.black, Color.red, Text.BOLD | Text.FRAME | Text.RELATIVETOTOP |
    Text.ONTOP | Text.RIGHT, null, 14, "build error");
    return;
    }
    vTime = getValue("Time");
    if (vTime != null) {
    vFirstIndex = Math.abs( getFirstBarIndexOfDay( vTime ) );
    }

    nH=high();
    nL=low();
    //find the highest-high and lowest-low for last 100 bars
    for (x=0; x<=vFirstIndex; x++) {
    nH = Math.max( high(-x), nH );
    nL = Math.min( low(-x), nL );
    }
    // set scale to price range
    nScale = nH-nL;

    b1 = b;
    a1 = a;
    nAskSize = getMostRecentAskSize();
    nBidSize = getMostRecentBidSize();
    nTotSize = nAskSize + nBidSize;
    nAskHt = nAskSize / nTotSize * nScale;
    nBidHt = nScale - nAskHt;
    nPrevAskSize=nAskSize;
    nPrevBidSize=nBidSize;

    if (nBidSize==null) nBidSize=nPrevBidSize;
    if (nBidSize>nPrevBidSize) {
    bHc=GR;
    } else if (nBidSize<nPrevBidSize) {
    bHc=RD;
    } else if (nBidSize==nPrevBidSize) {
    bHc=LG;
    }
    if (nAskSize==null) nAskSize=nPrevAskSize;
    if (nAskSize>nPrevAskSize) {
    aHc=GR;
    } else if (nAskSize<nPrevAskSize) {
    aHc=RD;
    } else if (nAskSize==nPrevAskSize) {
    aHc=LG;
    }


    b = getMostRecentBid();
    if (b == null) b = b1;
    if (b > b1) {
    bColor = Color.lime;
    } else if (b < b1) {
    bColor = Color.red;
    }
    b *= 10000
    b = Math.round(b);
    b /=10000;
    //drawShapeRelative(2, b, Shape.CIRCLE, null, bColor, Shape.ONTOP, "bid");
    drawLineRelative(2, b, 2, b-nBidHt, PS_SOLID, 10, bHc, "bid line");
    drawTextRelative(3, b, " Bid: " + b + " ", Color.black, bColor, Text.BOLD |
    Text.FRAME | Text.TOP | Text.ONTOP, null, 10, "bid text");
    drawTextRelative(3, b-(.1*nScale), " Size: " + nBidSize + " ", Color.black, bHc, Text.BOLD |
    Text.FRAME | Text.TOP | Text.ONTOP, null, 10, "bid size");

    a = getMostRecentAsk();
    if (a == null) a = a1;
    if (a > a1) {
    aColor = Color.lime;
    } else if (a < a1) {
    aColor = Color.red;
    }
    a *= 10000
    a = Math.round(a);
    a /=10000;
    //drawShapeRelative(2, a, Shape.CIRCLE, null, aColor, Shape.ONTOP, "ask");
    drawLineRelative(2, a, 2,a+nAskHt, PS_SOLID, 10, aHc, "ask line");
    drawTextRelative(3, a, " Ask: " + a + " ", Color.black, aColor, Text.BOLD |
    Text.FRAME | Text.BOTTOM | Text.ONTOP, null, 10, "ask text");
    drawTextRelative(3, a+(.1*nScale), " Size: " + nAskSize + " ", Color.black, aHc, Text.BOLD |
    Text.FRAME | Text.BOTTOM | Text.ONTOP, null, 10, "ask size");

    return;
    }

    Comment

    Working...
    X