Auto trading in replay - positions don't reverse

Questions about MultiCharts and user contributed studies.
MCuser123
Posts: 3
Joined: Jul 26 2024

Sep 07 2024

I'm observing a peculiar behavior when I run replay with my strategies. When a long signal is followed by a short signal, the short signal acts as a stop and just closes the long position, instead of reversing and opening a short position. Should be as simple as sell short contract count x 2, rather than x 1. The same thing with short followed by a long. The strategies just never reverse, there is always a flat period between entries. This makes replay unusable for strategies that don't rely on stops and are always in the market. Is there a setting controlling that, which I'm not aware of? Or is this a bug?

User avatar
TJ
Posts: 7775
Joined: Aug 29 2006
Location: Global Citizen
Has thanked: 1036 times
Been thanked: 2233 times

Sep 08 2024

This is a coding issue.
Please post your codes.

MCuser123
Posts: 3
Joined: Jul 26 2024

Sep 08 2024

Code: Select all

if BuyCondition then begin buy("LE") this bar on close; end else if SellshortCondition then begin sellshort("SE") this bar on close; end else if SellCondition then begin sell("LX") this bar on close; end else if BuytocoverCondition then begin buytocover("SX") this bar on close; end;
I'm trading futures. Sellshort I expect to reverse a long position. It does work in real trading as expected by sending a 2 x position size sell order.

PeterSt
Posts: 33
Joined: Jun 18 2024
Has thanked: 5 times
Been thanked: 11 times

Sep 08 2024

Should be as simple as sell short contract count x 2, rather than x 1.
It is as simple as Sell Short Contract count x 1. This will immediately Reverse.
I think it may depend on the Broker - with IBKR this is so. Without Broker, default MC behaves the same (not even sure this is settable).

MCuser123
Posts: 3
Joined: Jul 26 2024

Sep 12 2024

Weirdly, this behavior depends on the option "Preferences >> Trading >> Simulated Trading >> Start Simulated Trading Automatically". At least after I turn it off, positions start to reverse as expected. Not sure if this particular option matters, or just a change in setting that triggers some cache flush or whatever. Not sure if anyone from MC support is watching these threads, as I couldn't figure out how to submit a bug request to their Project Management portal.

User avatar
Polly MultiCharts
Posts: 282
Joined: Jul 20 2022
Has thanked: 2 times
Been thanked: 68 times

Sep 13 2024

Dear Users,

If you’d like us to check the issue in detail, please send us the following files to our support email so that we would be able to investigate the issue:
  1. The workspace where the issue is reproduced.
  2. Export of used symbols (with data) from QuoteManager in .qmd archive.
  3. The exported scripts with all dependent functions that are used on the workspace.
  4. The screenshots demonstrating the issue.
  5. Step-by-step instruction on how to reproduce the issue and the time when Simulated Trading is started from.