Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Keeping MC synced with the broker (MarketPosition_at_Broker, etc)
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:
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.
"!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?
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.
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.
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.