Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

RANDOM ENTRY for Amibroker (AFL)

Rating:
4 / 5 (Votes 2)
Tags:
trading system, amibroker

Using a random entry, it is possible to isolate the effects of the exit from the entry.

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Formula 1");
//	EnterAtRandom.afl
//
// Entry a position at the close of a random bar.
//
// A random entry for use as a benchmark.
// Expect this entry to mirror the buy and hold.
// It cannot be profitable taking long positions in 
//	a declining market, or	taking	short	positions
//	in a rising market.
//
//	This code just waits a	fixed number	of	bars to exit.
//	It can be used to test	any of	the exit	systems.
//
// For market orders, enter and exit Market On Close
// with no delay
SetTradeDelays(0,0,0,0);
BuyPrice = C;
SellPrice = C;
// Frequency is the number of entries per year.
Frequency = Param("Entries per Year",12,1,100,1);
// Repeatable is a switch.
// True (1): the sequence of random numbers will be repeated.
// False (0): each sequence is random.
Repeatable = Param("Repeatable",0,0,1,1);
// Seed is the number used to start the random sequence // when repeatable sequences are desired.
Seed = Param("Seed", 13331,1,99999,1);
// Generate a fraction, uniformly distributed // between 0.00000 AND 0.99999.
NextRandom = IIf (Repeatable,Random(Seed),Random());
Buy = IIf (NextRandom<Frequency/252,1,0);
// The code for the exit being tested starts here.
//
// HoldBars is the number of bars to wait for exit.
HoldBars = Param("HoldBars", 3,1,100,1);
Sell = BarsSince(Buy)>=HoldBars;
// The code for the exit being tested ends here.
// Remove extra Buy and Sell signals.
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell,Buy);
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.

Back