Initial Size - write and run |
Top Previous Next |
In this exercise, we’ll first run Lesson3.sig on a single symbol (price data file) in order to generate some trades to size. Then, we’ll write a simple Initial Sizing routine, and run it.
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
STARTUPCASH = 250000000 '$25,0000,000 NEWCONTRACTS = 1 'for stock testing, use NEWSHARES
STARTUPCASH Let’s 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 1000’s 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 we’ll refrain from jumping into the fray. These keywords are identical in their behavior; it doesn’t 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. |