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

Re: [amibroker] AFL help



PureBytes Links

Trading Reference Links

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___