PureBytes Links
Trading Reference Links
|
A shorter code, but it works (varsågod).
Beware of linewrap.
x=Param("Days",2,2,5);
y=Cum(1)%x==0;
Ox=IIf(y,Ref(O,-(x-1)),Null);
Hx=IIf(y,HHV(H,x),Null);
Lx=IIf(y,LLV(L,x),Null);
Cx=IIf(y,C,Null);
Vx=Sum(V,x);
Change=100*(Cx-Ref(C,-x))/Ref(C,-x);
PlotOHLC(Ox,Hx,Lx,Cx,"",colorBlack,styleCandle);
GraphXSpace=3;
Title=WriteIf(!IsNull(Cx),Name()+" "+WriteVal(x,1.0)+"-day
bars "+" Open "+WriteVal(Ox,1.2)+", Hi "+WriteVal(Hx,1.2)+",
Lo"+WriteVal(Lx,1.2)+", Close "+WriteVal(Cx,1.2)+" ("+WriteVal
(Change,1.1)+"%) "+" Volume "+WriteVal(Vx,1.0),Name()+" "+WriteVal
(x,1.0)+"-Day bars "+" {EMPTY}");
/Johan :)
--- In amibroker@xxxxxxxxxxxxxxx, "Johan" <epostens@xxxx> wrote:
> Hi! Thanks for your help! So much? :/
>
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "theoldchartreader"
> <theoldchartreader@xxxx> wrote:
> > Hi,
> > Yes you can do it, just change the factor to 2.
> >
> > // compress price time series by a given factor
> > // e.g. 5 into 1 is like weekly view
> > // by Junya Ho (JUNYAdotHO@xxxxxxxxxxxxxxxxxxx)
> > barnum = Cum(1);
> > numbars = LastValue(barnum);
> > factor = 3; // compress FACTOR bars into 1
> >
> > // number of compressed bars
> > numcbars = ceil(numbars / factor);
> >
> > delta = numbars - barnum;
> >
> > factorbeginidx = - factor * delta - factor + 1 + delta;
> > factorendidx = - factor * delta + delta;
> >
> > newo = IIf(barnum < numbars - numcbars, 0, Ref(O,
factorbeginidx));
> > newh = IIf(barnum < numbars - numcbars, 0, Ref(HHV(H, factor),
> > factorendidx));
> > newl = IIf(barnum < numbars - numcbars, 0, Ref(LLV(L, factor),
> > factorendidx));
> > newc = IIf(barnum < numbars - numcbars, 0, Ref(C, factorendidx));
> >
> > Daystart_str = WriteVal(Ref(Year(), factorbeginidx), 1.0) + "-" +
> > WriteVal(Ref(Month(), factorbeginidx), 1.0) + "-" + WriteVal(Ref
(Day
> > (),
> > factorbeginidx), 1.0);
> >
> > Dayend_str = WriteVal(Ref(Year(), factorendidx), 1.0) + "-" +
> > WriteVal(Ref(Month(), factorendidx), 1.0) + "-" + WriteVal(Ref
(Day
> (),
> > factorendidx), 1.0);
> >
> >
> > PlotOHLC(newo, newh, newl, newc, WriteVal(factor, 1.0) + "-
period
> > price", 17,styleBar);
> >
> > Title = WriteVal(factor, 1.0) + "-period candlesticks, O:" +
> WriteVal
> > (newo) +
> > ", H:" + WriteVal(newh) + ", L:" + WriteVal(newl) + ", C:" +
> > WriteVal(newc)
> > + ", from: " + Daystart_str + ", to: " + Dayend_str;
> >
> >
> >
> >
> > good luck,
> > Dennis
> >
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "Johan" <epostens@xxxx> wrote:
> > > Is it possible to have bars that shows for example 2 daily
bars
> in
> > > one? Just like weekly is five..
> > >
> > > Thank you
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|