Auto trading question

Questions about MultiCharts and user contributed studies.
Algyros
Posts: 52
Joined: 28 Sep 2009
Location: Austin, TX
Has thanked: 1 time
Been thanked: 5 times

Auto trading question

Postby Algyros » 17 May 2011

Occasionally, when I'm trading a chart live with autotrader on, no trade will appear. However, when I change the settings (i.e., reset it so that it gets backtrading data), a trade will appear. The trade would also appear if the chart were turned off and then turned on again (again, for the same reason).

This is disturbing because it means that a trade can appear at any time after the chart has been renewed that did not appear in live trading. The result is that live trading results won't be close to backtested results. Consequently, the value of backtesting and optimizing is diminished (because what the backtest showed and what happened in realtime aren't the same).

Is there any way around this? If not, and I ask this not to be contentious but because I truly want to know, what is the value of creating automated systems through backtesting if the won't run live the way they do in backtest mode?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Auto trading question

Postby TJ » 17 May 2011

Occasionally, when I'm trading a chart live with autotrader on, no trade will appear. However, when I change the settings (i.e., reset it so that it gets backtrading data), a trade will appear. The trade would also appear if the chart were turned off and then turned on again (again, for the same reason).

This is disturbing because it means that a trade can appear at any time after the chart has been renewed that did not appear in live trading. The result is that live trading results won't be close to backtested results. Consequently, the value of backtesting and optimizing is diminished (because what the backtest showed and what happened in realtime aren't the same).

Is there any way around this? If not, and I ask this not to be contentious but because I truly want to know, what is the value of creating automated systems through backtesting if the won't run live the way they do in backtest mode?
Stan Bokov explained this in detail recently. I can't find the post at the moment, maybe Stan can find it when he arrives at work tomorrow.

Algyros
Posts: 52
Joined: 28 Sep 2009
Location: Austin, TX
Has thanked: 1 time
Been thanked: 5 times

Re: Auto trading question

Postby Algyros » 17 May 2011

Thanks, TJ. I did a search and didn't find an answer to this question. I'll wait for Stan, of course, but, in the meantime, do you recall enough of his answer to give me the gist?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Auto trading question

Postby TJ » 17 May 2011

Thanks, TJ. I did a search and didn't find an answer to this question. I'll wait for Stan, of course, but, in the meantime, do you recall enough of his answer to give me the gist?
IIRC,

partly has to do with data provider sending different versions of data.
ie. the historic data (refresh) is different from the live stream data.

it also dependents on how you code the strategy,
some conditions might trigger in a historic bar, but not applicable in tick-by-tick real time situation.

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: Auto trading question

Postby Stan Bokov » 17 May 2011

Occasionally, when I'm trading a chart live with autotrader on, no trade will appear. However, when I change the settings (i.e., reset it so that it gets backtrading data), a trade will appear. The trade would also appear if the chart were turned off and then turned on again (again, for the same reason).

This is disturbing because it means that a trade can appear at any time after the chart has been renewed that did not appear in live trading. The result is that live trading results won't be close to backtested results. Consequently, the value of backtesting and optimizing is diminished (because what the backtest showed and what happened in realtime aren't the same).

Is there any way around this? If not, and I ask this not to be contentious but because I truly want to know, what is the value of creating automated systems through backtesting if the won't run live the way they do in backtest mode?

Dear Algyros,

I don't remember where exactly I explained this concept, I can't find the exact post, so I will retype. A couple of things may be at play here. You are probably using Synchronous autotrading mode (SA letters in the top left of your chart), which means you only see on your chart the trades that actually occurred at the broker. This mode is not the same as the backtesting mode, but it ensures that you are always in sync with your broker. The strategy will wait for a confirmation from the broker before posting an arrow on your chart.
There is another mode for autotrading, called asynchoronous autotrading mode (AA). AA mode will display on your chart every trade that is generated by your script regardless of whether it was filled at the broker. This mode is useful when your trading decisions are based on previous trades, but it does not guarantee that you will always be in sync with the broker.

Backtesting will always differ from real trading, it's only an assumption of what 'would have' happened given certain assumptions. The goal of MultiCharts is to minimize these assumptions and to make backtesting as realistic as possible, and the two may get pretty close, but you should still be aware of the differences. For instance, backtesting assumes all of your orders are filled instantly, which may not happen during real trading - there may be a line up of people in front of you, or not enough liquidity. The order may reject your order because the market moved, your internet connection may go down, there could be a number of other possibilities in real trading that prevent your order from getting filled. You should be aware of this possibility.

Some traders complain that trades that 'should have happened' according to backtesting don't happen in real life, and when they turn off autotrading, the trades appear. That may be due to the difficulties I described above, but it also may be due to the fact that backtesting is not being precise enough. In real trading, your scripts are evaluates on a tick-by-tick level, and not every single point between high and low of a bar may be available. Trades also get filled at ask and bid, while most backtesting takes place on Trade prices. When backtesting is not fine-tuned enough, it will give you more optimistic results, and may show you arrows where they would not happen in real life. Here are some things you can do to improve your backtesting results (by improve I mean make them more accurate, and less optimistic), and make your assumptions closer to real life.

