Automatic OCO order?

Questions about MultiCharts and user contributed studies.
firemag
Posts: 43
Joined: 15 Sep 2017
Has thanked: 9 times
Been thanked: 2 times

Automatic OCO order?

Postby firemag » 02 Jan 2018

I have a strategy that sends two breakout buy/sell stop orders, i.e., one long and one short. This is what I see when the orders go in:
2018-01-02_5-01-38.jpg
(72.63 KiB) Downloaded 736 times
In the orders tab I see:
2018-01-02_5-05-16.jpg
(57.9 KiB) Downloaded 737 times
There is an OCO ID for these two orders. Does this mean that MC automatically converted the two buy/sell stops to an OCO order? That would be the intention for this strategy, but just wanted to confirm.

firemag
Posts: 43
Joined: 15 Sep 2017
Has thanked: 9 times
Been thanked: 2 times

Re: Automatic OCO order?

Postby firemag » 02 Jan 2018

The buy-stop just hit its price and entered a position. And the sell-stop was canceled, confirming that this was an OCO order. However, MC put in a new sell-stop position for double the contracts. (Original positions were for 3 contracts)
2018-01-02_8-15-00.jpg
(74.08 KiB) Downloaded 735 times
Rather than *no* sell-stop (because it was canceled), there is now a sell-stop with 6 contracts.

The cancel order:
2018-01-02_8-35-50.jpg
(46.82 KiB) Downloaded 735 times
But then there is a new order for double the contracts:
2018-01-02_8-40-50.jpg
(46.37 KiB) Downloaded 735 times
The entry code is pretty straightforward:

Code: Select all

If SignalDay then
begin
if ( MarketPosition <> 1 ) then
Buy next bar at LBreakoutPrice stop;

if ( MarketPosition <> -1 ) then
Sellshort next bar at SBreakoutPoints stop ;
end;
After one of the stops is hit, does MC reevaluate the strategy code for the bar? Could it be hitting the SellShort statement again, or is there something else going on behind-the-scenes? Either way, I don't understand why the contracts doubled from 3 to 6.

Any idea?

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

Re: Automatic OCO order?

Postby TJ » 02 Jan 2018

. . .


The entry code is pretty straightforward:

Code: Select all

If SignalDay then
begin
if ( MarketPosition <> 1 ) then
Buy next bar at LBreakoutPrice stop;

if ( MarketPosition <> -1 ) then
Sellshort next bar at SBreakoutPoints stop ;
end;
After one of the stops is hit, does MC reevaluate the strategy code for the bar? Could it be hitting the SellShort statement again, or is there something else going on behind-the-scenes? Either way, I don't understand why the contracts doubled from 3 to 6.

Any idea?

The computer is dumb.
It will do EXACTLY what you tell it to do.

It will continue to do what you tell it to do...
until you tell it not to do anymore, or if you don't tell it to do anything.

Each instruction is good for ONE bar -- the current bar.
The instruction will REPEAT every tick, until the end of the bar.

firemag
Posts: 43
Joined: 15 Sep 2017
Has thanked: 9 times
Been thanked: 2 times

Re: Automatic OCO order?

Postby firemag » 02 Jan 2018

The computer is dumb.
It will do EXACTLY what you tell it to do.

It will continue to do what you tell it to do...
until you tell it not to do anymore, or if you don't tell it to do anything.

Each instruction is good for ONE bar -- the current bar.
The instruction will REPEAT every tick, until the end of the bar.
Yep, totally agree with you about computers -- GIGO.

But your assessment that the code is repeated with every TICK... that doesn't make sense. If so, then the sellshort line of code would have been repeated 3 x TICKS since the position was opened, which it is obviously not doing. There were be a huge number of sellshort contracts if that were the case.

So, in this case, it's not so much that computers are dumb, but that I (all of us actually) need to have a better understanding of what is going under the hood of MC in order to code the strategy in the way I expect it to behave.

So, again... how is it that, after the OCO order was canceled, that MC generated a new sell-stop order for double the contracts?

That's getting under the hood...

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

Re: Automatic OCO order?

Postby TJ » 02 Jan 2018

The computer is dumb.
It will do EXACTLY what you tell it to do.

It will continue to do what you tell it to do...
until you tell it not to do anymore, or if you don't tell it to do anything.

Each instruction is good for ONE bar -- the current bar.
The instruction will REPEAT every tick, until the end of the bar.
Yep, totally agree with you about computers -- GIGO.

But your assessment that the code is repeated with every TICK... that doesn't make sense. If so, then the sellshort line of code would have been repeated 3 x TICKS since the position was opened, which it is obviously not doing. There were be a huge number of sellshort contracts if that were the case.

So, in this case, it's not so much that computers are dumb, but that I (all of us actually) need to have a better understanding of what is going under the hood of MC in order to code the strategy in the way I expect it to behave.

So, again... how is it that, after the OCO order was canceled, that MC generated a new sell-stop order for double the contracts?

That's getting under the hood...

Orders are sent at EOB (End of Bar)
unless you have set IOG (IntrabarOrderGeneration=True)

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

Re: Automatic OCO order?

Postby TJ » 02 Jan 2018

. . .

So, again... how is it that, after the OCO order was canceled, that MC generated a new sell-stop order for double the contracts?

That's getting under the hood...

SELLSHORT is an entry keyword. It will flatten your position before going short.

SELL is used to exit your positions.

firemag
Posts: 43
Joined: 15 Sep 2017
Has thanked: 9 times
Been thanked: 2 times

Re: Automatic OCO order?

Postby firemag » 02 Jan 2018

Orders are sent at EOB (End of Bar)
unless you have set IOG (IntrabarOrderGeneration=True)
IOG is not enabled. However, the only way I can figure a sell-stop entry being put in by MC for 6 contracts after canceling the OCO order is if it re-evaluated the bar. If it did this, then the 6 contracts makes sense -- the stop is treated as a reversal signal: sell 3 contracts (since I am currently long 3) and then short 3 (to honor the original sell-stop order for 3 contracts).

So did MC re-evaluate the bar after the buy-stop was hit (which I am thinking not since, as you mention, this bar should only be evaluated once at close), or did it perform some underlying logic behind-the-scenes?

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

Re: Automatic OCO order?

Postby TJ » 03 Jan 2018

Orders are sent at EOB (End of Bar)
unless you have set IOG (IntrabarOrderGeneration=True)
IOG is not enabled. However, the only way I can figure a sell-stop entry being put in by MC for 6 contracts after canceling the OCO order is if it re-evaluated the bar. If it did this, then the 6 contracts makes sense -- the stop is treated as a reversal signal: sell 3 contracts (since I am currently long 3) and then short 3 (to honor the original sell-stop order for 3 contracts).

So did MC re-evaluate the bar after the buy-stop was hit (which I am thinking not since, as you mention, this bar should only be evaluated once at close), or did it perform some underlying logic behind-the-scenes?

Where did I say the bar should only be evaluated once at close?

firemag
Posts: 43
Joined: 15 Sep 2017
Has thanked: 9 times
Been thanked: 2 times

Re: Automatic OCO order?

Postby firemag » 03 Jan 2018

Where did I say the bar should only be evaluated once at close?
Implied when you said "Orders are sent at EOB (End of Bar)". If that's not what you meant, then misinterpretation.

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

Re: Automatic OCO order?

Postby TJ » 03 Jan 2018

Where did I say the bar should only be evaluated once at close?
Implied when you said "Orders are sent at EOB (End of Bar)". If that's not what you meant, then misinterpretation.

Please see my first answer to you in the third post.


Return to “MultiCharts”