Previous day's OHLC indicator.

K

kmlsoni

Guest
#1
Hi,
I need formula for previous day's OHLC indicator on intraday chart as horizontal line. If you have formula for that,please post here.

Thanks,
Regard,
Kamal
 

Bulli

New Member
#2
Here it is:

MetaStock -> Tools -> Indicator Builder -> New
-> copy & paste complete formula below.


==========
Daily OHLC
==========
---8<---------------------------

{ Daily Open/High/Low/Close v3.1
For intraday charts.

Copyright 2002~2006 Jose Silva.
The grant of this license is for personal use
only - no resale or repackaging allowed.
All code remains the property of Jose Silva.
http://www.metastocktools.com }

{ User inputs }
pds:=Input("Day's OHLC: [1]Current (dynamic), [2]Previous",1,2,2);
plotOp:=Input("plot daily Open? [1]Yes, [0]No",0,1,1);
plotHi:=Input("plot daily High? [1]Yes, [0]No",0,1,1);
plotLo:=Input("plot daily Low? [1]Yes, [0]No",0,1,1);

{ Day's Start }
SOD:=DayOfMonth()<>Ref(DayOfMonth(),-1)
OR Cum(1)=2;

{ Day's Open }
dOp:=ValueWhen(pds,SOD,O);
dOp:=ValueWhen(1,dOp<>0,dOp);

{ Day's High }
Hi:=HighestSince(1,SOD,H);
dHi:=If(pds=1,Hi,ValueWhen(1,SOD,Ref(Hi,-1)));
dHi:=ValueWhen(1,dHi<>0,dHi);

{ Day's Low }
Lo:=LowestSince(1,SOD,L);
dLo:=If(pds=1,Lo,ValueWhen(1,SOD,Ref(Lo,-1)));
dLo:=ValueWhen(1,dLo<>0,dLo);

{ Day's Close }
dCl:=If(pds=1,C,
ValueWhen(1,SOD,Ref(C,-1))*(Cum(SOD)>1));
dCl:=ValueWhen(1,dCl<>0,dCl);

{ Hide OHL price plots }
dOp:=If(plotOp,dOp,dCl);
dHi:=If(plotHi,dHi,dCl);
dLo:=If(plotLo,dLo,dCl);

{ Plot on price chart }
dOp; { <- Open: Violet}
dHi; { <- High: Blue }
dLo; { <- Low: Red }
dCl; { <- Close: Green }

---8<---------------------------



Cheers,
Bulli
 
K

kmlsoni

Guest
#3
Here it is:

MetaStock -> Tools -> Indicator Builder -> New
-> copy & paste complete formula below.


==========
Daily OHLC
==========
---8<---------------------------

{ Daily Open/High/Low/Close v3.1
For intraday charts.

Copyright 2002~2006 Jose Silva.
The grant of this license is for personal use
only - no resale or repackaging allowed.
All code remains the property of Jose Silva.
http://www.metastocktools.com }

{ User inputs }
pds:=Input("Day's OHLC: [1]Current (dynamic), [2]Previous",1,2,2);
plotOp:=Input("plot daily Open? [1]Yes, [0]No",0,1,1);
plotHi:=Input("plot daily High? [1]Yes, [0]No",0,1,1);
plotLo:=Input("plot daily Low? [1]Yes, [0]No",0,1,1);

{ Day's Start }
SOD:=DayOfMonth()<>Ref(DayOfMonth(),-1)
OR Cum(1)=2;

{ Day's Open }
dOp:=ValueWhen(pds,SOD,O);
dOp:=ValueWhen(1,dOp<>0,dOp);

{ Day's High }
Hi:=HighestSince(1,SOD,H);
dHi:=If(pds=1,Hi,ValueWhen(1,SOD,Ref(Hi,-1)));
dHi:=ValueWhen(1,dHi<>0,dHi);

{ Day's Low }
Lo:=LowestSince(1,SOD,L);
dLo:=If(pds=1,Lo,ValueWhen(1,SOD,Ref(Lo,-1)));
dLo:=ValueWhen(1,dLo<>0,dLo);

{ Day's Close }
dCl:=If(pds=1,C,
ValueWhen(1,SOD,Ref(C,-1))*(Cum(SOD)>1));
dCl:=ValueWhen(1,dCl<>0,dCl);

{ Hide OHL price plots }
dOp:=If(plotOp,dOp,dCl);
dHi:=If(plotHi,dHi,dCl);
dLo:=If(plotLo,dLo,dCl);

{ Plot on price chart }
dOp; { <- Open: Violet}
dHi; { <- High: Blue }
dLo; { <- Low: Red }
dCl; { <- Close: Green }

---8<---------------------------



Cheers,
Bulli
Thanks Bulli

Regard
Kamal :clapping::clap::D:thumb: