// ===================================================================
// PZT BA PRESSURE Indicator (Version 2.0a)
// Bid/Ask Ratio Analyzer
// Coded by: Lee Leibfarth, 2006
// _WWW.POWEZONETRADING.COM
// ===================================================================
//
// version 2.0a
// modified by TAMS
// date: 20090402
// description: added up/down color scheme based on previous bar
//
inputs:
Color_1_or_2(2),
Period(20),
UpColor(green),
DownColor(red);
variables:
MyVol(0),
Color(yellow),
SmoothedBA(0),
Length(squareroot(Period)),
intrabarpersist MyCurrentBar(0),
intrabarpersist VolumeAtBid(0),
intrabarpersist VolumeAtAsk(0),
intrabarpersist BAVolRatio(0),
intrabarpersist VolTmp(0);
if LastBarOnChart and BarStatus(1) <> 2 then begin
MyVol = Iff(BarType < 2, Ticks, Volume);
if CurrentBar > MyCurrentBar then begin
VolumeAtBid = 0;
VolumeAtAsk = 0;
BAVolRatio = 0;
VolTmp = 0;
MyCurrentBar = CurrentBar;
end;
if InsideBid < InsideAsk then begin
if Close <= InsideBid then
VolumeAtBid = VolumeAtBid + MyVol - VolTmp
else if Close >= InsideAsk then
VolumeAtAsk = VolumeAtAsk + MyVol - VolTmp ;
end;
if VolumeAtBid > 0 and VolumeAtAsk > 0 then BAVolRatio = Log( VolumeAtAsk / VolumeAtBid );
VolTmp = MyVol ;
end ;
SmoothedBA = xaverage(xaverage(BAvolratio, Length), Length);
if Color_1_or_2 = 1 then
begin
if SmoothedBA <= 0 then color = DownColor else color = UpColor;
end
else
begin
if SmoothedBA < SmoothedBA[1] then color = DownColor else color = UpColor;
end;
plot1(SmoothedBA, "Pressure", color);