Double stop orders

Questions about MultiCharts and user contributed studies.
JonMitchell
Posts: 3
Joined: 03 Nov 2015

Double stop orders

Postby JonMitchell » 03 Nov 2015

My code appears to be executing a stop order twice. When I am long, the code should place a stop order every interval. Every time it should place a stop order, two orders are actually entered within a few milliseconds of each other. If I try to close one, it is entered again immediately. Always two orders and never more or less. When the stop price is triggered, one order closes the position and the next reverses it short. So I end up with a reversal instead of closing.

This is for Rithmic and happens on Rithmic paper trading and live trading.

Code: Select all

if marketposition > 0 then begin
sell next bar at entryprice - atr_f1 * AvgTrueRange(atr_len1) stop;
end;
Any ideas?
Last edited by JonMitchell on 03 Nov 2015, edited 1 time in total.

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

Re: Double stop orders

Postby TJ » 03 Nov 2015

My code appears to be executing a stop order twice. When I am long, the code should place a stop order every interval. Every time it should place a stop order, two orders are actually entered within a few milliseconds of each other. If I try to close one, it is entered again immediately. Always two orders and never more or less. When the stop price is triggered, one order closes the position and the next reverses it short. So I end up with a reversal instead of closing.

This is for Rithmic and happens on Rithmic paper trading and live trading.

if marketposition > 0 then begin
sell next bar at entryprice - atr_f1 * AvgTrueRange(atr_len1) stop;
end;

Any ideas?
You need to post more codes. Your snippet does not tell the story.

JonMitchell
Posts: 3
Joined: 03 Nov 2015

Re: Double stop orders

Postby JonMitchell » 03 Nov 2015

The code is known to work and did work for a time but I'm not sure what changed. I can only assume the issue is a MC setting. I can look back in my recent order history and see every time there is a long position, one bar later two stop orders are created. If I try to manually cancel one of them, they are both canceled and created again at next bar. There's no errors or warnings in the logs during that time. If I manually create a stop order, it works fine.

Rick Webber
Posts: 47
Joined: 04 Jan 2008
Has thanked: 21 times
Been thanked: 3 times

Re: Double stop orders

Postby Rick Webber » 12 Nov 2015

I'd like to know the answer to that myself as that happened to me also today using IB's sim account and autotrading.

JonMitchell
Posts: 3
Joined: 03 Nov 2015

Re: Double stop orders

Postby JonMitchell » 12 Nov 2015

I finally found it. You have to use "optimize order flow" in the strategy settings. I don't understand exactly why that fixed it because that setting is supposed to be for how it handles OCO orders. I wasn't trying to do any OCO orders but I guess that setting is needed with Rithmic.

Rick Webber
Posts: 47
Joined: 04 Jan 2008
Has thanked: 21 times
Been thanked: 3 times

Re: Double stop orders

Postby Rick Webber » 12 Nov 2015

Thanks for feedback Jon, I'll try it.


Return to “MultiCharts”