Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
ZoomTop, without exception, the toughest part of my job is the transferral of my client's idea, from his/her mind to my own. Often this transfer process fails at no one's fault.
For this lack of communication, we can thank 6 billion distinct and very different human operating systems on this planet. It's no wonder that no one can predict the markets with 100% certainty.
Anyway, perhaps some of this code can be adapted to your needs:
[code:1:cb2af83adc]
=========================
OHLC at variable interval
=========================
---8<------------------------------
{ OHLC at variable period intervals }
{©Copyright 2005 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("End-Of-Period (EOP) bar interval",
1,2600,5);
type:=Input("EOP signal: [1]Static, [2]Dynamic",1,2,1);
plot:=Input("plot: [1]OHLC, [2]EOP signals",
1,2,1);
{ Static - count bars forward from first bar }
countForward:=Cum(1);
{ Dynamic - count bars back from last bar }
countBackward:=LastValue(Cum(1))-Cum(1)+1;
{ Choose Dynamic/Static }
count:=If(type=1,countForward,countBackward);
{ Signal at x period intervals }
signal:=count/pds=Int(count/pds);
{ OHLC values at x period intervals }
Op:=ValueWhen(1,signal,Ref(O,-pds));
Op:=ValueWhen(1,Op>0,Op);
Hi:=ValueWhen(1,signal,Ref(HHV(H,pds),-1));
Hi:=ValueWhen(1,Hi>0,Hi);
Lo:=ValueWhen(1,signal,Ref(LLV(L,pds),-1));
Lo:=ValueWhen(1,Lo>0,Lo);
Cl:=ValueWhen(1,signal,Ref(C,-1));
Cl:=ValueWhen(1,Cl>0,Cl);
{ Plot on price charts }
If(plot=1,Op,signal);
If(plot=1,Hi,signal);
If(plot=1,Lo,signal);
If(plot=1,Cl,signal)
---8<------------------------------
[/code:1:cb2af83adc]
jose '-)
|