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

Re: [amibroker] Re: Setting the start date for "Relative Performance" indicator



PureBytes Links

Trading Reference Links

Hello Alex _ I believe what you want to take advantage of is the function BarinRange as used below.
 It will get the status of the FROM to RANGE that you set in the AutoAnalyzer window, rather than
BarVisible (Ah Dimitris where are you?)   If you Explore this you'll see that BIR is
an array of 1 and 0's representing the range you want to consider.
 
Now if you're using it as an indicator you'll want BarVisible and I've also included a piece of code
that uses that approach as templates for you and others to glean code snippets.
Both attributed to the forum and right now unknown authors.  
 
Hope this helps - can't have too many good examples
JOE
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
 
BIR = IIf(Status("BarInRange") > 0, 1, 0);

CurEq = IIf(BIR, C, 0);

MaxEq = Highest(CurEq);

CurDD = IIf(BIR, 100 * (MaxEq - CurEq) / MaxEq, 0);

MaxDD = Highest(CurDD);

SqrDD = CurDD ^ 2;

CumDD = Cum(SqrDD);

FirstBar = LastValue(ValueWhen(Status("FirstBarInRange") > 0, Cum(1)));

LastBar = LastValue(ValueWhen(Status("LastBarInRange") > 0, 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 = round(BarNo / TotDays);

CAR = ValueWhen(BIR > 0, 100 * ((CurEq / Ref(CurEq, -(BarNo - 1))) ^ (1 / (BarNo / BPD / 254)) -1));

MAR = CAR / MaxDD;

UI = ValueWhen(BIR > 0, sqrt(CumDD / BarNo));

UPI = (CAR - 5.4) / UI;

Filter = BarNo == NoBars;

AddColumn(CAR, "CAR", 1.2);

AddColumn(MaxDD, "MDD", 1.2);

AddColumn(MAR, "MAR", 1.2);

AddColumn(UI, "UI", 1.2);

AddColumn(UPI, "UPI", 1.2);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

* AccuTrack as calculated by FastTrack - coded by Bill Barnard,

8/28/03 */

fnd = "ndx-x";

ind = "nyc-i";

fund = Foreign(fnd, "Close");

index = Foreign(ind, "Close");

fast = 12;

slow = 48;

RawAT = EMA((EMA(ROC(fund,1), slow) - EMA(ROC(index,1),

slow)),fast);

VisibleAT = Status("barvisible")*RawAT;

Hi = LastValue(Highest(VisibleAT));

Lo = LastValue(Lowest(VisibleAT));

multiplier = IIf(Hi > Lo, 100 / Hi, 100 / Lo);

FastTrackAT = multiplier*RawAT;

Plot(FastTrackAT, "AccuTrack", colorYellow);

PlotGrid(0);

GraphXSpace = 5;

Title = " "+Date()+" \\c42 FastTrack AccuTrack

of "+fnd+" / "+ind+

" = "+WriteVal(FastTrackAT, 1.2)+" ";

----- Original Message -----
Sent: Wednesday, June 01, 2005 6:44 AM
Subject: [amibroker] Re: Setting the start date for "Relative Performance" indicator

Thanks Stephane,

I might try that next.  In the meantime, I've fiddled around with
some of the other suggestions and come up with a slight variation
which seems to work well - code below.

This is the best solution so far, but it would still be nice
(Tomasz...) if we were able to choose the date for the first visible
bar on the left side of the chart...

Thanks all,
Alex.

-----

_SECTION_BEGIN("Relative Performance");


TickerList = ParamStr
("Tickers", "^AXJO,^AXDJ,^AXEJ,^AXFJ,^AXHJ,^AXIJ,^AXMJ,^AXNJ,^AXPJ,^A
XSJ,^AXTJ,^AXUJ,^AXXJ");


fvb = SelectedValue(C);

Plot((100 * ( C - fvb ) / fvb), Name(), colorBlack, styleThick=4 );

for( i = 0; ( symbol = StrExtract( TickerList, i ) ) !=""; i++ )
{
fc = Foreign( symbol, "C" );

fcb = SelectedValue(Foreign( symbol, "C" ));

if( ! IsNull( fc[ 0 ] ) )
{
Plot( 100 * ( fc - fcb )/ fcb, symbol, colorBrown + ( (2*i) % 15 ),
styleLine);
}
}

Plot(0,"0",colorGrey50,1|styleNoLabel|styleNoTitle);

_N(Title = "{{NAME}} - ASD - Relative Performance [%]: {{VALUES}}");
_SECTION_END();


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



--- In amibroker@xxxxxxxxxxxxxxx, "Stephane Carrasset"
<s.carrasset@xxxx> wrote:
> you can try
> barcount-selectedvalue(barindex());
> and adding setbarsrequired(10000,10000);at thye beginning of the
code
>
> stephane
>
> > Is there a way to set the start date for the "Relative
Performance"
> > Indicator?  As it is, it simply resets all securities to "0" at
the
> > far left-hand side of the screen and allows the relative
performance
> > to unfold across the screen - but there doesn't appear t obe an
easy
> > way to elect which date is the first visible date on the screen
(&
> > thus the first date of the "Relative Performance").
> >
> > Any ideas?
> >
> > Many thanks,
> > Alex.
> >
> > alexdouglas@xxxx




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 other support material please check also:
http://www.amibroker.com/support.html





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 other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links