[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ELS code to generate random entry or exit



PureBytes Links

Trading Reference Links

AceTrader wrote
>Can any kind soul send me ELS code to generate random entry or exit
>for testing my exit and entry strategies.

Maybe I'm missing a point here, but this seems too easy:

vars: dir(0), tradenow(false), exitnow(false);

{Entries}

{new entry at any time with 40% probability, except when position in
same direction already exists}

dir = random(100)-50;
tradenow = (random(100) < 40);
if marketposition >= 0 and dir < 0 and tradenow then sell;
if marketposition <= 0 and dir > 0 and tradenow then buy;

{OR... like above, but enter only when NOT holding any position}

dir = random(100)-50;
tradenow = (random(100) < 40);
if marketposition = 0 and dir < 0 and tradenow then sell;
if marketposition = 0 and dir > 0 and tradenow then buy;

{exit at any time with 30% probability}

exitnow = (random(100) < 30);
if marketposition > 0 and exitnow then exitlong;
if marketposition < 0 and exitnow then exitshort;

>Thanks in advance.

I hope this helps.

-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com