In NeuroShell Trader, creating a portfolio trading system is easy to accomplish by selecting multiple ticker symbols in the New Chart wizard. When the chart is created, each of the ticker symbols you created will be a different chart page. You switch back and forth between the chart pages using the ticker symbol or name dropdown boxes at the top of the chart. Any indicators, predictions or trading strategies you insert into the chart get applied to all the chart pages. If you want to create portfolio based rules, you can use the Chart Page indicators to create trading rules based upon minimum, maximum, rankings, average, count, standard deviation, etc. across all the chart pages. For more information on these basic portfolio trading techniques load the “Example 18 – Portfolio Management” and “Example 19 – Portfolio Management Long and Short” charts in NeuroShell Trader.
Many portfolio trading systems require a limit to the number of simultaneous open positions open at any given time. Because NeuroShell Trader evaluates Predictions and Trading Strategies on a ticker by ticker basis (i.e. each ticker symbol in a chart is optimized and backtested before the next ticker symbol is worked on), it is impossible for a ticker symbol to access the final results of the other ticker symbol trading signals within the same prediction or trading strategy. For this reason, creating a system in NeuroShell Trader that limits the number of simultaneous open positions requires two trading strategies: An unrestricted system and a restricted trading strategy. The unrestricted trading system is the prediction or trading strategy which generates all the systems rules without regard to the number of simultaneous open positions. The restricted trading strategy then uses the output signals from the unrestricted system to create new trades, but only if the maximum number of simultaneous open positions rule is not violated.
The first step is to create the unrestricted system. This is done as you would normally with any prediction or trading strategy by selecting the appropriate input and trading rules, optimizing and refining as needed.
The second step is to create an indicator based upon the unrestricted system which we will call the Next Bar Position. This indicator should produce a 2 when the unrestricted system will be in position on the next bar, a 1 if it will be entering a position on the next bar and 0 if it wont be in a position the next bar. The pseudo code for this indicator would look like the following:
If ( Position(Unrestricted System) <> 0 AND NOT Exit Signal: Unrestricted System ) THEN 2
ELSE IF ( Entry Signal: Unrestricted System ) THEN 1
ELSE 0
By applying the Chart Page Upper Rank indicator to the “Next Bar Position” indicator, we can tell how many unrestricted positions are already open and thus whether or not the restricted system should enter a position. On any given bar, the chart pages with unrestricted systems already in a position will have the lowest upper rank values (1,2,3, etc.). The chart pages with unrestricted systems which will be entering a position on the next bar will have the next higher upper rank values. The chart pages with unrestricted systems which are not in a position the next bar will have the highest upper rank values. The actual entry conditions for a restricted trading system which limits to no more than 2 simultaneous open positions would be the following (both of which must be true at the same time):
Entry Signal: Unrestricted System
A<=B ( Next Bar Position, 2 )
Note that the above code assumed that you were trading a system that only took long positions or only short positions. It is still possible to have the same type of restrictions when trading a system that trades both long and short. To limit the simultaneous long positions independently from the short positions, you would simply use the above next bar position indicator and entry conditions, except use the long entry signal, long exit signal and Position > 0 for the long part of the restricted strategy and short entry, short exit signal and Position < 0 for the short part of the restricted strategy. To limit the cumulative number of long AND short positions open simultaneously at any given time, you would use the above except substituting in OR2(Long Entry Signal, Short Entry Signal), OR2(Long Exit Signal, Short Exit Signal) and Position <> 0 for the entry, exit and position tests for both the long and short parts of the restricted strategy.
To see an example chart, download and explore the following chart, which implements a long strategy with a maximum or 2 simultaneous open long positions at any time.