PureBytes Links
Trading Reference Links
|
This may help also, it will give you the ability to easily change
the index and indicator parameters you use.
index = ParamStr("Index", "^IXIC");
myIndex = Foreign(index, "C");
myBuy = MA(myIndex, 34) > Ref(MA(myIndex, 34), -1);
mySell = whatever your sell strategy is.
The above will give multiple buy signals. Once you develop your sell
code use something like this to give only one signal per trend:
Buy = exrem(myBuy, mySell);
Sell = exrem(mySell, mybuy);
Here is an real example that works but could be improved upon:
_SECTION_BEGIN("IndexEMA + MACD");
index = ParamStr("Index", "^RUT"); // RUT is the default index
indexC = Foreign(index, "C");
// ema - is set for a longer trend and uses the foreign C
PeriodShort = Param("Ema Short Periods", 10, 2, 20, 1);
PeriodLong = Param("Ema Long Periods", 30, 2, 100, 1);
pS = EMA(indexC , PeriodShort);
pL = EMA(indexC , PeriodLong);
upEma = IIf(pS > pL, 1, 0); // fast ema is above slow, long condition
// macd - set to intermediate trend, periods 6, 19, 9 could be used
to get in the stock faster
r1 = Param( "Macd Fast avg", 12, 2, 200, 1 );
r2 = Param( "Macd Slow avg", 26, 2, 200, 1 );
r3 = Param( "Macd Signal avg", 9, 2, 200, 1 );
myMacd = MACD(r1,r2);
mySignal = Signal(r1,r2,r3);
upMacd = IIf(myMacd > mySignal, 1, 0);
myBuy = upEma AND upMacd;
myShort = !upEma AND !upMacd;
Buy = Cover = ExRem(myBuy, myShort);
Short = Sell = ExRem(myShort, myBuy);
Plot( Buy * C, "EMA(" + NumToStr(PeriodShort,1.0) + "," + NumToStr
(PeriodLong,1.0) +
") MACD(" + NumToStr(r1,1.0) + "," + NumToStr(r2,1.0) + ","
+ NumToStr(r3,1.0) +
") - myBuy ", colorGreen); // a positive spike that
indicates a buy or cover trade.
Plot( -Short * C , "myShort ", colorRed);
// exploration
Filter = Buy OR Short;
AddColumn(Close, "Close", 1.2);
AddColumn(Buy, "Buy", 1.0);
AddColumn(Short, "Short",1.0);
_SECTION_END();
Cheers,
Barry
--- In amibroker@xxxxxxxxxxxxxxx, lapilia <lapilia@xxxx> wrote:
>
> Hi Eric
>
> Try this and let me know the result :
>
> IXIC = Foreign("^IXIC", "C");
>
> MA(IXIC, 34) > Ref(MA(IXIC, 34), -1);
>
> Claude Marc-Aurčle
>
>
>
>
>
> ----- Original Message -----
> From: "eric paradis" <thechemistrybetweenus@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Sunday, October 23, 2005 12:11 PM
> Subject: Re: [amibroker] comparing stock price to an index
>
>
> > My code is from the other forum... I have a problem in
> > the backtest mode saying "Error 5 Argument 2 has
> > incorrect type( the function expects different
> > argument type here)
> >
> > ForeignTrend = MA(Foreign("^IXIC", C), 34);
> > TrendDetect = ForeignTrend > Ref(ForeignTrend, -1);
> >
> > Buy = TrendDetect AND rules.....
> >
> > Any suggestions?
> >
> > --- eric paradis <thechemistrybetweenus@xxxx>
> > wrote:
> >
> >> Im trying to compare the price of an index so that I
> >> can go long or short on a stock. Is there a formula
> >> that does this in AFL or sample system code in the
> >> amibroker forum?
> >>
> >> Thanks,
> >>
> >> Eric
> >>
> >> --- eric paradis <thechemistrybetweenus@xxxx>
> >> wrote:
> >>
> >> > Barry,
> >> >
> >> > Thanks for your reply. I have tried to Add Linker
> >> > under the window menu. It does not solve my
> >> problem.
> >> > My price info and bar info is still missing in all
> >> > the
> >> > panes. Im considering that my template is either
> >> > missing or corrupted. Is there such thing as a
> >> price
> >> > template or a panel with the relevant data.
> >> Possibly
> >> > you could attach the file and send to me?
> >> Otherwise
> >> > I
> >> > might have to take this up with Thomas J.
> >> >
> >> > Thanks,
> >> >
> >> > Eric
> >> >
> >> > --- Barry Scarborough <razzbarry@xxxx>
> >> > wrote:
> >> >
> >> > > I have had a similar problem. Somehow AB lost
> >> the
> >> > > link to my
> >> > > symbols. In Charts I could see the formulas but
> >> AB
> >> > > did not know they
> >> > > were there. But in my case they failed on every
> >> > > sheet.
> >> > >
> >> > > First you might try and edit the failing pane.
> >> If
> >> > > that does not work
> >> > > add the price chart to the sheet using insert
> >> > > linked. You have to
> >> > > have at least one pane on the sheet so you can
> >> not
> >> > > delete them all.
> >> > > Then delete all the other panes on that sheet.
> >> > Then
> >> > > start adding the
> >> > > panes (indicators) you had on the sheet and see
> >> if
> >> > > problem recurs.
> >> > > If so edit the indicator and use verify syntax
> >> to
> >> > > see if you can
> >> > > find the problem that way.
> >> > >
> >> > > Barry
> >> > >
> >> > > --- In amibroker@xxxxxxxxxxxxxxx, eric paradis
> >> > > <thechemistrybetweenus@xxxx> wrote:
> >> > > >
> >> > > >
> >> > > > I seem to have a problem on my panes where the
> >> > > data
> >> > > > does not show up. I have reinstalled over
> >> > > Amibroker
> >> > > > without luck. Oddly all the other indicators
> >> > work
> >> > > in
> >> > > > the backgroun after sheet 1. Sheet 1 may be
> >> > > missing an
> >> > > > indicator, but it seems I can not add it once
> >> > Its
> >> > > > taken off. I can not add a new pane and have
> >> the
> >> > > > problem go away. Apparently its an indicator
> >> > that
> >> > > is
> >> > > > necessary to view the data. Any ideas or
> >> > > suggestions
> >> > > > how I can fix this?
> >> > > >
> >> > > > Thanks,
> >> > > >
> >> > > > Eric
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > __________________________________
> >> > > > Yahoo! Mail - PC Magazine Editors' Choice 2005
> >>
> >> > > > http://mail.yahoo.com
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > >
> >> > >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > __________________________________
> >> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> >> > http://mail.yahoo.com
> >> >
> >>
> >>
> >> __________________________________________________
> >> Do You Yahoo!?
> >> Tired of spam? Yahoo! Mail has the best spam
> >> protection around
> >> http://mail.yahoo.com
> >>
> >
> >
> >
> >
> >
> > __________________________________
> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > http://mail.yahoo.com
> >
> >
> >
> > 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
> >
> >
> >
> >
> >
> >
> >
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Try Online Currency Trading with GFT. Free 50K Demo. Trade
24 Hours. Commission-Free.
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~->
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|