I am using Portfolio Trader to automated a strategy on daily bars. Naturally I cannot keep it running continuously throughout the time a position is open.
Entries are done with a market order and exits using a stop and limit orders submitted at the time of entry and do not change later on - so there is no order management after entry and I don't need Portfolio Trader to handle that aspect. I can turn it off and the orders are still on the broker's (IB) server, in an OCA group.
However, I do need the script to know if there is an existing position, to prevent another one from being opened in parallel, when I reactivate Portfolio Trader.
Most documentation I saw about marketposition, marketposition_at_broker, and the synchronizer script !From Broker To Strategy MP Synchronizer! seem to refer to charts.
What should I use to detect an existing position with scripts running on Portfolio Trader?
Portfolio Trader and Market Position [SOLVED]
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
- Svetlana MultiCharts
- Posts: 645
- Joined: 19 Oct 2017
- Has thanked: 3 times
- Been thanked: 163 times
Re: Portfolio Trader and Market Position
Hello, TraderWalrus,
The commands you have listed, as well as the pre-built autotrading signal !From Broker To Strategy MP Synchronizer! will work not only on chart but in the PortfolioTrader too.
The commands you have listed, as well as the pre-built autotrading signal !From Broker To Strategy MP Synchronizer! will work not only on chart but in the PortfolioTrader too.
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
Re: Portfolio Trader and Market Position
Thank you Svetlana - could you advise for the case I described - is the synchronizer script necessary or is it enough to use marketposition_at_broker ?
- Svetlana MultiCharts
- Posts: 645
- Joined: 19 Oct 2017
- Has thanked: 3 times
- Been thanked: 163 times
Re: Portfolio Trader and Market Position [SOLVED]
If you want only to check the position at broker – you can use the “MarketPosition_at_Broker” command in your own code.
But if you want your strategy to also manage this position – it would be better to utilize the !From Broker To Strategy MP Synchronizer! signal, since it already has the position synchronization logic implemented with the help of the ChangeMarketPosition command.
But if you want your strategy to also manage this position – it would be better to utilize the !From Broker To Strategy MP Synchronizer! signal, since it already has the position synchronization logic implemented with the help of the ChangeMarketPosition command.