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 );