Initial Size - write and run

Top  Previous  Next

 

A simple example

In this exercise, well first run Lesson3.sig on a single symbol (price data file) in order to generate some trades to size. Then, well write a simple Initial Sizing routine, and run it.

1Open Lesson3.sig. This file should appear on the Most Recently Used files list (MRU) at the bottom of the File menu. If it does not, then...
2Click the File icon on the Signal toolbar; the path is ..\Mechanica\Sample Rules\Signal Rules.
Here is the code as we left it at the end of the previous lesson:

Resources

SYSTEM = 3

COL1 = MAX[HIGH,34,0] + TICK[1]      'long entry price

COL2 = MIN[LOW,34,0] - TICK[1]      'short entry price

COL3 = SMA[CLOSE,34]      'exit indic. (long and short)

 

Trade Entry

'BUYSTOP = COL1[1]                  'long entry signal 

 BUYSTOP = Long_Entry[1] 

'SELLSTOP = COL2[1]                'short entry signal

 SELLSTOP = Short_Entry[1]

 

Trade in Progress & Exit

'IF C[1] < COL3[1] THEN SELLOPEN     'long exit signal

 IF C[1] < SMA_Exit[1] THEN SELLOPEN

'IF C[1] > COL3[1] THEN BUYOPEN     'short exit signal

 IF C[1] > SMA_Exit[1] THEN BUYOPEN

 

3From the Data menu, choose Symbol Manager.
4Make sure that the Pinnacle_Futures Data Page is still selected (checked). Tag it (if it is not), and untag any other Data Pages that are currently tagged.
5Under the Tag Symbols tab, tag JY_REV, and untag any other Symbols that may be currently tagged.
6Close the Symbol Manager.
7Save your work out to another filename; from the File menu, choose Save As, Signal Rules
8Call this new file Lesson5  (Mechanica will add the *.sig extension.)
9Click the Run arrow icon on the Signal toolbar, or choose Run Signal Rules (Signals menu), to run the system.
10When the Signal Rules run is complete, click on the Initial Size tab, and enter the following two lines of code:

STARTUPCASH = 250000000  '$25,0000,000 

NEWCONTRACTS = 1              'for stock testing, use NEWSHARES

 

11Click the Save position sizing rules (disk) icon on the Position Sizing toolbar, or from the File menu, choose Position Sizing Rules, Save As, and call this file Lesson5. Mechanica will automatically add the file extension (*.siz).
12To run the Position Sizing Rules, Click the Run arrow icon on the Position Sizing toolbar, or from the Position Sizing menu, choose Run Position Sizing Rules.
When the Position Sizing Rules run is complete, the Portfolio Performance window will appear.

 

STARTUPCASH

Lets review the two lines of Initial Sizing code we wrote. STARTUPCASH specifies your initial account equity for use in Portfolio Analysis. At the start of a simulation, before the first trade is taken:

STARTUPCASH = TOTALCLOSEDEQUITY = TOTALEQUITY 

 

In the example above, we specified that STARTUPCASH = 25000000 … or $25,000,000. Note that the comma used to separate 1000s is omitted in Mechanica Basic. If STARTUPCASH is not specified, Mechanica defaults to 100000 ($100,000).

 

NEWCONTRACTS / NEWSHARES

These keywords specify the number of contracts or shares to trade. In this first example, we specified NEWCONTRACTS = 1. Some futures traders run such “single contract” testing as a first step in evaluating the worth of a system; others do not. There are as many opinions on this as there are systematic traders, so well refrain from jumping into the fray.

These keywords are identical in their behavior; it doesnt matter which you use. The keyword NEWSHARES was added as a convenience for stock traders, many of whom find the concept of dealing with “contracts” (and the keyword NEWCONTRACTS), unfamiliar.