[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RE: [amibroker] Another Code Puzzle



PureBytes Links

Trading Reference Links

Ken and Fred
Many thanks from me too.
Peter

--- In amibroker@xxxxxxxxxxxxxxx, Ken Close <ken45140@xxx> wrote:
>
> So nice.  So elegant.  So frustrating I can't see constructions 
like that.
>  
> Many thanks (again).
> 
>   _____  
> 
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] 
On Behalf
> Of ftonetti@xxx
> Sent: Thursday, August 14, 2008 2:39 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: RE: RE: [amibroker] Another Code Puzzle
> 
> 
> CurEq = Foreign("~~~Equity", "C", 1);
> 
> MaxEq = Highest(CurEq);
> 
> CurDD = IIf(CurEq < MaxEq, 100 * (MaxEq - CurEq) / MaxEq, 0);
> 
> MaxDD = Highest(CurDD);
> 
> MDDBar = MaxDD == LastValue(MaxDD) AND CurDD == MaxDD;
> 
> CDDBar = Cum(0);
> 
> CDD0 = LastValue(Highest(IIf(MDDBar == 1, BarIndex() - BarsSince
(CurDD ==
> 0), 0)));
> 
> CDDBar[CDD0] = 1;
> 
> Plot(MaxDD, "MaxDD", colorRed);
> 
> Plot(CurDD, "CurDD", colorOrange);
> 
> Plot(MDDBar, "MDDBar", colorWhite, styleHistogram | styleOwnScale |
> styleThick);
> 
> Plot(CDDBar, "CDDBar", colorBlue, styleHistogram | styleOwnScale |
> styleThick);
> 
> ----- Original Message -----
> From: Ken Close 
> Date: Thursday, August 14, 2008 2:19 pm
> Subject: RE: RE: [amibroker] Another Code Puzzle
> To: amibroker@xxxxxxxxxxxxxxx
> 
> > Yep. That's what I thought and tried. . . 
> > > > Top = BarsSince(CurDD==0)==0 AND MaxDD == Ref(MaxDD,-1) AND 
BIR;
> > 
> > Finding it "prior to" where the MaxDD occurred is the trick. It 
> > finds every
> > occurrence of the places where CurDD == 0. ValueWhen to try and 
> > get the
> > most recent occurrence of CurDD==0 seemed not to work.
> > 
> > Another hint?
> > 
> > _____ 
> > 
> > From: amibroker@xxxxxxxxxxxxxxx 
> > [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
> > Of ftonetti@xxx
> > Sent: Thursday, August 14, 2008 1:20 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: Re: RE: [amibroker] Another Code Puzzle
> > 
> > 
> > The bar you are looking for will be 
> > 
> > BarsSince(CurDD == 0) bars prior to where the MaxDD ocurred ...
> > 
> > ----- Original Message -----
> > From: Ken Close 
> > Date: Thursday, August 14, 2008 12:37 pm
> > Subject: RE: [amibroker] Another Code Puzzle
> > To: amibroker@xxxxxxxxxxxxxxx
> > 
> > > Absolutely. Thanks.
> > > 
> > > . . .now the bar associated with the CurDD==0 just preceding 
> > > the bar on
> > > which MaxDD==LastValue(MaxDD) is . . . ?
> > > 
> > > Seriously, I tried to find the bar (date) associated with the 
> > > beginning of
> > > the MaxDD but it still alludes me.
> > > 
> > > 
> > > MDD = MaxDD==LastValue(MaxDD) AND CurDD==MaxDD;
> > > MDDBar = ValueWhen(MDD,BarIndex(),1);
> > > //Top = BarsSince(CurDD==0)==0 AND AND BIR;
> > > Top2 = ValueWhen(CurDD==0,BarIndex(),1);
> > > Top3 = ValueWhen(MDD==1,BarIndex());
> > > Top = BarsSince(CurDD==0)==0 AND MaxDD == Ref(MaxDD,-1) AND BIR;
> > > Top2X = BarIndex()==Top2 AND BIR AND MaxDD != LastValue(MaxDD);
> > > 
> > > Nothing works.
> > > 
> > > _____ 
> > > 
> > > From: amibroker@xxxxxxxxxxxxxxx 
> > > [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
> > > Of ftonetti@xxx
> > > Sent: Wednesday, August 13, 2008 4:07 PM
> > > To: amibroker@xxxxxxxxxxxxxxx
> > > Subject: Re: [amibroker] Another Code Puzzle
> > > 
> > > 
> > > I assume what you'd be looking for is the bar on which MaxDD =
> > > LastValue(MaxDD) and CurDD = MaxDD ...
> > > 
> > > ----- Original Message -----
> > > From: Ken Close 
> > > Date: Wednesday, August 13, 2008 1:59 pm
> > > Subject: [amibroker] Another Code Puzzle
> > > To: amibroker@xxxxxxxxxxxxxxx
> > > 
> > > > Once again, I stumble across seemingly simple things that 
> > are 
> > > > hard (for me)
> > > > to do.
> > > > 
> > > > Task: Find the Date of the MaxDD which occurs in a price 
> > > series 
> > > > (Equity or
> > > > price).
> > > > More complex task: Find the Date when the current MaxDD 
> > > started, 
> > > > ie, the
> > > > highest price associated with the MaxDD.
> > > > 
> > > > FredT has had code for finding the MaxDD since almost from 
> > > when 
> > > > AB started.
> > > > We all have used it countless times.
> > > > Yet I can not adapt or adopt it to finding the date when the 
> > > > MaxDD occurs
> > > > much less find the Date of the highest price associated with 
> > > the 
> > > > Maxdd. 
> > > > Can anyone suggest an approach?
> > > > 
> > > > Ken
> > > > 
> > > > Code snippits:
> > > > 
> > > > 
> > > > 
> > > > 
> > > > BIR = IIf(Status("BarInRange") > 0, 1, 0);
> > > > Price = C;
> > > > MaxPrice = Highest(Price);
> > > > CurDD = IIf(BIR, 100 * (MaxPrice - Price) / MaxPrice, 0);
> > > > MaxPriceDate = IIf(BIR,ValueWhen(MaxPrice !=
> > > > Ref(MaxPrice,1),DateTime(),0),0);
> > > > MaxDD = Highest(CurDD);
> > > > RCurDD = round(CurDD * 100) / 100;
> > > > MaxDD = Highest(CurDD);
> > > > MaxDDDate = ValueWhen(MaxDD != Ref(MaxDD,-1),DateTime(),0);
> > > > 
> > > > This last line, my attempt, is not correct; it works some of 
> > > the 
> > > > time but
> > > > not with all cases.
> > > > 
> > > > 
> > > > 
> > > > 
> > > 
> > > 
> > 
> >
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/