Skip to main content

Display Bid and Ask for Amibroker (AFL)

klimpek over 15 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 2)
  • Tags:
    amibroker, realtime

Need realtime data connection active.
From amibrokerfan.com

Indicator / Formula

Copy & Paste Friendly
// Bid & Ask Example.afl
Plot(L+(H-L)/2, "Mid",colorYellow,styleDots|styleNoLine);
Plot(C, "Close",colorGreen,styleDots);
SetChartBkColor(ParamColor("Outer panel",colorBlack));

bc=BarCount-1;
Bid = GetRTData("Bid");
Ask=GetRTData("Ask");
szBid=GetRTData("BidSize");
szAsk=GetRTData("AskSize");

// Display bid & ask as text header ...
if(Bid && Ask && szBid && szAsk)
{
  baDif = abs(szBid-szAsk);
  dCol = IIf(szBid > szAsk, colorGreen,colorRed);
  bidCol = IIf(szBid > Ref(szBid,-1), colorGreen,colorRed);
  askCol = IIf(szAsk > Ref(szAsk,-1), colorGreen,colorRed);
  bStr = EncodeColor(bidCol[bc])+WriteVal(szBid,8);
  aStr = EncodeColor(askCol[bc])+WriteVal(szAsk,8);
  dStr = EncodeColor(dCol[bc])+WriteVal(baDif,8);
  baStr="\nPrice of  Bid:  "+Bid+ "  -  "+"Ask:  "+ask
  + "\nSize of    Bid: "
  + bStr
  + EncodeColor(colorWhite)  +"   -    Ask: "
  + aStr
  + "  =  "+dStr;
} else baStr="\nNo RT Data";

_N(Title=EncodeColor(colorWhite)+StrLeft(Name(),7)
 + "   " + Interval(2) + "  "
 + Date()+" GMT"
 + "      ( O-" + O + "   H-"+ H + "   L-" + L + "   C-" + C + " )"
 + baStr
);

1 comments

1. mkiran9
about 6 years ago

Hi,

Thanks for providing the code for Bid and Ask price and its size along with price plot.

I am looking for small enhancement to this, how do I get Total Bid quantity size and Total Ask Quantity size.

Appreciate your anticipation.

Thanks,
Kiran

Leave Comment

Please login here to leave a comment.