31.07.2021 Views

Ultimate Algorithmic Trading System

Using automated systems for trading in stock markets

Using automated systems for trading in stock markets

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If marketPosition =-1 then

begin

end;

If c < entryPrice - 3* avgTrueRange(10) then

buyToCover this bar on close;

if c > entryPrice + 1* avgTrueRange(10) then

buyToCover this bar on close;

This algorithm covers long positions whenever the market closes above the

entryPrice plus 3 ATRs, or when it closes below the entryPrice minus 1 ATR.

The same technique is programmed for short trades as well. This algorithm risks

one ATR to achieve three.

The following algorithm is a simple 20-day Donchian breakout that only takes

trades in the direction of the 14-day slope of closing prices. The interesting part of

the algorithm is found in the trade management.

222

AN INTRODUCTION TO EASYLANGUAGE

Inputs: linearSlopeLength(14),channelLength(20);

Inputs: atrLen(10),numAtrStop(3),numAtrProfThreshold(5),

numAtrTrail(2);

vars: buyLevel(0),shortLevel(0),maxContractPoints(0);

buyLevel = Highest(High[1],channelLength);

shortLevel = Lowest(Low[1],channelLength);

if marketPosition <> 1 and linearRegSlope(c,linearSlopeLength)

> 0 then

Buy("BuyLevelEntry") tomorrow at buyLevel stop;

maxContractPoints = maxContractProfit / bigPointValue;

If marketPosition = 1 then

begin

sell("L-ATR-Stop") next bar at entryPrice-numAtrStop *

avgTrueRange(atrLen) stop;

if maxContractPoints >= numAtrProfThreshold *

avgTrueRange(atrLen) then

begin

value1=entryPrice + (maxContractPoints-numAtrTrail *

avgTrueRange(atrLen));

sell("L-Trail-Stop") next bar at value1 stop;

end;

end;

www.rasabourse.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!