Random Walk Trading Strategy (Amibroker Code)
The original article can be found here.
Amibroker code:
setOption("initialEquity",100000);
Leverage=1 ;
SetOption("accountmargin",100/leverage);
SetPositionSize(99.75*leverage,spsPercentOfEquity);
setOption("MaxOpenPositions",1);
SetTradeDelays( 0, 0, 0, 0 );
_SECTION_BEGIN("Formula 1");
SetTradeDelays(0,0,0,0);
BuyPrice = C;
SellPrice = C;
Frequency = Param("Entries per Year",12,1,100,1);
Repeatable = Param("Repeatable",0,0,1,1);
Seed = Param("Seed", 13331,1,99999,1);
NextRandom = IIf (Repeatable,Random(Seed),Random());
Buy = IIf (NextRandom<Frequency/252,1,0);
HoldBars = Param("HoldBars", 4,1,100,1);
Sell = BarsSince(Buy)>=HoldBars;
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell,Buy);
_SECTION_END();
