Strategies will often result in redundent signals (e.g. receive another buy signal when already holding a position). Also, depending on your settings for position size, number of positions allowed, etc. you may not be able to take all signals.
Refer to the user guide for more detail: http://www.amibroker.com/guide/h_backtest.html Mike --- In amibroker@yahoogroups.com, "Alan Nouray" <al...@...> wrote: > > Thank you Mike. When I backtest, only one trade shows but on the chart > there are many "Buy" & "Sell" signals. Do I do backtest the system by > simply using the backtest button? > > Alan > > --- In amibroker@yahoogroups.com, "Mike" <sfclimbers@> wrote: > > > > > > Grrr. Sorry, forgot that Yahoo's rich text editor doesn't work from > > Google's Chrome browser. > > > > What I intended to say was that the formula looks fine. It is helpful to > > add Plot statements to see what is going on. For example; I have > > modified your formula a bit for clarity, added Plot statements for > > visual confirmation, and ran it against X=^DJI, A=JNJ, B=IP using the > > default AmiBroker database. These symbols were just selected at random. > > > > The two EMA's are charted as lines, the close > Ref(close, -50) is > > charted as a ribbon at the bottom. > > > > Mike > > > > > > > > Buy = Sell = Short = Cover = 0; > > > > x = Foreign( "^DJI","C" ); > > Fast = EMA( x, 10 ); > > Slow = EMA( x, 20 ); > > AbovePrevious = x > Ref( x, -50 ); > > > > YourSystemEntrySignal = Cross( Fast, Slow ) AND AbovePrevious; > > YourSystemExitSignal = Cross( Slow, Fast ) AND NOT AbovePrevious; > > > > if( Name() == "JNJ" ) > > { > > Buy = YourSystemEntrySignal; > > Sell = YourSystemExitSignal; > > > > SetPositionSize( 500, spsShares ); > > } > > > > if( Name() == "IP" ) > > { > > Short = YourSystemEntrySignal; > > Cover = YourSystemExitSignal; > > > > SetPositionSize( 500, spsShares ); > > } > > > > Plot(Fast, "Fast", colorDarkRed); > > Plot(Slow, "Slow", colorDarkGreen); > > Plot(x, "X", colorLightGrey); > > Plot(1, "AbovePrevious", IIF(AbovePrevious, colorBrightGreen, colorRed), > > styleOwnScale | styleNoLabel | styleNoTitle | styleArea); > > PlotShapes(Buy * shapeUpArrow, colorDarkGreen); > > PlotShapes(Sell * shapeDownArrow, colorDarkRed); > > PlotShapes(Short * shapeHollowDownArrow, colorDarkRed); > > PlotShapes(Cover * shapeHollowUpArrow, colorDarkGreen); > > > > > > --- In amibroker@yahoogroups.com, "Mike" <sfclimbers@> wrote: > > > > > > > > > --- In amibroker@yahoogroups.com, "Alan Nouray" alann@ wrote: > > > > > > > > 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 amibroker@yahoogroups.com, "Mike" sfclimbers@ 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 amibroker@yahoogroups.com, "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 > > > > > > > > > > > > > > > > > > > > >