Broker API - How to Support Bracket Orders?

Posted By: AndrewAMD

Broker API - How to Support Bracket Orders? - 01/17/18 12:39

jcl,

I am thinking of supporting bracket orders with my Sierra Chart plugin. I think that this is what I am supposed to do... please critique.


* To begin, there is no such thing as "Trades" in the DTC protocol. There are only orders.
* Although the brokers themselves may be NFA compliant, the user will never use NFA mode.
* Therefore, I will need my own trade management engine built into my plugin.
* After logging in, my plugin will receive a logon response message indicating which features are supported.
* If "OCOOrdersSupported" and "BracketOrdersSupported" are enabled, I can support bracket orders.
* If "UsesMultiplePositionsPerSymbolAndTradeAccount" is enabled, hedging is available. If false, hedging is not allowed (but virtual hedging is).

Logon sequence:

* Plugin logs in.
* Plugin receives configuration data upon logon response.
* User must call GET_COMPLIANCE to confirm settings.

Example: Sierra Chart is used with hedging-allowed forex broker.
* GET_COMPLIANCE == 0 (no restrictions)

Example: Sierra Chart is used with futures or stocks broker, such as IB.
* GET_COMPLIANCE == 2 (no hedging)

Example: Sierra Chart is used with NFA-compliant forex broker.
* GET_COMPLIANCE == 3 (FIFO compliance)

Example: Sierra Chart is used with NFA-compliant forex broker, and bracket orders are not supported for some reason.
* GET_COMPLIANCE == 7 (FIFO compliance + no stop loss)
Posted By: Zheka

Re: Broker API - How to Support Bracket Orders - 01/17/18 13:47

Hi, Andrew,

great you are progressing with SC plug-in!

Re your questions:

1) I do not think there will be any "Hedging-allowed" FX broker available via SC.
"Hedging-allowed" mode is a "feature" of MT4/5; so any trades bypassing MT servers of a broker will not be "hedging-allowed".
And none of SC integrations are with broker MT systems.

e.g. FXCM,LMAX,Gain trading via SC is FIX-based and so is NFA compliant by definition.

2) The key benefit of using orders "resting" in a broker's OMS vs. simulating their execution in Zorro is, of course, reduced slippage.
Will defining a BrokerStop function/StopFactor not help?

Cheers.
Posted By: AndrewAMD

Re: Broker API - How to Support Bracket Orders - 01/17/18 14:07

#1 - Currently, yes. Yet, SC uses this flag: "UsesMultiplePositionsPerSymbolAndTradeAccount". A responsible plugin writer will account for this in case SC adds such a broker. You never know.

Quote:
e.g. FXCM,LMAX,Gain trading via SC is FIX-based and so is NFA compliant by definition.
By the way, NFA compliance and Zorro's NFA mode are two very different things.

#2 - The idea behind my method is that the bracket-child-orders will sit with the broker. Plugin receives pool trades and places all orders as needed, including bracket stop orders and bracket limit orders. The user interface will be "trades".

Attached picture trade_model.PNG
Posted By: Zheka

Re: Broker API - How to Support Bracket Orders - 01/17/18 15:39

From what I know, SC will not do this as a matter of principle.
There had been several requests for integration with MT, and by the way(and reason) such requests had been rejected I would say the probability of this is big phat zero.
Besides, their development pipeline is full for the next couple of years (look also their latest "What SC is working on post").
And you will not even have the possibility to test it.
But can ask them directly,anyway...
Posted By: AndrewAMD

Re: Broker API - How to Support Bracket Orders - 01/17/18 15:46

Don't bother them with such questions. I don't need to test a boolean.

Before this topic gets completely derailed, I should reiterate that this topic is about how to write a plugin with bracket support.

jcl, is my method correct?
Posted By: jcl

Re: Broker API - How to Support Bracket Orders - 01/17/18 16:02

Yes. Currently the GET_COMPLIANCE function is for script use only, and not internally called by Zorro. But we can do that in a future version for automatically determining NFA and Hedge modes.
Posted By: AndrewAMD

Re: Broker API - How to Support Bracket Orders - 01/17/18 16:11

Originally Posted By: jcl
Yes. Currently the GET_COMPLIANCE function is for script use only, and not internally called by Zorro. But we can do that in a future version for automatically determining NFA and Hedge modes.
You can put this on hold. I'm not sure if SC necessarily changes those flags per broker. I will need to ask them.

They created this universal DTC protocol (it's like FIX, but in binary and quite compact). Then they pick and choose which features their program will actually use.

Anyways, I think I know how to proceed now. Thanks.
© 2024 lite-C Forums