Automated Trading - Sync Price and Time

Questions about MultiCharts .NET and user contributed studies.
lordsriram
Posts: 20
Joined: 03 Dec 2018

Automated Trading - Sync Price and Time

Postby lordsriram » 04 Dec 2018

Hi

I enabled automated trading on a strategy that i have back tested. I have a couple of questions on automated trading

1. A strategy buy was initiated at a certain timeframe
2. The buy was executed at the broker
3. I have enabled Assign initial position at broker (with always enabled)
4. Every day or every time, when i have to restart multi charts with IB, the current bar of the day is assumed as the initial position, instead of the bar at which the trade was executed.

How can I make automated trading to determine the bar it executed the trade at the broker and keep it across multiple restart of .Net? My stop loss etc move based on bars since the last trade was executed

Please provide some clarification

Thanks
Sriram

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Automated Trading - Sync Price and Time

Postby Henry MultiСharts » 14 Jan 2019

Hello Sriram,

When auto trading is initially started/restarted in SA mode - the strategy position is flat (zero). If you have an open position at the broker and you want your strategy to continue managing this position - you need to feed this position to the strategy.
When you are trading one instrument using a single strategy/chart only – this can be done automatically.
If you need to split the current position across multiple strategies/charts – you need to specify the position manually for each strategy next time you turn on the auto trading.
Please keep in mind that only the open position information is synchronized (direction, amount of contracts, avg entry price), active price orders you have at broker and bars since entry value cannot be synchronized.

In SA mode you can store the strategy position value and bars since entry or entry date/time value in a text file and then read it back into your code to restore the previous auto trading position state.
In AA mode the backtesting results are still displayed on the chart (calculated in Portfolio) and can be referenced in the code after auto trading was started or restarted.
The bars since entry and the entry date values will be returned based on these backtesting results which may or may not be the same as the actual order execution.
So to save the specific date/time/bar number etc of the order execution you will need to write it into a file or manually input it into your code as an input. Then use this input or variable in your calculations.
You might also find this Forum thread useful: viewtopic.php?t=51494


Return to “MultiCharts .NET”