Trading one symbol with two strategies

Questions about MultiCharts and user contributed studies.
User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Trading one symbol with two strategies

Postby MC_Prog » 09 Dec 2014

Hi.

I have a strategy I would like to apply twice to the same symbol (with different settings) and have it auto-trade.

My goal could be thought of as having a short-target strat and a long-target strat both active at once (but not necessarily entering at the same time).

I'm willing to put two strats on one chart, or two strats on two charts, or use the portfolio trader - whatever works reliably and cleanly.

Can anyone speak from experience about doing something like this?

What is a known good setup (and even what are known bad setups, if any) for accomplishing this?

Thanks!

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

Re: Trading one symbol with two strategies

Postby TJ » 09 Dec 2014

Hi.

I have a strategy I would like to apply twice to the same symbol (with different settings) and have it auto-trade.

My goal could be thought of as having a short-target strat and a long-target strat both active at once (but not necessarily entering at the same time).

I'm willing to put two strats on one chart, or two strats on two charts, or use the portfolio trader - whatever works reliably and cleanly.

Can anyone speak from experience about doing something like this?

What is a known good setup (and even what are known bad setups, if any) for accomplishing this?

Thanks!
No experiences to share...
Just asking to make sure you have got this covered,

Have you read the wiki doc on trading 2 strat on same symbol?

If you have, you should know what to expect and what needs to be done.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 09 Dec 2014

Hi. I would expect that something has been written somewhere about this, but I'm having a difficult time turning it up either on the Forum or in the Wiki.

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

Re: Trading one symbol with two strategies

Postby TJ » 09 Dec 2014

Hi. I would expect that something has been written somewhere about this, but I'm having a difficult time turning it up either on the Forum or in the Wiki.
Trading from Multiple Charts on One Instrument
https://www.multicharts.com/trading-sof ... Instrument

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Trading one symbol with two strategies

Postby MAtricks » 09 Dec 2014

I have many strategies on one symbol. There's no issue to speak of.. No coding or settings needed. Just use different chart windows.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 09 Dec 2014

Thanks TJ and MAtricks!

The information seems encouraging!

I did ask again here:

viewtopic.php?f=1&t=10204&p=111289#p111289

because it turns out Xyzzy has asked my exact question there, but the thread stopped without a reply to his last post.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Trading one symbol with two strategies

Postby orion » 09 Dec 2014

MC_Prog, I have not tried this but the following is my understanding.

MAtricks, since you have been doing this, can you please let us know whether following points are correct for two charts trading same symbol in SA mode:

1. marketPosition keyword in one chart will return the market position for that chart and will not see any market positions opened by strategy on other chart.

2. marketPosition keyword on chart will not be synchronized with marketPosition_at_broker since multiple charts are being used to trade.

3. market positions for either chart are not messed up by any market positions opened by manual trading. You may even have a manual trade that trades in opposite direction to strategy on chart and by so doing it makes the broker position flat but the chart position will stay as is.

4. setStopLoss and setProfitTarget brackets for an entry in one chart will not interfere with those from setStopLoss and setProfitTarget brackets for an entry on other chart. Both brackets will remain pending at broker. Furthermore, the brackets will remain pending even if you traded manually and made the broker position flat with manual trading.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Trading one symbol with two strategies

Postby MAtricks » 09 Dec 2014

I understand that there must be confusion here, but as I said there is nothing needed except separate charts. The charts are independent of each other. Market position and Profit targets are independent to the chart they're applied to.

Create a few charts and give it a go :) I have 20 strats on one symbol..

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Trading one symbol with two strategies

Postby orion » 09 Dec 2014

Trading from Multiple Charts on One Instrument
https://www.multicharts.com/trading-sof ... Instrument
TJ, thanks for bringing this up. I think this wiki entry is accurate but is a red herring by virtue of its sins of omission if the points I made in my previous post are correct. In addition to those points, I believe the following apply as well:

1. These strategy synchronizers will force the marketPosition keyword for the strategy to synchronize with the position returned by marketPosition_at_broker.

