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

[amibroker] Re: The Watered Down Semi-Interesting System



PureBytes Links

Trading Reference Links

Sid,

That should not be necessary because that's the first thing in the 
Equity Line indicator (See Below).  The code below also includes the 
later thought of ANN%

/* */
//--equity-plot-- do not remove this line

MaxGraph    = 10;
GraphZOrder =  1;
GraphXSpace = 20;
GraphYSpace = 10;

BIR      = IIf(Status("BarInRange") > 0, 1, 0);

BarEq    = Equity(1);
CurEq    = Equity();
MaxEq    = Highest(CurEq);
FlatEq   = IIf(BIR, BarsSince(MaxEq > Ref(MaxEq,-1)),0);
MaxFlat  = Highest(FlatEq);
LMaxFlat = LastValue(MaxFlat) * (1 + GraphYSpace / 100);
LogEq    = log10(CurEq);

CurDD    = IIf(BIR, 100 * (MaxEq - CurEq) / MaxEq, 0);
MaxDD    = Highest(CurDD);
LMaxDD   = LastValue(MaxDD) * (1 + GraphYSpace / 100);
CumDD    = Cum(CurDD);

FirstBar = ValueWhen(ExRem(Buy OR Short, 0), Cum(1));
LastBar  = LastValue(ValueWhen(Status("LastBarInRange") > 0, Cum(1)));
TotBars  = LastValue(Cum(1));
BarNo    = ValueWhen(BIR > 0, Cum(1) - FirstBar + 1);
NoBars   = LastValue(BarNo);

Dates    = DateNum();
Days     = ValueWhen(BIR > 0, IIf(Dates != Ref(Dates,-1), 1, 0));
TotDays  = Cum(Days);
BPD      = BarNo / TotDays;

CAR      = ValueWhen(BIR > 0, 100 * ((CurEq / Ref(CurEq, -(BarNo - 
1))) ^ (1 / (BarNo / BPD / 252)) -1));
Ann      = ValueWhen(BIR > 0, 100 * ((CurEq / Ref(CurEq, -(252 * 
BPD)) - 1)));
MAR      = ValueWhen(BIR > 0, CAR / MaxDD);
UI       = ValueWhen(BIR > 0, sqrt(CumDD / BarNo));
UPI      = (CAR - 5.4) / UI;
TPI      = UPI / MaxDD;

bb0      = LastValue(LinRegIntercept(Ref(LogEq, -(TotBars - 
LastBar)), NoBars));
mm       = LastValue(LinRegSlope(Ref(LogEq, -(TotBars - LastBar)), 
NoBars));
yy       = mm * BarNo + bb0;

BarsCum  = ValueWhen(BIR > 0, Cum(BarNo));
AvgBar   = LastValue(BarsCum) / NoBars;
SRDevSQ  = ValueWhen(BIR > 0, sqrt(Cum((BarNo - AvgBar) ^ 2)));
ErrEq    = LastValue(StdErr(Ref(logEq, -(TotBars - LastBar)), 
NoBars));
KRatio   = ValueWhen(BIR > 0, mm * SRDevSQ / ErrEq / sqrt(NoBars));

TradeEq  = IIf(Sell, (BarEq - ValueWhen(Buy, BarEq)) / ValueWhen(Buy, 
BarEq), 0) +
           IIf(Cover, (BarEq - ValueWhen(Short, BarEq)) / ValueWhen
(Short, BarEq), 0);
PosEq    = Cum(IIf(TradeEq > 0, TradeEq, 0));
NegEq    = Cum(IIf(TradeEq < 0, TradeEq, 0));
PosTrade = Cum(TradeEq > 0);
NegTrade = Cum(TradeEq < 0);
AvgPos   = PosEq / PosTrade;
AvgNeg   = NegEq / NegTrade;
PosPct   = PosTrade / (PosTrade + NegTrade);
Expect   = (1 + AvgPos / abs(AvgNeg)) * PosPct - 1;

Plot(IIf(BarNo > 0, CAR,    -1e10), "CAR%",  colorBrightGreen, 
styleNoLine | styleNoLabel);
Plot(IIf(BarNo > 0, Ann,    -1e10), "Ann%",  colorBrightGreen, 
styleNoLine | styleNoLabel);

Plot(IIf(BarNo > 0, -CurDD, -1e10), "CDD%",  colorRed,         
styleOwnScale | styleHistogram, -LMaxDD, LMaxDD);
Plot(IIf(BarNo > 0, -MaxDD, -1e10), "MDD%",  colorDarkRed,     
styleOwnScale,                  -LMaxDD, LMaxDD);

Plot(IIf(BarNo > 0, MAR,    -1e10), "MAR",   colorBrightGreen, 
styleNoLine | styleNoLabel);

Plot(IIf(BarNo > 0, UI,     -1e10), "UI",    colorYellow,      
styleNoLine | styleNoLabel);
//Plot(IIf(BarNo > 0, UPI,    -1e10), "UPI",   colorGreen,       
styleNoLine | styleNoLabel);
//Plot(IIf(BarNo > 0, TPI,    -1e10), "TPI",   colorGreen,       
styleNoLine);
//Plot(IIf(BarNo > 0, Expect, -1e10), "Exp",   colorGreen,       
styleNoLine);
//Plot(IIf(BarNo > 0, KRatio, -1e10), "KRatio",colorGreen,       
styleNoLine | styleNoLabel);

Plot(IIf(BarNo > 0, FlatEq, -1e10), "CF",    colorYellow,      
styleOwnScale | styleHistogram, -LMaxFlat, LMaxFlat);
Plot(IIf(BarNo > 0, MaxFlat,-1e10), "MF",    colorDarkYellow,  
styleOwnScale,                  -LMaxFlat, LMaxFlat);

Plot(IIf(BarNo > 0, yy,     -1e10), "LinReg",colorBlue,        
styleThick | styleOwnScale | styleNoLabel);
                                                                      
                                     

--- In amibroker@xxxxxxxxxxxxxxx, Sidney Kaiser <s9kaiser@xxxx> wrote:
> At 08:04 PM 02/20/2003 -0500, you wrote:
> 
> >Fred,
> >
> >I get an error in the "FirstBar = ValueWhen(ExRem(Buy OR Short, 
0), 
> >Cum(1));" at the OR location....
> >
> >Can you provide assistance
> 
> Not Fred, but maybe I can help.  That is the error message I got 
when the 
> AA system results were not communicating with the indicator 
module.  Check 
> to see that you have   /*   at the bottom of the AA system script.  
That 
> seems to enable the link between the tester and the indicator code.
> 
> Sid
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.455 / Virus Database: 255 - Release Date: 02/13/2003


Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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