Thank you Mike. This is what I wrote but when I do backtest, nothing
shows up. Is this correct?
x=Foreign("X","C");
YourSystemEntrySignal = Cross( EMA(x, 10), EMA(x, 20 ) ) AND x >
Ref(x,-50);
YourSystemExitSignal= Cross(EMA(x, 20), EMA(x, 10)) AND x < Ref(x, -50);
if( Name() == "A" )
{
Buy = YourSystemEntrySignal;
Sell = YourSystemExitSignal;
SetPositionSize( 500, spsShares );
}
if( Name() == "B" )
{
Short = YourSystemEntrySignal;
Cover = YourSystemExitSignal;
SetPositionSize( 500, spsShares );
}
Alan
--- In [email protected], "Mike" <sfclimb...@...> wrote:
>
> You were not specific enough in your description for anyone to write
> the formula. Do you mean that the Cross happens in the EMA of "X", or
> of "A", or of "B"?
>
> In any event, the functions that you will need are as follows:
>
> 1a. Foreign http://www.amibroker.com/guide/afl/afl_view.php?
> name=foreign
> or
> 1b. SetForeign http://www.amibroker.com/guide/afl/afl_view.php?
> name=setFOREIGN
> 2. EMA http://www.amibroker.com/guide/afl/afl_view.php?id=44
> 3. Cross http://www.amibroker.com/guide/afl/afl_view.php?name=cross
> 4. Ref http://www.amibroker.com/guide/afl/afl_view.php?name=ref
> 4. How to trade pairs/spreads
> http://finance.groups.yahoo.com/group/amibroker/message/134492
>
> Mike
>
> --- In [email protected], "Alan Nouray" <alann@> wrote:
> >
> > Can anybody help me how to write and test the following formula:
> >
> > when 10 day ema crosses the 20 day ema and the close of "X" fund is
> > higher than the close 50 days ago, then buy fund "A" and sell
> fund "B"
> >
> > when 20 day ema crosses the 10 day ema and the close of "C" fund is
> > lower than the close 50 days ago, then sell fund "A" and buy fund "B"
> >
> > Thank you.
> > Alan
> >
>