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.

Buy = COND1 AND COND3;

Short = COND2 AND NOT(COND3);

BuyPrice = C;

ShortPrice = C;

longEntryPrice = ValueWhen(Buy,BuyPrice,1);

shortEntryPrice = ValueWhen(Short,ShortPrice,1);

Buy = ExRem(Buy,Short);

Short = ExRem(Short,Buy);

The Buy array is filled with 1’s when a pivot low has formed below zero in the

histogram and the current price is below the 100-day moving average. The Short

array is filled with 1’s when a pivot high has formed and the current price is below

the 100-day moving average. The longEntryPrice is captured when Buy is set

to 1. The ValueWhen function returns the second array value when the first array

is set to 1. You must use the ExRem function to remove redundant Buys and

Shorts. In other words, only turn subsequent Buys on or Shorts on when the existing

long/short positions are either liquidated or reversed.

298

AMIBROKER

Sell = Cross(C, longEntryPrice - 3 * ATR(10));

Cover = Cross(ShortEntryPrice + 3 *ATR(10),C);

Buy = ExRem(Buy,Sell);

Short = ExRem(Short,Cover);

AddColumn(longEntryPrice,"BuyPrice");

AddColumn(longEntryPrice - 3 * ATR(10),"longStop");

AddColumn(Sell,"Sell ?");

Sell array (long liquidation) is turned on when the close crosses 3 ATR below the

longEntryPrice.

■ Position Sizing in Futures Mode

Here is the exact formula used to apply an ATR Risk-Based Fixed Fractional money

management scheme to a trading algorithm.

RiskPerContract = 2 * ATR(10);

PositionRisk = 1;

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!