Changes

Jump to navigation Jump to search

Portfolio Trader

5,312 bytes added, 12:59, 25 September 2014
no edit summary
[[File:PMMS Signal window.png]]
== Symbol Prioritization ==
If the '''PortfolioEntriesPriority''' function is specified within a strategy, the sequence of the sets of orders is rearranged based on the criteria specified.
This process is illustrated in the Symbol Prioritization section of the diagram: the resulting sequence of sets of orders begins with the set of orders for the symbol 1, followed by the set of orders for symbol N, and ends with the set of orders for symbol 2.
The position of a set of orders in the sequence determines its relative priority: the set of orders for symbol 1 has the highest priority (3), set of orders for symbol N has the second highest priority (2), and the set of orders for symbol 2 has the least priority (3).
== Risk Control ==
At the risk control stage, the sequence of sets of orders is treated as one long sequence of orders. Orders are executed one-by-one from the beginning of the sequence, until all orders are executed, or until the risk control limits defined in Portfolio Settings prevent the execution of remaining orders. Any remaining orders that could not be executed are discarded.
This process is illustrated in the Risk Control section of the diagram: all of the orders for symbol 1 and symbol N are executed, while only some of the orders for symbol 2, 100 shares Long @ 55, are executed, due to risk control limits; this prevents the execution of the rest of the orders for symbol 2.
The entire process is repeated for the next bar of each of the portfolio symbol's data series.
== Currency Conversion ==
 
Currency conversion is used when instruments in the Portfolio are traded in different currencies or Portfolio’s account currency does not match the currency of Portfolio symbols.
For example, if the Portfolio account is in EUR and the instruments (GOOG and CSCO) are traded in an American Exchange, then to buy/sell Stocks the account currency (EUR) is converted to the Exchange currency (USD). A Portfolio can be even more complex, containing instruments from various Exchanges and trading in different currencies.
If account currency and instrument currency are the same, then a conversion is not executed. ''' Currency settings''' are taken from:
 
# Account currency is set in Portfolio Settings. Go to View then select Portfolio Settings and combo-box Base Currency.
# Symbol currency is set in Exchange settings in QuoteManager. Go to Tools then select Exchanges & ECNs and combo-box Currency.
# For FOREX currency pairs cross-rates are used. <br>
 
All major strategy calculation indicators, such as Portfolio Net Profit, Gross Profit, Gross Loss, Trades Profits and Losses, etc. are calculated in the account currency, including EXISTING MaxIDDrawDown, NetProfit, MaxPositionProfit; PosTrade***;_OpenEntry***. <br>
When automated trading in the Portfolio is run by selecting Run Automate Order Execution, the currency conversion will be executed in real-time using current rates within each executed trade.
When a strategy is backtested or optimized using historical data, the corresponding historical rates will be used for conversion (exchange rates at the close of the previous FOREX trading session will be used, intra-day exchange rate fluctuations are not taken into account: e.g. if the trade occurs on April 30th, the close price of the April 29th FOREX trading session will be used).
 
Currency conversion patterns:<br>
 
'''Example 1:''' Currency conversion in PowerLanguage script. <br>
 
To correctly set a Stop Loss of 1% from the Portfolio’s capital, it is necessary to write:
<syntaxhighlight>
var: need_convert(false), equity(0);
equity = Portfolio_Equity;
if (SymbolCurrencyCode <> portfolio_CurrencyCode) then
equity = convert_currency( datetime, portfolio_CurrencyCode, SymbolCurrencyCode, equity);
setstopposition;
setstoploss(0.01 * equity);
</syntaxhighlight>
 
'''Example 2:''' Portfolio parameters calculation when backtesting without conversion. <br>
 
For example, Portfolio currency and instrument currency are the same, USD. The result of strategy backtesting is 1 trade.
 
Buy 1 lot at price $100 -> Sell 1 lot at price $110.
 
In this case, in the List of Trades under the Performance Report we should see, for example, a Net Profit=$10, and in the List of Trades this Trade will also be with the Profit=$10.
 
'''Example 3:''' Calculation of Portfolio parameters into Portfolio currency when backtesting. <br>
 
Let’s use the same example, but with EUR as the Portfolio’s currency and the same trade on this instrument as before.
Buy 1 lot at price $100 -> Sell 1 lot at a price of $110, with currency rate at the moment, buying =1.25, and selling=1.275.
In this case, in the Performance Report Net Profit will be =6.27 EUR, and in the List of Trades the trade will be with a profit=6.27 EUR.
To purchase a dollar asset, it’s necessary to buy them using the current rate. For example, $100 was bought for 80 EUR. When selling, dollars are converted back to the Portfolio currency. For example, $110, using the rate of 1.275, is converted back to approximately 86.27 EUR. <br>
 
Thus, if the rate had changed significantly after buying, for example up to 1.4, the executed trade would have been losing money:
The buy would have been for ($100/1.25 =) 80 EUR and the following amount would have been made after selling ($110/1.4 =) 78.57 EUR.

Navigation menu