Partfills - Are they detectable within powerlanguage at all?

Questions about MultiCharts and user contributed studies.
wilkinsw
Posts: 299
Joined: 21 Apr 2013
Has thanked: 76 times
Been thanked: 49 times

Partfills - Are they detectable within powerlanguage at all?

Postby wilkinsw » 28 Jul 2017

Hi,

I've got a buy entry order for 100 lots. It gets partfilled with 1 lot. 99 remain working.

Are there any keywords within powerlanguage that return "1" in this situation?

What would OpenEntryContracts(0) return?

Thanks.

wilkinsw
Posts: 299
Joined: 21 Apr 2013
Has thanked: 76 times
Been thanked: 49 times

Re: Partfills - Are they detectable within powerlanguage at all?

Postby wilkinsw » 28 Jul 2017

I've done my own sim testing and found the following:

using IOG=ON and:

Code: Select all

print(barstatus(1)=2, "  ,  ",currentcontracts, "   ,   ",openentrycontracts(0), "   ,   ",getappinfo(aicalcreason));


When trying to fill 600 lots (marketable limit order) to force a partfill situation all positional keywords read "0" throughout the partfill process, even though getappinfo demonstrated that "position changes" were being generated.

But, when a new bar was generated the partfill became an open position (produced a "5 = fill event") from the POV of the positional keywords... eventhough 600 lots hadn't been fulfilled. The unfilled portion was pulled from the bid at the start of the new bar. That seems strange to me and I don't know if that is just Paper Trader behaviour or not (I haven't noticed the pulling of partfills before on a new bar, during live trading)

I feel like this has opened up questions (and feature requests).

Questions:

What happens if partfilled and we have "convert unexecuted to market after x seconds" enabled? What number of contracts go to market? Original or unfulfilled qty?


Feature request (would like feedback before I submit one officially):

Can we have MC programmed so that each fill event propagates downstream exit orders? As partfills of entries are taking place, it makes sense to see attached exit orders being sent to market and their size modified continuously as we continue getting filled.

Maybe it would be useful to add positional keywords that are agnostic to partfills? Ie if I'm long 1/100 lots I have a keyword that returns "1", so no matter what I can handle partfill events?

faraz
Posts: 137
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 55 times

Re: Partfills - Are they detectable within powerlanguage at all?

Postby faraz » 29 Jul 2017

wilkinsw wrote:Hi,

I've got a buy entry order for 100 lots. It gets partfilled with 1 lot. 99 remain working.

Are there any keywords within powerlanguage that return "1" in this situation?

What would OpenEntryContracts(0) return?

Thanks.


1. For strategies that does not have IOG,
Strategy Properties > Auto trading >
a. check "Replace to market partially fill orders"
b. Check both "Unfilled strategy order replacement" set your desired seconds
It will convert partially filled orders after x Seconds time.
For more details check https://www.multicharts.com/trading-software/index.php/Auto_Trading

2. For IOG Strategies;

Code: Select all

[IntrabarOrderGeneration = true]

if (MarketPosition_at_Broker <> marketposition)  and barstatus(1) = 2 then begin

//React to a partially filled order here – generate specific orders if required or just leave the code ‘as is’ to have all orders cancelled and a market for the remainder sent

#return;

end;

wilkinsw
Posts: 299
Joined: 21 Apr 2013
Has thanked: 76 times
Been thanked: 49 times

Re: Partfills - Are they detectable within powerlanguage at all?

Postby wilkinsw » 29 Jul 2017

Thanks for taking the time to reply Faraz.

Silly question: I assume your IOG solution includes the setting; "Replace to market partially fill orders" being turned ON? Else why would "#return" event trigger a market order for the balance?

Seperately, this solution doesn't meet my needs. I merely need to monitor the number of lots I've been filled...including if it's only a partfill so that downstream logic functions correctly in an IOG strategy I'm building.

I can't use "marketpositon_at_broker" because I have many strategies running for the same instruments.

Would "MarketPosition_at_Broker_for_The_Strategy" detect partfills for the given strategy? I'll test it myself on Monday.

wilkinsw
Posts: 299
Joined: 21 Apr 2013
Has thanked: 76 times
Been thanked: 49 times

Re: Partfills - Are they detectable within powerlanguage at all?

Postby wilkinsw » 31 Jul 2017

I'll test it myself on Monday


Ok - I've ran some more tests. Please bear in mind that I can't use "marketposition_at_broker" as I would have to create a sub-account for every signal I trade with my broker, for it to make sense. Even if the broker didn't mind.... it would be an admin nightmare for me!

I use an IOG enabled strategy in SA mode, using the Paper Trader broker profile and send a 600 lots buy limit order for Globex Gold at the last barstatus(1)=2 close + a few ticks (marketable limit order).

MarketPosition_at_Broker_for_The_Strategy : from the output logs behaves just like the other positional keywords (currentcontracts, marketposition, openentrycontracts(0) ): It only updates after the current bar has closed, meaning that partfills were undetectable intrabar. So sadly this keyword won't help me neither.

marketposition_at_broker: DOES update intrabar though, but it's not practical for me to use, as explained. I'm confident this will be the same for many/most others too.

A logical workaround would be for me to add up all the "marketpositions" for a given instrument and to cross check that value against "marketposition_at_broker". However this would be very inefficient and prone to errors: Relying on GV's in an IOG strategy that's checking marketposition every tick. Assuming that only one strategy is partfilled at a time. Also, I sometimes find that GV's hang and don't update until they are refreshed etc etc. So this won't do for me neither.


So, I'll put forward my feature request again:

A new keyword that reports total contracts (long/short) that we have been filled for a given entryname (if only for the whole strategy would be an improvement), regardless of whether or not it is a partfill and that updates intrabar like "MarketPosition_at_Broker" does.

Please feedback. Thanks.

User avatar
Henry MultiСharts
Posts: 8508
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2733 times

Re: Partfills - Are they detectable within powerlanguage at all?

Postby Henry MultiСharts » 22 Aug 2017

wilkinsw wrote:Can we have MC programmed so that each fill event propagates downstream exit orders? As partfills of entries are taking place, it makes sense to see attached exit orders being sent to market and their size modified continuously as we continue getting filled.

Maybe it would be useful to add positional keywords that are agnostic to partfills? Ie if I'm long 1/100 lots I have a keyword that returns "1", so no matter what I can handle partfill events?
Hello wilkinsw,

Unfortunately that is not technically possible within the current architecture. Potentially such functionality may be introduced with the
New Auto Trading and Backtesting engine.


Return to “MultiCharts”