Auto Trading Order Time Help

Questions about MultiCharts and user contributed studies.
o2cool
Posts: 9
Joined: 29 Nov 2022
Has thanked: 1 time
Been thanked: 1 time

Auto Trading Order Time Help

Postby o2cool » 23 Dec 2022

Hello,

I’m a newbie to muilticharts. Been trying for two weeks to figure this out.

I cannot seem to get auto trading setup correctly for a simple strategy in portfolio trader. I must be missing something.

The strategy trades some US ETFs and stocks on the daily chart. In the strategy, once the conditions are met, I use a simple “buy next bar at market”. I setup all of the symbols to have a 9:30am-4pm session time. I am in the same time zone as the exchange. Backtesting works perfectly. In the script, I’ve included a print command to show orders in the output log. Most timestamps for trades happen at 4:00pm, although some seem to happen at 2:00am (I don’t know why).

My broker connection seems to be working fine. I can send orders using the trade bar and it all works as expected.

What I am trying to find out here, is when the orders are sent to the broker (using the simple "buy next bar at market")? Is it suppose to happen at 4:00pm close? Does something happen at 2:00am like the log seems to say? Does it happen at open?

I’ve tried running auto trade at the open and today at the close but nothing happens. All I really need is to run the system for 5 mins a day to send orders (whenever that is suppose to occur).

Any help anybody could provide or suggest would be super appreciated.

Luto
Posts: 9
Joined: 18 May 2022
Has thanked: 3 times

Re: Auto Trading Order Time Help

Postby Luto » 23 Dec 2022

It might be that you are using daily bars. So, it means your order goes in at the close of the bar. But you have a DAY order. which will then get canceled.

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: Auto Trading Order Time Help

Postby rrams » 24 Dec 2022

Hi o2cool,

You actually are learning the right way by starting with a simple trading strategy on a longer time scale with few symbols and forward testing on a demo account. Imagine if you wasted a year building and backtesting a sophisticated strategy only to discover how different it behaves in real-time.

We can't tell what happened without looking at the logs, but it could be that some of those ETF symbols stoped making trade quotes before the end of the day bar time finish. That could make it hang there until a refresh or history revision at 2:00am closed the bar and sent orders.

If you don't want to keep your computer on 24hrs then you should re-write the strategy to trade intraday but taking signals from a daily time frame.

o2cool
Posts: 9
Joined: 29 Nov 2022
Has thanked: 1 time
Been thanked: 1 time

Re: Auto Trading Order Time Help

Postby o2cool » 24 Dec 2022

Thanks for the info! Taking it in, maybe this would work?

To buy intraday at the open I can add the simple code "if time = 09:30:05 then begin" and "IntrabarOrderGeneration = True". The entry conditions can be updated to refer back to the previous daily bars.

If I understand correctly the script will run once at 9:30:05. It will check prior daily bars to determine orders, and then send orders to the broker on the next tick (because intrabar is on). Because the script uses past daily bars to determine orders, doesn't need any data about what is happening at the open, and is allowed to purchase within a daily bar, it can keep using just daily bar data.

If any of this actually works, it begs the question: does multicharts required live data to execute? I have live IB data and can use that to feed it daily data, but if the above doesn't work and I have to start going into intraday 1 min bars or whatever IB data seems to totally fail. I'm finding it takes hours to load.

Thanks again for any info!

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: Auto Trading Order Time Help

Postby rrams » 25 Dec 2022

o2cool,

Yes, MultiCharts needs a live data feed to autotrade because signals are processed at the end of a new bar. You can't just click the Automate Order Execution button once at the beginning or end of the session.

I do not advise that you try to use IntraBarOrderGeneration until you have more experience or you will wonder why multiple duplicate orders are getting sent.

Daily bars are still considered real time and should execute from a signal either at the end of the day session or the beginning of the next. You just need to leave Portfolio Trader and TWS running with Automate Order Execution turned on.

I can test trade this scenario if you supply the list of symbols that are giving you a problem and how many Bars Back your strategy requires.

o2cool
Posts: 9
Joined: 29 Nov 2022
Has thanked: 1 time
Been thanked: 1 time

Re: Auto Trading Order Time Help

Postby o2cool » 25 Dec 2022

So intrabar is trouble. Will forget it for now.

If I understand what you’re saying correctly, the autotrader needs to be on continuously from the time the signal is calculated to the time the order is sent? So in this case, from just before the close, through the entire night, to just past the next day’s open?

Seems like using two data series might be best then. Maybe 1 sec and daily. Process the orders on the 1 sec, turn it on just before the open (or at anytime during the day really), and have all the conditions use the daily.

In this case, is there a way to limit how much data is requested from IB for each data series? For the sec data series, all I really need 5-10 bars maybe? Hopefully, this should avoid the limits with IB’s data. For the daily I use the 200 SMA so would need more.

Thanks again for all the help. Really, it is immensely appreciated!!


Return to “MultiCharts”