|
本帖最後由 joshsmi 於 13-10-20 19:14 編輯
Here is a simple example
tradedelay = 0;
SetTradeDelays( tradedelay, tradedelay, tradedelay, tradedelay );
SetBacktestMode( backtestRegular );
SetOption( "FuturesMode", False );
SetOption( "InitialEquity", 100000);
// add other setoptions here or see backtest settings
Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Sell;
Cover = Buy;
if ( tradedelay > 0 )
{
array = Open;
equityflag = 2;
}
else
{
array = Close;
equityflag = 1;
}
BuyPrice = SellPrice = array;
ShortPrice = CoverPrice = array;
if ( Status( "action" ) == actionExplore )
{
eq = Equity( equityflag, -1 );
dt = DateTime();
entrydate = IIf( /*Long*/ Sell, ValueWhen( Buy, dt ),
IIf( /*Short*/ Cover, ValueWhen( Short, dt ),
0 ) );
entryprice = IIf( /*Long*/ Sell, ValueWhen( Buy, BuyPrice ),
IIf( /*Short*/ Cover, ValueWhen( Short, ShortPrice ),
0 ) );
exitprice = IIf( /*Long*/ Sell, SellPrice,
IIf( /*Short*/ Cover, CoverPrice,
0 ) );
Filter = Sell || Cover;
SetOption( "NoDefaultColumns", True );
AddTextColumn( Name(), "Ticker", 1.0, colorDefault, colorDefault, 70 );
AddColumn( IIf (Sell, 66, IIf( Cover, 83, 32 ) ), "Trade", formatChar );
AddColumn( entrydate, "Entry Date/Time", formatDateTime, colorDefault, colorDefault, 120 );
AddColumn( entryprice , "EntryPrice", 1.5 );
AddColumn( dt, "Exit Date/Time", formatDateTime, colorDefault, colorDefault, 120 );
AddColumn( exitprice , "ExitPrice", 1.5 );
}
|
評分
-
查看全部評分
|