PureBytes Links
Trading Reference Links
|
Go to Automatic Analysis and change the Periodicity from daily to 1
minute. Run back test.
To see where the buy and sell signals are add the following code to
plot arrows at the trade points. I also plotted the EMA so you can
see where it crossed the candles.
When you use the same formula results many times calcualte it once
and use the calculated value. It matters little here but the code is
more efficient.
Just copy the following code into a formula and insert linked. I ran
back test on it and it worked.
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close
%g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C,
SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g
(%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C,
SelectedValue( ROC( C, 1 )));
}
_SECTION_END();
pEMA = Param("EMA period", 35, 5, 50, 1);
pEMA = Optimize("EMA period", pEMA, 5, 50, 1);
myEma = EMA(C, pEMA);
Buy = Cover = Cross( Close, myEma );
Sell = Short = Cross( myEma, Close );
Plot(myEma, "\nEMA(" + NumToStr(pEMA, 1.0) + ")", colorBlue);
PlotShapes(Buy * shapeUpArrow, colorGreen, 0, L, -15 );
PlotShapes(Sell * shapeDownArrow, colorRed, 0, H, -15 );
Barry
--- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote:
>
> I'm still at the early phase of learning AmiBroker and am trying to
code
> my first easy test system. It's the example EMA crossover system
given
> in the User's Guide.
>
> I have a one-minute chart open with a year's worth of historical
> one-minute FOREX data (Euro-USD). After writing my formula, I click
on
> Analysis. On the pop-up panel, I check off "Run every 1 min" on all
> quotations. But when the back test runs, it runs on daily data
instead
> of the one-minute data.
>
> (1) How do I get the backtest to run on the one-minute data, not
daily?
>
> (2) Is there a quick and easy way to automatically plot the buy/sell
> points so I can view the entry and exit positions on the graph?
>
> (3) Does the backtest engine choose close prices for the entry and
> exits? If so, is this realistic, given that the high/low within
each bar
> can often be plus or minus several PIPs away from the actual close?
>
>
> Below is my code:
>
> _SECTION_BEGIN("Price");
>
> SetChartOptions(0,chartShowArrows|chartShowDates);
> _N(Title = StrFormat("{{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close
> %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C,
> SelectedValue( ROC( C, 1 )) ));
> Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle |
> ParamStyle("Style") | GetPriceStyle() );
>
> if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
> {
> ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g
> (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC
( C,
> 1 )));
> }
> _SECTION_END();
>
> /////////////////////////////////////////////////////
> // simplest buy sell rules;
> // Buy when the Close crosses above the 45-Day EMA;
> // sell when the 45-day ema crosses above the close;
> //////////////////////////////////////////////////////
>
> Buy = Cross( Close, EMA( Close, 45 ) );
> Sell = Cross( EMA( Close, 45 ), Close );
> SetPositionSize(5,spsShares);
>
------------------------------------
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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|