Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

_SECTION_BEGIN("dspascal");

SetBarsRequired(sbrAll);
Newday=Day()!=Ref(Day(),-1);
Show=ParamToggle("Show Lot Trend ?","No|Yes",0);
Show1=ParamToggle("Show Hi/Lo NetVol ?","No|Yes",0);
Show2=ParamToggle("Show OBV Avg ?","No|Yes",0);
Show3=ParamToggle("Show History ?","No|Yes",0);
FS=Param("History Font",10,5,14,1);
Avpe=Param("Number Of Lots",50,1,5000,1);
FB=ParamToggle("Ignore First Bar?","No|Yes",0);
Lot =Param("LOT Size Of The Trade",50,1,5000,1);
AVE=Param("OBV Average Periods",3,1,10,1);
Hou=Param("Start Time In Hour",9,9,23,1);
Minu=Param("Start Time In Minutes",15,0,55,1);
SEC1=Param("Start Time In Seconds",0,0,59,1);
Hou1=Param("End Time In Hour",9,9,23,1);
Minu1=Param("End Time In Minutes",45,0,55,1);
SEC2=Param("End Time In Seconds",0,0,59,1);
mytime = TimeNum();
PWAD=0;
PrevObv=0;
Hi=Max(H,Ref(C,-1));
Lo=Min(L,Ref(C,-1));
TimeFrameSet(0);
for(i=0;i<BarCount;i++)
{
if(i==0)
PWAD[i]=V[i]/Lot;
if(i>0 AND C[i]>C[i-1])
PWAD[i]=(V[i])/Lot+PWAD[i-1];
if(i>0 AND C[i]<C[i-1])
PWAD[i]=PWAD[i-1]-(V[i])/Lot;

if(i>0 AND C[i]==C[i-1])


PWAD[i]=PWAD[i-1];
if(i>0 AND Newday[i]==0 AND FB==1)
PWAD[i]=PWAD[i-1];
}
TimeFrameRestore();
Netvol=round(PWAD);
Up=netvol+avpe;
Dn=netvol-avpe;
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;
for (i = 1; i <BarCount; i++) {
TrendUp[i] = Null;
TrendDown[i] = Null;
trend[i]=1;
if (netvol[i]>Up[i-1]) {
trend[i]=1;
if (trend[i-1] == -1) changeOfTrend = 1;
}
else if (netvol[i]<Dn[i-1]) {
trend[i]=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend[i]=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}
if (trend[i]<0 && trend[i-1]>0) {
flag=1;
}
else {
flag=0;
}
if (trend[i]>0 && trend[i-1]<0) {

flagh=1;
}
else {
flagh=0;
}
if (trend[i]>0 && Dn[i]<Dn[i-1]){
Dn[i]=Dn[i-1];
}
if (trend[i]<0 && Up[i]>Up[i-1])
{ Up[i]=Up[i-1];
}
if (flag==1)
{ Up[i]=netvol[i]+avpe;;
}
if (flagh==1)
{ Dn[i]=netvol[i]-avpe;;
}
if (trend[i]==1) {
TrendUp[i]=Dn[i];
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=Up[i];
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}
TrendSL=IIf(trend==1,TrendUp,TrendDown);
Col=IIf(netvol>TrendSL,colorBlue,IIf(netvol<TrendSL,colorRed,colorBrown));
for(i=0;i<BarCount;i++)
{
if(i==0)
{
PrevOBV[i]=Netvol[i];
}
if(i>0 AND Newday[i]==1)
{
PrevOBV[i]=NetVol[i-1];
}
if(i>0 AND Newday[i]!=1)
{
PrevOBV[i]=PrevOBV[i-1];
}
}
k=1;
y=0;

x=0;
while(k<Ave+1)
{
y=ValueWhen(newday==1,prevobv,k);
x=x+y;
k=k+1;
}
a=1;
b=0;
Cc=0;
while(a<3)
{
b=ValueWhen(newday==1,prevobv,a);
Cc=Cc+b;
a=a+1;
}
Var1=ValueWhen(mytime==Hou*10000+Minu*100+SEC1,Netvol,1);
Var2=ValueWhen(mytime==Hou*10000+Minu*100+SEC1,NetVol,1);
for(i=1;i<BarCount;i++)
{
if( mytime[i]>Hou*10000+Minu*100+SEC1 AND mytime[i]<=Hou1*10000+Minu1*100+SEC2)
Var1[i]=Max(NetVol[i],Var1[i-1]);
if( mytime[i]>Hou*10000+Minu*100+SEC1 AND mytime[i]<=Hou1*10000+Minu1*100+SEC2)
Var2[i]=Min(Netvol[i],Var2[i-1]);
if(mytime[i]>Hou1*10000+Minu1*100+SEC2 OR mytime[i]<Hou*10000+Minu*100+SEC1)
Var1[i]=Var1[i-1];
if(mytime[i]>Hou1*10000+Minu1*100+SEC2 OR mytime[i]<Hou*10000+Minu*100+SEC1)
Var2[i]=Var2[i-1];
}
Plot(Var1,"HI",colorRed,styleLine|styleThick|styleNoTitle);
Plot(Var2,"LO",colorYellow,styleLine|styleThick|styleNoTitle);
Plot((Var1+Var2)/2,"MID",colorBlue,styleLine|styleThick|styleNoTitle);
Plot((NetVol),"NetVol",colorGreen,styleLine|styleThick);
Plot(TrendSL,""+Avpe+" Lot Trend",Col,IIf(show==1,styleLine,styleNoLine|styleNoT
itle|styleNoLabel)|styleThick);
Plot(PrevOBV,"Prev On Bal Vol",colorDarkRed,styleLine|styleThick);
if(show1==1)
{

Plot(HighestSince(newday==1,Netvol,1),"Highest NetVol In Day",colorIndigo,styleL


ine|styleThick);
Plot(LowestSince(newday==1,Netvol,1),"Lowest NetVol In Day",colorOrange,styleLin
e|styleThick);
}
if(show2==1)
{
Plot((x/ave),"" +AVE+" Period OBV Avg",colorBlack,styleLine|styleThick);
Plot(((Cc+Netvol)/3)," Spl OBV Avg",colorViolet,styleLine|styleThick);
}
GfxTextOut(""+(HighestSince(newday==1,Netvol,1)-PrevOBV)+"",875,30);
GfxTextOut(""+(LowestSince(newday==1,Netvol,1)-PrevOBV)+"",875,250);
GfxTextOut(""+(Netvol-PrevOBV)+"",875,130);
GfxTextOut(NumToStr((TimeFrameGetPrice("V",inDaily,-1))/Lot,1.0),500,250);
GfxTextOut(NumToStr((TimeFrameGetPrice("V",inDaily,0)/Lot),1.0),650,250);
if(Show3==1)
{
GfxSelectFont("Tahoma", FS, 500 );
GfxSelectSolidBrush(colorGreen);
GfxSetTextColor(colorWhite);
GfxRoundRect(20,20,450,225,8,8);
Hinet=Highest(Netvol);
Lonet=Lowest(Netvol);
Hicl=Highest(C);
Locl=Lowest(C);
Clpr=ValueWhen(Netvol==Hinet,C,1);
Clpr1=ValueWhen(Netvol==Lonet,C,1);
d1=ValueWhen(Netvol==Hinet,Day(),1);
m1=ValueWhen(Netvol==Hinet,Month(),1);
y1=ValueWhen(Netvol==Hinet,Year(),1);

d2=ValueWhen(Netvol==Lonet,Day(),1);
m2=ValueWhen(Netvol==Lonet,Month(),1);
y2=ValueWhen(Netvol==Lonet,Year(),1);
d3=ValueWhen(C==Hicl,Day(),1);
m3=ValueWhen(C==Hicl,Month(),1);
y3=ValueWhen(C==Hicl,Year(),1);
Hinetvol=ValueWhen(C==Hicl,Netvol,1);
d4=ValueWhen(C==Locl,Day(),1);
m4=ValueWhen(C==Locl,Month(),1);
y4=ValueWhen(C==Locl,Year(),1);
Lonetvol=ValueWhen(C==Locl,Netvol,1);
GfxSetBkMode(1);
GfxTextOut("Highest NetVol Of Contract = "+NumToStr(Hinet,1.0)+" --- "+NumToSt
r(d1,1.0)+"/"+NumToStr(m1,1.0)+"/"+NumToStr(y1,1.0,False),25,25);
GfxTextOut("Close Price At The Time = "+NumToStr(Clpr,1.2),25,50);
GfxTextOut("Lowest NetVol Of Contract = "+NumToStr(Lonet,1.0)+" --- "+NumToStr
(d2,1.0)+"/"+NumToStr(m2,1.0)+"/"+NumToStr(y2,1.0,False),25,75);
GfxTextOut("Close Price At The Time = "+NumToStr(Clpr1,1.2),25,100);
GfxTextOut("Highest Close = "+NumToStr(Hicl,1.2)+" --- "+NumToStr(d3,1.0)+"/"+
NumToStr(m3,1.0)+"/"+NumToStr(y3,1.0,False),25,125);
GfxTextOut("NetVol At Highest Close = "+NumToStr(Hinetvol,1.0),25,150);
GfxTextOut("Lowest Close = "+NumToStr(Locl,1.2)+" --- "+NumToStr(d4,1.0)+"/"+N
umToStr(m4,1.0)+"/"+NumToStr(y4,1.0,False),25,175);
GfxTextOut("NetVol At Lowest Close = "+NumToStr(Lonetvol,1.0),25,200);
}
//Plot(0,"",colorGold,styleLine|styleThick);
_SECTION_END();

You might also like