Hi everybody

I am new to trading and to Amibroker. I was trying to replicate Seykota's 
Simple 
Exponential Crossover system in amibroker Backtester but I have troubles in 
sizing the correct number of Shares: Amibroker seem not to use the figures that 
I calculate in AFL. I am using Amibroker 5.20 unregistered (I am still 
evaluating it) and the historical SP500 futures data found at 

http://www.seykota.com/tribe/TSP/resources/SP----C.csv

I am trying to exactly match the run for SlowAverage=150 and FastAverage=15, 
whose Trade List can be found on Seykota site at 
http://www.seykota.com/tribe/TSP/EA/2005_u_11_EA_System/Trade_Log_0-0.txt.

The BackTester does match the entry/exit dates, but instead of buying 6500 
Shares for the first trade, it buys 3345,8 and I do not see why. If I use the 
old backtester the system does buy 6500 Shares.

I am using the following code (which is almost identical to the one which can 
be 
found on both Amibroker and Seykota sites) and SetPositionSize + spsShares but 
it does not seem to do the job.

I am probably missing something as I am a newbie on both trading and Amibroker.

Any help is kindly appreciated.

Cheers, Robert

// Parameters Set 

SetOption("InitialEquity", 1000000);
SetOption("MinShares", 50);
SetOption("NoDefaultColumns", True );
SetOption("CommissionMode", 2); //$$ per trade
SetOption("CommissionAmount", 0);
SetOption("MarginRequirement", 10);
SetOption("UsePrevBarEquityForPosSizing", True);
SetTradeDelays( 1, 1, 1, 1 );
// RoundLotSize = 50;

// redefine the EMA according to Seykota version (does match EMA Amibroker 
function)

function Seykota_EL(P, TC)
{
    r[0] = P[0];
    for(i = 1; i < BarCount; i++)
    {
        r[i] = r[i-1] + (P[i] - r[i-1])/((TC+1)/2) ;
    }
    return r;
}

// TR definition, initialised to span H-L

tr = Max(H-L, Max(abs(H-Ref(C, -1)), abs(Ref(C, -1)-L)));
tr[0] = H[0] - L[0];

// To optimize: fast = Seykota_EL(C, Optimize("FastEMA", 50, 5, 140, 5));
//              slow = Seykota_EL (C, Optimize("SlowEMA", 200, 100, 500, 50));

fast = Seykota_EL(C, 15);
slow = Seykota_EL(C, 150);

// entry/exit rules

Buy = Cross(fast, slow);
Sell = Cross(slow, fast);
Buy[1] = 0; // to avoid false signal at the beginning

// TO optimize: ATR_multi = Optimize("ATP Multi", 5, 3, 9, 2); e si definisce 
l'array dell' ATR
//                 Heat = Optimize("Heat", 0.05, 0.01, 0.21, 0.02);

ATR_multi = 5;
ATR0 = Seykota_EL(tr, 20);
Risk_Per_Lot = Ref(ATR0, -1) * ATR_multi;
Heat = 0.1;

BuyPrice = (H+O)/2;
SellPrice = (L+O)/2;

// Position Size calculation

PosSize = Ref(Equity(), -1)*Heat/Risk_Per_Lot; //Seykota formula

PosSizeRounded = 250*int(PosSize/250+0.5);

SetPositionSize(PosSizeRounded, spsShares);


Filter = 1;

AddColumn( DateTime(), "Date", formatDateTime ); 
AddColumn(Equity() , "Equity");
AddColumn(PosSizeRounded, "Lotti");
AddColumn(O, "Open");
AddColumn(H, "High");
AddColumn(L, "Low");
AddColumn(C, "Close");
AddColumn(slow, "SlowEMA", 1.3);
AddColumn(fast, "FastEMA", 1.3);
AddColumn(ATR0, "ATR", 1.3);
AddColumn(IIf(Buy, 111, IIf(Sell, 222, 0)) , "Buy1Sell2", 1);

Plot(fast, "FastEMA", colorRed);
Plot(slow, "SlowEMA", colorBlue);



      

Reply via email to