2. It is not necessary for marketPosition keyword in the chart to be synced with marketPosition_at_broker if your strategy code only references marketPosition. So you can trade multiple charts on the same symbol without using these synchronizers.

MAtricks, can you please advise on the truth value of the above statements since you have practical experience with this. Cheers.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Trading one symbol with two strategies

Postby MAtricks » 09 Dec 2014

I have no experience using the Marketposition_at_Broker so I cannot answer this. I see no need for this in my code.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Trading one symbol with two strategies

Postby orion » 09 Dec 2014

I have no experience using the Marketposition_at_Broker so I cannot answer this. I see no need for this in my code.
Thanks. You answer addresses a lot of the source of potential confusion. Andrew or Henry can hopefully advise to the accuracy of the rest of the points in posts #7 and #9 above.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Trading one symbol with two strategies

Postby MAtricks » 09 Dec 2014

My suggestion:

Create five 1 minute charts with different strategies on them. Apply them to a demo account. Click the SA button. And you will have the easy answer that I've been trying to relay :)

You're making it a lot harder than it is.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Trading one symbol with two strategies

Postby Andrew MultiCharts » 10 Dec 2014

Hello everyone,
1. marketPosition keyword in one chart will return the market position for that chart and will not see any market positions opened by strategy on other chart.
That is correct.
2. marketPosition keyword on chart will not be synchronized with marketPosition_at_broker since multiple charts are being used to trade.
That is correct.
3. market positions for either chart are not messed up by any market positions opened by manual trading. You may even have a manual trade that trades in opposite direction to strategy on chart and by so doing it makes the broker position flat but the chart position will stay as is.
That is correct. Manual trading has its own market position, not accessible from a code. MarketPosition_at_broker will see the net positions, which may be formed by all strategy orders (sent from any chart) and manual orders (again sent from any chart). Please be careful with "...have a manual trade that trades in opposite direction to strategy on chart..."
4. setStopLoss and setProfitTarget brackets for an entry in one chart will not interfere with those from setStopLoss and setProfitTarget brackets for an entry on other chart. Both brackets will remain pending at broker. Furthermore, the brackets will remain pending even if you traded manually and made the broker position flat with manual trading.
That is correct.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 10 Dec 2014

I'm lovin' what I'm reading above, both the "it just works" aspect, and the detailed Q&A. Many thanks!

Hopefully I will be able to add my own experiences here in the not-too-distance future.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 10 Dec 2014

OK, did my first run this AM. Used same strat, different settings, on two charts with the same symbol. Broker was IB, via standalone TWS running on the same machine as MC 9.0.

The entries and exits did all take place where they were supposed to. (Nice!)

However, the displays during the life of the trade were quite confusing to me.

With Chart Trading set on each chart to 'Show Open Positions' and 'Show Active Orders' what I got was each chart showing ALL entry and exit lines.

What I would have liked to see is each chart showing only the entry/exit lines for the strategy running on that chart.

Is that possible at this point in time?

If not, would it perhaps be possible as a future enhancement (or would that be contrary to design principles MC has decided to settle on)?

P.S. Probably the current behavior is exactly what some people would prefer, but I think having each chart just show it's own situation (rather than a global situation) is something that many others would agree is desirable, as an option, for those who wish it.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 10 Dec 2014

A separate issue is that as soon as the 2nd chart puts on a trade (while the first chart still has a trade open), the reference line for position entry (and current open P&L) becomes the average price for the two positions.

Again, some might like this, but I find it very confusing.

Is it possible at the current time to configure so that each chart tracks, displays, and references it's own entry price?

If not, would it perhaps be possible as a future enhancement (or would that be contrary to design principles MC has decided to settle on)?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Trading one symbol with two strategies

Postby Andrew MultiCharts » 10 Dec 2014

With Chart Trading set on each chart to 'Show Open Positions' and 'Show Active Orders' what I got was each chart showing ALL entry and exit lines.

