Keeping MC synced with the broker (MarketPosition_at_Broker, etc) - futures io
futures io futures trading



Keeping MC synced with the broker (MarketPosition_at_Broker, etc)


Discussion in MultiCharts

Updated by ABCTG
    1. trending_up 2,185 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 9 replies
    2. attach_file 4 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Keeping MC synced with the broker (MarketPosition_at_Broker, etc)

(login for full post details)
  #1 (permalink)
Montreal, QC
 
 
Posts: 11 since Apr 2014
Thanks: 5 given, 5 received

I've found that if I'm running a strategy and holding a position, but then I restart MC or the strategy, MC gets out of sync with the broker. For example if I'm +1 (long) on an "always in" strategy, and the strategy should short, it sells 1 contract and makes me flat instead of selling 2 to reverse positions to -1, since it's not taking MarketPosition_at_Broker into consideration.

So far my research tells me that doing something like this would likely fix it:
 
Code
variables:
vMktPos( MarketPosition_at_Broker ), 
vMktPosStrat( MarketPosition_at_Broker_for_The_Strategy );

If vMktPos = vMktPosStat then <buy or sell like I usually would do> ;

if vMktPos=1 and vMktPosStrat=0 then <on sell signal, sell short 2 contracts instead of 1>;

and so on...
But are there easier ways to achieve this that require less customized code for each strategy? Off the top of my head:

1) Being able to set MarketPosition_at_Broker_for_The_Strategy to equal MarketPosition_at_Broker would fix this

2) Maybe there is a command to buy/sell short which changes the position based on what MarketPosition_at_Broker is. So for example I could then "Sellshort so that position = -1" and it wouldn't matter if I'm flat or at +1 or at +2, etc, it would just sell the necessary number of contracts so that the position becomes -1.

Any ideas/suggestions? Thanks!

Reply With Quote

Can you help answer these questions
from other members on futures io?
Tradestation behind Firewall
TradeStation
portfolio maestro manage my strategies
TradeStation
Calendar Spread on Weekly Options
The Elite Circle
Scan by comparing SMAs within 5 mins
ThinkOrSwim
Automated Strategies Questions
MultiCharts
 
 
(login for full post details)
  #2 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,187 since Apr 2013
Thanks: 384 given, 1,423 received

jesse514,

what settings are you using in the last part of the Strategy Properties "Auto Trading" tab?

You could also try the build in !From Strategy To Broker MP Synchronizer! and !From Broker To Strategy MP Synchronizer! signals.

Regards,
ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #3 (permalink)
Montreal, QC
 
 
Posts: 11 since Apr 2014
Thanks: 5 given, 5 received


Great! I added the "!From Broker To Strategy MP Synchronizer!" signal and it seems to be exactly what I needed. Thanks again!

As for my signal settings on the Auto-Trading tab, I've attached a screenshot. Would you have me change anything?

Attached Thumbnails
Click image for larger version

Name:	Auto-trading_tab.PNG
Views:	92
Size:	21.4 KB
ID:	144420  
Reply With Quote
 
(login for full post details)
  #4 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,187 since Apr 2013
Thanks: 384 given, 1,423 received

jesse514,

you are welcome. Your automation settings look okay.

If you want you can try out "Async" mode and see how this effects the issue you are currently having.

Regards,
ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #5 (permalink)
Montreal, QC
 
 
Posts: 11 since Apr 2014
Thanks: 5 given, 5 received

ABCTG,

"!From Broker To Strategy MP Synchronizer!" with the default settings of TimeOutMS=250 and LatencyMS=500 has turned out to be behave strangely. Every single trade is doubled in MC's performance report. See attached screenshots of MC history vs the broker's history.

This is simply a MACD always-in reversal system I'm testing. Without the synchronizer it works fine. The strategy began when the broker was +1, so I expected one initial internal sync trade, after which things would function normally since the broker and the strategy were in sync. Would you have any idea of why it is instead behaving like this?

thanks again.

Attached Thumbnails
Click image for larger version

Name:	syncing.png
Views:	39
Size:	44.4 KB
ID:	144471   Click image for larger version

Name:	syncing2.png
Views:	33
Size:	7.0 KB
ID:	144472  
Reply With Quote
 
(login for full post details)
  #6 (permalink)
Montreal, QC
 
 
Posts: 11 since Apr 2014
Thanks: 5 given, 5 received

According to this thread, it is likely a latency issue: https://www.multicharts.com/discussion/viewtopic.php?f=5&t=9905

However this thread also mentions ChangeMarketPosition which is perhaps what I should be using. Something like this:

 
Code
if MarketPosition_at_Broker <> MarketPosition_at_Broker_for_The_Strategy then
ChangeMarketPosition( MarketPosition_at_Broker, etc ..........

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,187 since Apr 2013
Thanks: 384 given, 1,423 received

jesse514,

you might want to limit the ChangeMarketPosition execution to once when you start (restart) the signal. Also using this check means you should avoid trading the same market from more than one chart.

Regards,
ABCTG


jesse514 View Post
According to this thread, it is likely a latency issue: https://www.multicharts.com/discussion/viewtopic.php?f=5&t=9905

However this thread also mentions ChangeMarketPosition which is perhaps what I should be using. Something like this:

 
Code
if MarketPosition_at_Broker <> MarketPosition_at_Broker_for_The_Strategy then
ChangeMarketPosition( MarketPosition_at_Broker, etc ..........


Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #8 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,187 since Apr 2013
Thanks: 384 given, 1,423 received

jesse514,

did you try using the assign the initial market position at broker dialog?



This gives you the ability to align the chart position with the broker position.

Regards,
ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #9 (permalink)
Montreal, QC
 
 
Posts: 11 since Apr 2014
Thanks: 5 given, 5 received

Ah, the "assign the initial market position at broker dialog" definitely seems like a simple solution! I'll only bother with the more complicated coded solutions if I find scenarios where the strategy and broker get out of sync on their own.

I suppose if a bracket order gets triggered during a disconnection from the broker things would get out of sync. It would be nice if there was a simple setting to always assign market position based on broker, not only when starting strategy, and not through a dialog. But I guess that requires some code.

Thanks again ABCTG.

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,187 since Apr 2013
Thanks: 384 given, 1,423 received


jesse514,

we could gather a couple of scenarios of what could happen and how to deal with it. This should be of general interest to many.

Your situation with the bracket order and disconnection would be something to try out in a simulated environment. When you get a disconnection that turns your strategy automation off, there is not much you can do from the strategy code anymore anyway.

Regards,
ABCTG

Follow me on Twitter Visit my Facebook Reply With Quote


futures io Trading Community Platforms and Indicators MultiCharts > Keeping MC synced with the broker (MarketPosition_at_Broker, etc)


April 22, 2014


Upcoming Webinars and Events
 

Relative Rotation Graphs w/Julius de Kempenaer

Elite only
 

Every journal equals ten meals for the hungry

Now
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts