I have a need to produce a csv from the AA results which show a variety of
monthly stats on equity curves, or even fund or index symbols.  Things like
the total number of months the symbol was up for the month, or down for the
month, etc.
 
I produced this snippit of test code which seems to do the job ok, but I am
wondering if there is an easier and better way.  I am only showing a couple
of stats here but I have to make a whole list of monthly stats.
 
Two questions for those willing and interested in commenting:
 
1.  Is there a better more efficient way of doing this either with or
without loops?  (It seems this approach without loops would be
faster---(???) )
 
2.  My several attempts at using different time frame commands (inMonthly
for example) did not produce anything.  Can someone tell me if this is a
place to use SetTimeFrame(inMonthly) and if so, how would the code below be
modified to make it work.  I have read and reread the Help files on this,
and experimented to no avail, but obviously am missing a key piece of
understanding.
 
Here is the code snippit that works:
 
Thanks for any comments:
 
Ken
 
 
Price = C;
Mnth = Month();
Nmnth = Mnth != Ref(Mnth,-1);
LmPrice = ValueWhen(Nmnth,Price,2);
ThisMP = ValueWhen(Nmnth,Price,1);
MnGain = 100 * (ThisMP - LmPrice)/LmPrice;
Per = LastValue(Cum(1));
MarkUp = MnGain>0 AND Nmnth;
MarkDn = MnGain<0 AND Nmnth;
Up = IIf(Markup,1,0);
Dn = IIf(Markdn,1,0);
UpMnths = Sum(Up,Per);
DnMnths = Sum(Dn,Per);
 
// Set to n =1 days
Filter = 1;//Nmnth;
Col = IIf(Nmnth,colorPink,colorDefault);
AddColumn(Price,"Price",1.2,colorDefault,Col,50);
AddColumn(LmPrice,"LmPrice",1.2,colorDefault,Col,50);
AddColumn(Per,"Per",1.0);
AddColumn(Up,"Up",1.0);
AddColumn(UpMnths,"UpMnths",1.0,colorDefault,Col,70);
AddColumn(DnMnths,"DnMnths",1.0,colorDefault,Col,70);
 

Reply via email to