What I would have liked to see is each chart showing only the entry/exit lines for the strategy running on that chart.

Is that possible at this point in time?
Unfortunately it is not possible at the moment, it shows all positions and all orders (assuming the market and the broker account is the same).
If not, would it perhaps be possible as a future enhancement (or would that be contrary to design principles MC has decided to settle on)?

P.S. Probably the current behavior is exactly what some people would prefer, but I think having each chart just show it's own situation (rather than a global situation) is something that many others would agree is desirable, as an option, for those who wish it.
Please leave us such feature request.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Trading one symbol with two strategies

Postby orion » 10 Dec 2014

A separate issue is that as soon as the 2nd chart puts on a trade (while the first chart still has a trade open), the reference line for position entry (and current open P&L) becomes the average price for the two positions. Again, some might like this, but I find it very confusing.

Is it possible at the current time to configure so that each chart tracks, displays, and references it's own entry price?
I have not been able to do the experiment since all my licenses are in use. Thanks for posting your results and thanks to Andrew for responding.

MC_Prog, are you saying that if chart A strategy code makes an entry at 50 and then later chart B strategy code makes an entry at 60 then the EntryPrice keyword in both will return 55 instead of their individual values? I believe following should be valid though I have not done this experiment yet.

1. All Strategy Performance keywords and all Strategy Position keywords (keywords such as EntryPrice, BarsSinceEntry, CurrentShares, PositionProfit, OpenPositionProfit, ...) return the values for the respective chart strategies. It would not make sense for them to reflect the values from the other strategy. Correct?

2. The only keywords in these two categories that should reflect the aggregate state should be MarketPosition_at_Broker and AvgEntryPrice_at_Broker. Keywords from the Accounts and Positions category should also reflect the global sate. Correct?


Links to these keyword groups:
http://www.multicharts.com/trading-soft ... erformance
http://www.multicharts.com/trading-soft ... y_Position
http://www.multicharts.com/trading-soft ... _Positions

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 10 Dec 2014

A separate issue is that as soon as the 2nd chart puts on a trade (while the first chart still has a trade open), the reference line for position entry (and current open P&L) becomes the average price for the two positions.
Here I am referring to the line and price value displayed on the chart which is intended to show the level of entry and the open P&L.

This is the line enabled/disabled from the Format Chart Trading dialog by checking/unchecking 'Show Open Positions'.

AFAIK, Orion, your #1 and #2 above are correct.
Last edited by MC_Prog on 10 Dec 2014, edited 1 time in total.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Trading one symbol with two strategies

Postby MAtricks » 10 Dec 2014

I like where you're going with this. I've wished for quite some time that each window would be completely independent of the others. I'd like to access the average market position, but not have it as the only available feature. If a strategy has resting orders or a position, only its window should show these.

Where I see MC needing work is the Order and Position Tracker. When you have multiple positions in one symbol, its performance is quite odd. I don't think these features were ever tested in an environment like what we're doing.

Honestly though, once you get used to it, you'll be fine with it. Regardless of the averaged market position, your windows strategy position is independent and doesn't use this unless its meant to.


Try this: Format Chart Trading -> Connecting Line tab -> Uncheck Show Connecting Line. Doing this will give you lines from trades generated from that window only. This helps with confusion.

Since I run so many strategies on each symbol, I turn off all features of a chart. No orders or trades show at all. These 'trade windows' are very small. I have one window for each symbol which is a bit larger than the rest which shows the orders, positions, and trade lines for all strategies.

I have a decent amount of experience with this stuff so if there are any specific questions, I'd be glad to help out where I can. AFTER I have a coffee! :) I was up all night working and my guess is that none of this made much sense haha

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 10 Dec 2014

I've wished for quite some time that each window would be completely independent of the others. I'd like to access the average market position, but not have it as the only available feature. If a strategy has resting orders or a position, only its window should show these.
Yes, that would be my preference also.
Last edited by MC_Prog on 10 Dec 2014, edited 1 time in total.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 10 Dec 2014

