MAXPOSITIONS

Top  Previous  Next

Keyword Description

Sets upper limit on the number of open positions

Class

Directive

Where Legal

Resources

Entry Logic

Exit Logic

Initial Size

Resize

(Pre-Category)

Resize

(Category-Level)

 

 

 

l

l

 

Syntax

MAXPOSITIONS

 

Example

Sample code

MAXPOSITIONS = 5

 

ThumbTack white

This causes different behavior based upon where it appears in your code and the status of Include Today.  On Initial Size when Include Today is set to NO (False) Mechanica will have no knowledge of trades entered earlier during the same session.  In that case it looks back to yesterday to see how many positions were currently open then.  If that number does not exceed MaxPositions then any number of new trades can be entered that day. With Include set to True (a postdictive exercise)  Mechanica will have knowledge of any trades entered earlier the same day.  On the Resizing page Mechanica is legitimately privy to data that is one day more recent than was available to it on Initial Size with Include Today = NO.  In that case MAXPOSITIONS will reflect the number of trades that were entered during the most recent previous session and will also have knowledge of the results of multiple resizes that your code may order for the next session.

If there was an exit-certain trade from the previous session (a trade that is to exit on the next open), then a new position can be added, since one position slot is 'certain' to become available.  In the PSR Detail this can show up as more than MaxPositions trades open (non-zero size) on a given day that also has an exit P/L for a trade exiting at the open of the same day.