Using Weekly, Monthly or Daily bars in live trading, practical implications?

Questions about MultiCharts and user contributed studies.
Salzburg
Posts: 140
Joined: 19 Sep 2018
Has thanked: 9 times
Been thanked: 35 times

Using Weekly, Monthly or Daily bars in live trading, practical implications?

Postby Salzburg » 30 Jan 2020

Hi, Some questions, might sounds stupid but i always have worked on shorter timeframes, and i am constructing a portfolio of longer term strategies trading on a combination of Daily, weekly and monthly bar sizes.

Have just ended a long research period, and now it comes to to setting up real execution and the issues that comes with just that.

When using a portfolio in MC, one will be faced with the starting and stopping a portfolio even when one is in position, can be due to server crash, server update, update etc etc, this happens and can not be avoided and is not the fault of MC.

So, in my case i will have longer positions that will loose its stops on server side, and position size needs to be assigned to each strategy when restarting the portfolio again.

I am also trading same instruments in the portfolio, using different strategies. So for example 3 strategies can have position in same stock.

My portfolio trades 150 different stocks.

Questions
1: How can i solve the issue that when for some reason have to restart my portfolio, and 3 of my strategies each hold a position (in same direction since all are long only), how can i know what position to assign to what strategy ? how do i practically solve this in the best way? since i will know from my IB account that i have one large position in this specific stock, BUT its 3 positions from 3 strategies.

2: When i restart a portfolio, i loose all my stops on server side, if i use daily, weekly or monthly bars, i normally have to wait until next bar start, before my stops are placed again from strategy, IS there any way, my stops can be reassigned asap when i restart my strategy? is there any best practise for this ? any setting i have missed that can help with this issue ?

3: Is there any practical implications when researching and implementing for live trading strategies using weekly or monthly bars? something i am missing or need to think about?

Thanks for help

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: Using Weekly, Monthly or Daily bars in live trading, practical implications?

Postby Svetlana MultiCharts » 07 May 2020

Hello Salzburg,

Now let us describe in detail some peculiarities that will help you understand the MultiCharts AutoTrading System and use it to achieve your goals.

When one stops auto trading, there are two variants: close all positions and cancel orders, or leave the position and orders at the broker.
In the first case, one needs to record the profit/loss and, when auto trading is restarted, open positions anew according to the strategy logic.
In the second case, the position and orders are kept at the broker. When the auto trading is restarted it should begin from a definite moment.
Below I will provide a piece of information on how one can achieve it and what one should expect from MultiCharts auto trading system.

1# What happens if auto trading is turned off without canceling active orders and closing the position?

Active orders and positions stay active at the broker before the broker profile is turned off. These are the possible variants of what happens when turning off broker profile:

1) If the broker supports Native OCO group, the orders will remain at the broker after turning off auto trading.
- IB supports Native OCO. This option can be enabled in Strategy Properties → Auto Trading → Select broker plugin -> Interactive Brokers → gear button → OCO Group.
- When auto trading and broker profile are turned off, the orders and positions will remain at the broker. One will be able to see them in MultiCharts OPT next time MultiCharts is launched and IB broker profile is connected.

2) If Native OCO group is not supported by the broker, the orders will be canceled and positions will stay unprotected.

2# In auto trading mode there are 3 positions in MultiCharts:

- chart position (or string in Portfolio Trader). The keyword is marketposition;
- position at the broker (Order and Position Tracker (OPT) → Open Positions tab). The keyword is marketposition_at_broker;
- position in the auto trading chart system (OPT → Strategy position). The keyword is marketposition_at_broker_for_the_strategy;

Following your goal, you need to set these positions at the start for each of the charts (or strings in Portfolio Trader). In other words, you need to synchronize them.

3# There are two types of auto trading: synchronous auto trading mode (SA) and asynchronous auto trading mode (AA). Here you can learn more about these modes of auto trading.

1) In SA mode, marketposition, marketposition_at_broker are equal to 0; there is no order history (though it can be created from the script via ChangeMarketPosition keyword).

2) In AA mode, order history is the same as in backtesting. After the script is calculated, the history of marketposition equals the strategy calculations; marketposition_at_broker = 0 since auto trading is not performed on the history.
The only way to synchronize everything is to use Assign the Initial Market Position settings.

3) In SA mode, it is possible to start either from 0 position or synchronize at the start (with the Assign the Initial Market Position).

4) If several strategies from different charts manage the position of one instrument, after restart it will be not possible to know which of the positions changed the broker position and how much.

- For example, if the first strategy went +1 contract and the second strategy went +1 contract, then the broker position will be +2 contracts for both strategies for this symbol and it will be indicated in OPT → Open Positions.

- In this case synchronization of the position with the broker will not work because all strategies will take a starting position from broker +2 instead of +1 as it was when auto trading mode was off.

- In AA mode, you will be able to use synchronization with the chart. To do this, please make sure that by the end of the calculation, the starting position is the same as it was with auto trading turned off.

- In SA mode, none of the synchronization variants will suit you. It will be required to make changes in the script by adding the logic of setting the starting position (ChangeMarketposition).

4# If you build weekly and monthly bars, there is no need for you to wait until the bar is closed to generate the Stop Orders.

- If the script generated non-conditional Stop Orders at the last historical calculation, they will be placed automatically at the moment when auto trading is turned on. This will happen if after synchronization marketposition_at_broker_for_the_strategy is not equal to 0.

5# In your case, the best choice is AA mode which will open positions for all your symbols and will place orders according to backtesting results. Also, since you have a long-term strategy, there is no need to keep MultiCharts running all the time.

- When auto trading is turned on, in the Assign the Initial Market Position dialogue the position generated by the strategy backtesting will appear. It can be changed for the desired one.

- In any case, there is a possibility that the position is still left at the broker if there was a considerable time gap between turning off auto trading and then turning it on again. Also, when the system was turned off, backtesting could have generated other orders which do not match the broker position. Then in the Assign the Initial Position dialogue the suggested position will differ from the expected one. If this situation, one should process this logic in the signal script. For example, one can make it remember the time of auto trading being turned off, the time it was then turned on, and use the keyword getappinfo(aiStrategyAuto) = 1 (the start of auto trading). Thus it will be possible to isolate the backtesting calculation for the time when the system was not launched.

I hope this information will help you in figuring this out. I would recommend you to use the prebuilt Paper Trader or demo account of your broker for running tests and debugging the script logic.

Salzburg
Posts: 140
Joined: 19 Sep 2018
Has thanked: 9 times
Been thanked: 35 times

Re: Using Weekly, Monthly or Daily bars in live trading, practical implications?

Postby Salzburg » 13 May 2020

Many thanks Svetlana


Return to “MultiCharts”