When my strategy opened a position, I need to restart server due to something reasons (eg. Windows force restart, computer halt, stop computer in weekend .....etc)
Any way to resume my strategy? My strategy logic includes marketpostion (tried to use marketposition_at_broker to replace), entry price and some dynamic values assigning during real time calculation.
How to continue my strategy after server restart
Re: How to continue my strategy after server restart
When you restart your strategy you should be presented with a dialog box asking if you would like to accept the position(s) reported at your broker. Depends on settings in strategy see attached at bottom
- Attachments
-
- Annotation 2020-02-22 074120.png
- (54.57 KiB) Not downloaded yet
- Anna MultiCharts
- Posts: 560
- Joined: 14 Jul 2017
- Has thanked: 42 times
- Been thanked: 141 times
Re: How to continue my strategy after server restart
kinwai,
Please describe the issue in detail as I’m afraid it’s not clear from your description. Attach some screenshots for illustration as well.
Please describe the issue in detail as I’m afraid it’s not clear from your description. Attach some screenshots for illustration as well.
Re: How to continue my strategy after server restart
For example, if use 1 min chart and use dynamic variable to keep the day high value. After computer executed the strategy but computer halt and need to restart, how can resume the strategy but reload the previous dynamic variable?
- Anna MultiCharts
- Posts: 560
- Joined: 14 Jul 2017
- Has thanked: 42 times
- Been thanked: 141 times
Re: How to continue my strategy after server restart
Hello kinwai,
Apart from assigning the position, you can use the !From Broker To Strategy MP Synchronizer! signal.
Also you could trade in asynchronous mode (AA) and pick up the strategy position From Chart as a starting point of calculations.
In synchronous mode (SA) you can add a signal with a logic similar to the sample below: for each order that happened in autotrading before the restart you can assign a matching ChangeMarketPosition order. In this case in the Assign Initial Market Position dialog you should also choose From Chart.
Sample code (not functional, just an idea):
So to sum it up, the recommendations are as follows:
1) use the From-To data range on the chart;
2) the variables that are not related to orders and positions should have the same or very close values compared to the values that existed before the autotrading termination;
3) to have access to the information about orders and positions (and relate variables)you can trade in AA mode and assign the initial positions From Chart,
Or
Add a special script to the strategy in SA mode that will assign a matching ChangeMarketPosition order for each order from the previous trading session. In this case Assign Initial Market Position = From Chart.
Apart from assigning the position, you can use the !From Broker To Strategy MP Synchronizer! signal.
Also you could trade in asynchronous mode (AA) and pick up the strategy position From Chart as a starting point of calculations.
In synchronous mode (SA) you can add a signal with a logic similar to the sample below: for each order that happened in autotrading before the restart you can assign a matching ChangeMarketPosition order. In this case in the Assign Initial Market Position dialog you should also choose From Chart.
Sample code (not functional, just an idea):
Code: Select all
if date >= date_order1 and time >= time_order1 then
once ChangeMarketPosition( shares_order1, price_order1 ,"name_order1") ;
if date >= date_order2 and time >= time_order2 then
once ChangeMarketPosition( shares_order2, price_order2 ,"name_order2");
1) use the From-To data range on the chart;
2) the variables that are not related to orders and positions should have the same or very close values compared to the values that existed before the autotrading termination;
3) to have access to the information about orders and positions (and relate variables)you can trade in AA mode and assign the initial positions From Chart,
Or
Add a special script to the strategy in SA mode that will assign a matching ChangeMarketPosition order for each order from the previous trading session. In this case Assign Initial Market Position = From Chart.
Re: How to continue my strategy after server restart
A nice solution would be that if autotrading is stopped with positions opened the instances of the strategy objects get serialized to disk. This way all variable values are persevered. Then, when auto trading is re-enabled you get a prompt asking if you want to resume from the saved strategy objects. If the market was open in the meantime the now instantiated strategy objects would be fed all the bars in during its suspension to potentially update any relevant variables. Any orders the strategy object triggers would be ignored (just as if there was a broker connection error) until it reached the current bar.
Re: How to continue my strategy after server restart
Hi,
Another way (which I use) to achieve that is to select Asynchronous mode (AA) together with "Assign initial position" dialogue. That way I keep all the backtest history and calculation persistance. I can switch off autotrading if needed while in position, and resume it as if it did not happen.
Granted, AA mode is not recommended since it does not check for orders confirmation. You need to constantly monitor your strategy.
Yet I do that all the time since I need to manually tweak some inputs while in position, which saddly switches off autotrading. FWIW, MC14 introduced a "Self-Adaptive Trading" feature, which is able to change inputs value without switching off autotrading. Since it is possible, we should be able to just do that with manual changes.
Another way (which I use) to achieve that is to select Asynchronous mode (AA) together with "Assign initial position" dialogue. That way I keep all the backtest history and calculation persistance. I can switch off autotrading if needed while in position, and resume it as if it did not happen.
Granted, AA mode is not recommended since it does not check for orders confirmation. You need to constantly monitor your strategy.
Yet I do that all the time since I need to manually tweak some inputs while in position, which saddly switches off autotrading. FWIW, MC14 introduced a "Self-Adaptive Trading" feature, which is able to change inputs value without switching off autotrading. Since it is possible, we should be able to just do that with manual changes.