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

[amibroker] Re: AFL Median() help



PureBytes Links

Trading Reference Links


Keith,

Thanks for your help and interest, I'll give it a try but I
think the problem is how to use the event numbers and conditions
for the Period part of Median() Function.  If I use the number of 
Bars for Period than it works for all Bars.  I only want the event 
bars to be used in Period.

My coding abilities is limited.

Thanks
Art F


--- In amibroker@xxxxxxxxxxxxxxx, Keith McCombs <kmccombs@xxx> wrote:
>
> Art --
> I haven't taken a very hard look at the entire program.  However, 
first 
> off, rather than:
> "IIf(event,day1profit=(Ref(C,1)-C)/C*100,Null);"
> I believe it should be:
> "day1profit = IIf(event,(Ref(C,1)-C)/C*100,Null);"
> and, of coarse, similar for the other two IIf() statements.
> 
> Also, you might take a very close look at your results, to make 
sure 
> that Median() handles Null as you expect.  I have never used Median
() 
> and the Help in AB isn't specific on this -- so I don't know.
> -- Keith
> 
> aff392 wrote:
> >
> > Can anyone help
> >
> > I'm trying to find the median profit after a number of event 
occur
> > but am having trouble with Median(array,period) function.
> >
> > If I copy the profit results from the exploration to Excel I can 
use
> > the Median function in Excel but would like to plot it on my 
price
> > chart from within AFL.
> >
> > Any help or direction would be appreciated.
> > Art F
> >
> > //CODE:
> > Plot( C, "Price", colorBlack,128 );
> > MA40=MA(C,40);
> > event=Cross(C,MA40);
> > eventnum = LastValue( Cum( event) );
> >
> > IIf(event,day1profit=(Ref(C,1)-C)/C*100,Null);
> > IIf(event,day2profit=(Ref(C,2)-C)/C*100,Null);
> > IIf(event,day3profit=(Ref(C,3)-C)/C*100,Null);
> >
> > day1profitMedian=Median(day1profit,eventnum );
> > day2profitMedian=Median(day2profit,eventnum );
> > day3profitMedian=Median(day3profit,eventnum );
> >
> > Filter=event;
> > AddColumn(eventnum ,"Number of Events",1.0);
> > AddColumn(day1profit,"1st day P/L",1.2);
> > AddColumn(day2profit,"2nd day P/L",1.2);
> > AddColumn(day3profit,"3rd day P/L",1.2);
> >
> > Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %
g,
> > Lo %g, Close %g", O, H, L,
> >
> > C)+EncodeColor(colorViolet )+
> > "\n 40 MA "+" Number of Events ="+eventnum ;
> > Title=Title+
> > " Median 1st day P/L = "+NumToStr(day1profitMedian,1.2)+
> > " Median 2nd day P/L = "+NumToStr(day2profitMedian,1.2)+
> > " Median 3rd day P/L = "+NumToStr(day3profitMedian,1.2);
> > Plot (MA40,"40 DMA",colorViolet,styleThick ,1);
> > PlotShapes( event * shapeCircle , colorGreen ,0, High, 25 );
> >
> >
>



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

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/