First, you need to enable Bar Magnifier. Conventional backtesting on minute, hourly or daily bars will only take into account the OHLC values and it will ignore the price movements within the bar. Bar Magnifier will load up more precise data behind the scenes (to the degree you specify, 1 tick for instance) and even though you may be looking at 1 min bars, the strategy will actually calculate on a tick-by-tick level. IntrabarOrderGeneration mode in your study will allow you to place orders inside the bar, as soon as your condition is met. You can also load up Ask and Bid series, add them to your chart, and use Extended Backtesting to get filled at the more realistic ask and bid prices.

More information on all of these can be found in the Help file, but this is the main intro to it.

asyx
Posts: 27
Joined: 30 Apr 2011
Location: Europe
Has thanked: 57 times
Been thanked: 6 times

Re: Auto trading question

Postby asyx » 18 May 2011

Interesting, thanks.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Re: Auto trading question

Postby Spaceant » 20 May 2011

Stan,

I have been using AA for autotrading for some time. Well, it happened probably twice that the chart was not synchronized with position in broker. There are some reasons that I choose AA instead of SA. The following are two major ones: -

1) In AA, I can view historical trades in any time if I like. (Well, I can live without this as AA may result in a situation that the positions bwteen the chart and broker)

2) Is it possible to synchronize the position that have been opened?
Why is that? May be the position is an overnight opened position or due to some reasons the computer needs to be rebooted.

Can we match the opened position when we activate SA?

sa

Algyros
Posts: 52
Joined: 28 Sep 2009
Location: Austin, TX
Has thanked: 1 time
Been thanked: 5 times

Re: Auto trading question

Postby Algyros » 20 May 2011

Sa,

Could you explain the two reasons you prefer AA again (I'm afraid that I not quite sure I understand)? And, while using AA, do you experience the problem I initially posted about, namely that trades that don't appear in live trading appear when the system is switched to backtesting mode (and vice versa: trades that never appeared in live trading show up when the switch is made to backtesting mode)?

Thanks,
Alex

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: Auto trading question

Postby Stan Bokov » 20 May 2011

Stan,

I have been using AA for autotrading for some time. Well, it happened probably twice that the chart was not synchronized with position in broker. There are some reasons that I choose AA instead of SA. The following are two major ones: -

1) In AA, I can view historical trades in any time if I like. (Well, I can live without this as AA may result in a situation that the positions bwteen the chart and broker)

2) Is it possible to synchronize the position that have been opened?
Why is that? May be the position is an overnight opened position or due to some reasons the computer needs to be rebooted.

Can we match the opened position when we activate SA?

sa
You can use the Assign Initial Market Position (see attached image). It will allow you to sync when you turn on AT.
Attachments
Assign_initial_market_position.png
(77.69 KiB) Downloaded 1046 times

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Re: Auto trading question

Postby Spaceant » 21 May 2011

Sa,

Could you explain the two reasons you prefer AA again (I'm afraid that I not quite sure I understand)? And, while using AA, do you experience the problem I initially posted about, namely that trades that don't appear in live trading appear when the system is switched to backtesting mode (and vice versa: trades that never appeared in live trading show up when the switch is made to backtesting mode)?

Thanks,
Alex
Alex,

I have experienced what you have mentioned, in a few ccasions, but they were not related to AA / SA. As Stan has explained in details, there are a lot of reasons leading to these. You have to locate it youself.

For my experience, my strategy looks at the bar close to see if certain conditions are met, ending up an entry or exit signal. Also, I use IB as my datafeed which doesn't provide the data with timestamp. I have experience in having one machine giving a signal while the other doesn't. These relate to the differience in computer times, resulting in different bar closes. Now, I now use D4 timer sychronizer http://www.thinkman.com/dimension4/ which minimize the difference the time between computers.

Another occasion,before I installed D4, there was an entry while I autotraded, but there was no such entry when I reopened the chart. I then find out the chart was backfilled with a close that was different to the realtraded one. This was probably due to (i) inaccuracy of my computer time or (ii) the CPU was a bit overloaded resulting a lagging behind of data chart plotting. When the chart was backfilled once again, the chart was corrected...... leading to the situation.

All in all, you may have to locate the cause of these youself as you are the person who knows the logic of your code and find out the causes and then minimize the future happening again....

Sa

rondot samuel ws
Posts: 103
Joined: 05 Sep 2007
Has thanked: 8 times
Been thanked: 6 times

Re: Auto trading question

Postby rondot samuel ws » 23 May 2011

Stan,

I have been using AA for autotrading for some time. Well, it happened probably twice that the chart was not synchronized with position in broker. There are some reasons that I choose AA instead of SA. The following are two major ones: -

1) In AA, I can view historical trades in any time if I like. (Well, I can live without this as AA may result in a situation that the positions bwteen the chart and broker)

2) Is it possible to synchronize the position that have been opened?
Why is that? May be the position is an overnight opened position or due to some reasons the computer needs to be rebooted.

Can we match the opened position when we activate SA?

sa
You can use the Assign Initial Market Position (see attached image). It will allow you to sync when you turn on AT.
Hi,
this solution is not realist when you have many workspace, yon CAN'T know the position of every strategy, when MC crash or have to reboot.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Re: Auto trading question

Postby Spaceant » 25 May 2011

Hi,
this solution is not realist when you have many workspace, yon CAN'T know the position of every strategy, when MC crash or have to reboot.
This is quite true!!

Is there any workaround here?? Say, with an option to let MC to assign the position and entry price in SA as of the last theoretical open position, just like what AA does........

Is that possible??

Sa


Return to “MultiCharts”