Try this: Format Chart Trading -> Connecting Line tab -> Uncheck Show Connecting Line. Doing this will give you lines from trades generated from that window only. This helps with confusion.
Indeed, was set up that way. When all was done the connecting lines were as desired/expected.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Trading one symbol with two strategies

Postby Andrew MultiCharts » 15 Dec 2014

1. All Strategy Performance keywords and all Strategy Position keywords (keywords such as EntryPrice, BarsSinceEntry, CurrentShares, PositionProfit, OpenPositionProfit, ...) return the values for the respective chart strategies. It would not make sense for them to reflect the values from the other strategy. Correct?

2. The only keywords in these two categories that should reflect the aggregate state should be MarketPosition_at_Broker and AvgEntryPrice_at_Broker. Keywords from the Accounts and Positions category should also reflect the global sate. Correct?

Links to these keyword groups:
http://www.multicharts.com/trading-soft ... erformance
http://www.multicharts.com/trading-soft ... y_Position
http://www.multicharts.com/trading-soft ... _Positions
  1. Yes, such keywords return values from the specific chart, where they are applied only.
  2. "at_Broker" keywords get their values from (surprise!) broker, not from chart.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 15 Dec 2014

Just to mention, my own single-symbol multi-chart trading continues with all entry and exit orders working well as per advice above.

The displays are not "this chart's strategy only" as I would prefer (and I will write a feature request for that sometime soon), but the actual trading is doing what's needed and expected.

Bravo MC!

TA100
Posts: 54
Joined: 10 Feb 2014
Has thanked: 39 times
Been thanked: 9 times

Re: Trading one symbol with two strategies

Postby TA100 » 15 Dec 2014

I like where you're going with this. I've wished for quite some time that each window would be completely independent of the others. I'd like to access the average market position, but not have it as the only available feature. If a strategy has resting orders or a position, only its window should show these.
MATricks, thanks for your info on this - could you just explain if your trading 20 strats on same symbol and same account - say your long 10 and short 10 (if you had the actual entries showing) they would each show their respective entries and exits (you would have all 20 entries and exits on each chart unless as you do choose not to show them) but in fact your net position as reported by Order & Position Tracker would be zero?

In addition, how would that alter if in AA mode rather than SA mode (if at all).

Thanks
Michael

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Trading one symbol with two strategies

Postby MAtricks » 15 Dec 2014

If you have 10 strats that are long and 10 that are short, your broker position is flat. This is exactly as simple as it sounds. While running multiple strats on one symbol, remember not to pay attention to the Open Positions tab in the Order and Position tracker, but to pay attention to the Strategy Positions tab.

Each independent strategy will have its independent exit which will create the expected broker position change.

SA gives me a warm and fuzzy feeling because its calculated from the broker position :). Picking SA over AA is entirely personal preference. This choice will not affect what we're talking about.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Trading one symbol with two strategies

Postby Andrew MultiCharts » 17 Dec 2014

MATricks, thanks for your info on this - could you just explain if your trading 20 strats on same symbol and same account - say your long 10 and short 10 (if you had the actual entries showing) they would each show their respective entries and exits (you would have all 20 entries and exits on each chart unless as you do choose not to show them) but in fact your net position as reported by Order & Position Tracker would be zero?
If you have 10 strats that are long and 10 that are short, your broker position is flat. This is exactly as simple as it sounds. While running multiple strats on one symbol, remember not to pay attention to the Open Positions tab in the Order and Position tracker, but to pay attention to the Strategy Positions tab.

