Hi,
Some of my MR systems for stocks took a beating during the last weeks so probably time for some more tests - I thought.
Long story short, I wanted to play around with a limit order entry. I stumbled across this page (once again).
Nick Radge / Alvarez MR strategy w limit order entry
The strategy was programmed in a few minutes using Norgate Data. I can't get the thing anywhere close to what has been published. I wonder if I did something wrong and what it could be.
Did someone here play around and can shed some light on it?
...it works best with Norgate Data.
Dates simulated for comparison (same as webpage):
01/01/2014 - 06/30/2014
I didn't even include commissions or slippage.
The system just evaporated money...
for comparsion:
source:
source
#include_once "Formulas\Norgate Data\Norgate Data Functions.afl"
OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() == (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") );
index_string1 ="$RUA";
constituent = NorgateIndexConstituentTimeSeries(index_string1);
//Max. Pos. Held
qty= 10;//Optimize("qty",30,10,70,5);//
//Limit-Entry
lower = 0.5;//Optimize ("limit",1,0.5,3,0.5);
limit = C<=Ref(C,-1)-lower*Ref(ATR(10),-1);
BuyPrice= Ref(C,-1)-lower*Ref(ATR(10),-1); // simulate Limit Price
SellPrice= O;// no slippage
PctSize = 100/qty; //simple % alloc.
SetPositionSize(PctSize, spsPercentOfEquity);
//Back-Tester Initial Settings
//SetBarsRequired(200);//
SetOption("NoDefaultColumns",True);//
SetOption("InitialEquity",100000);//
//SetOption("AllowSameBarExit",True);//
SetOption("ActivateStopsImmediately",false);//TRUE when trading on OPEN
SetOption("AllowPositionShrinking",False);//
SetOption("FuturesMode",True);//
SetOption("AccountMargin",100);//
SetOption("InterestRate",0);//
SetOption("maxopenpositions",qty);//
//EnableRotationalTrading()
//SetOption("WorstRankHeld",false);// rot trading only
SetOption("MinShares",1);//
SetOption("MinPosValue",0);//
SetOption("PriceBoundChecking", False);//
SetOption("CommissionMode",3);// 0 - use portfolio manager commission table 1 - percent of trade 2 - $ per trade 3 - $ per share/contract
SetOption("CommissionAmount",0.00);//
SetOption("ReverseSignalForcesExit", False);//
SetOption("UsePrevBarEquityForPosSizing", True);//
SetOption("PortfolioReportMode", 0);// 0: trade list 1: detailed log 2: summary 3: no output
SetOption("UseCustomBacktestProc",False);//
SetOption("EveryBarNullCheck",False);//
SetOption("HoldMinBars",0);//
SetOption("EarlyExitBars",0);//
SetOption("EarlyExitFee",0);//
SetOption("EarlyExitDays",0);//
SetOption("DisableRuinStop",True);//
//SetOption("GenerateReport",1)
SetOption("SeparateLongShortRank",False);//
//SetOption("MaxOpenLong",0);//
//SetOption("MaxOpenShort",0);//
SetOption("RefreshWhenCompleted",False);//
SetOption("ExtraColumnsLocation",False);//
//SetOption("SettlementDelay",0);//
OptimizerSetEngine("cmae");
SetTradeDelays(0,1,0,0);//
SetBacktestMode( backtestRegular);
//SetOption("portfolioreportmode",1);//
Short=0;
Cover=0;
//Historical Vola filter / PositionScore
HV = 100 * StDev(log(C/Ref(C,-1)),100) * sqrt(252);
///////////////////////////////////////////////////////////////
//Buy Condition:
turnover = MA(V,21)*C>10000000;//
oc = NorgateOriginalCloseTimeSeries()>1;
buy1= L<Ref(L,-1) AND Ref(L,-1)<Ref(L,-2) AND Ref(L,-2)<Ref(L,-3) AND C<MA(C,5) AND C>MA(C,100) AND turnover AND oc;//
/////////////////////////////////////////////////////////////////
Buy= Ref(buy1,-1) AND limit AND constituent AND NOT OnSecondLastBarOfDelistedSecurity;//
Sell= C>Ref(C,-1) OR OnSecondLastBarOfDelistedSecurity;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
positionScore= HV; // rank by HV or mtRandom()