Each independent strategy will have its independent exit which will create the expected broker position change.
You got "A" for "Auto-trading" subject.
In addition, how would that alter if in AA mode rather than SA mode (if at all).
SA gives me a warm and fuzzy feeling because its calculated from the broker position :).
Ok, it is "A-" now. In SA it is supposed to start in sync with broker position, if so then it will be in sync, however in fact there is no actual forced synchronization. The only 2 things that should be taken into account is that you will see "False" in position match in Order and Position Tracker (doesn't really affect anything) and that you should be careful with using "_at_broker" keywords.
Picking SA over AA is entirely personal preference. This choice will not affect what we're talking about.
That is true. Any of the modes can be used if we are talking about auto-trading from multiple charts (same market, same account).

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Trading one symbol with two strategies

Postby orion » 18 Dec 2014

Andrew, using two strategies S1 and S2 to trade same symbol in PT is a bit different than using charts since the 'Show the assign the initial market position' dialog is not available.

I want to check on how to make this work for PT assuming strategies are not flat at end of trading session and the PT is restarted when new session begins. My thinking is to use the automatic sync option 'Use the actual position at the broker'. Lets say the actual position at broker was +3 at end of last session but respective strategy positions were +5 and -2. Questions:

1) What is expected behavior with S1 and S2 market positions on restart when you do 'Use the actual position at the broker'? Do they both get marketPosition = 1 and currentContracts = 3?

2) I am thinking of using changeMarketPosition keyword in S1 and S2 to bring them in line with what they actually were at end of last session. I am assuming this will work and it will not place any actual orders with the broker?

3) Will changeMarketPosition change both marketPosition and currentContracts?

4) If using SA mode, does changeMarketPosition also change marketPosition_at_broker_for_the_strategy?

Thanks.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Trading one symbol with two strategies

Postby MC_Prog » 18 Dec 2014

I have posted a feature request:

MC-1816 - Independence of Charts wrt. Order and Position Display

https://www.multicharts.com/pm/viewissu ... no=MC-1816

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Trading one symbol with two strategies

Postby Andrew MultiCharts » 22 Dec 2014

I want to check on how to make this work for PT assuming strategies are not flat at end of trading session and the PT is restarted when new session begins. My thinking is to use the automatic sync option 'Use the actual position at the broker'. Lets say the actual position at broker was +3 at end of last session but respective strategy positions were +5 and -2. Questions:

1) What is expected behavior with S1 and S2 market positions on restart when you do 'Use the actual position at the broker'? Do they both get marketPosition = 1 and currentContracts = 3?
In both modes, the strategy positions will be +3 if 'Use the actual position at the broker' is selected.
2) I am thinking of using changeMarketPosition keyword in S1 and S2 to bring them in line with what they actually were at end of last session. I am assuming this will work and it will not place any actual orders with the broker?
Yes, i believe it will work as a workaround for your case.
3) Will changeMarketPosition change both marketPosition and currentContracts?
In AA mode: it will work only for MarketPosition_at_broker_for_the_Strategy.
In SA mode: yes, both for MarketPosition and CurrentContracts (and MarketPosition_at_Broker_for_the_Strategy).
4) If using SA mode, does change MarketPosition also change marketPosition_at_broker_for_the_strategy?
Yes. In fact it changes exactly the MarketPosition_at_Broker and other keywords are synced with it.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Trading one symbol with two strategies

Postby orion » 22 Dec 2014

Thank you Andrew for answering all the questions. This is all now crystal clear for both chart based trading and portfolio trading.

pedro565
Posts: 12
Joined: 15 Aug 2015
Has thanked: 1 time

Re: Trading one symbol with two strategies

Postby pedro565 » 15 Oct 2015

Sorry for resurrecting this somewhat old thread but I want to do something similar but do it in a different way.

Is it possible to have multiple strategies on one instrument but have them in the same chart *AND* use different, specific profit targets and stops for each strategy running? I know that setprofittarget is a global command for all strategies in the chart, but is there a way to make it specific? Perhaps by mentioning the name of the buy/short order?

Thanks in advance for your help.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Trading one symbol with two strategies

Postby orion » 17 Oct 2015

No, you can't do that.

On a related point but different point, note that in MC parlance, a strategy is a chart (aka symbol) and the signals applied to the chart. It is common to confuse the terms signal and strategy. When two or more signals are applied to a chart, they interact and make up a single strategy.


Return to “MultiCharts”