Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 827 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
Reversing positions without market orders? #486097
06/08/22 20:03
06/08/22 20:03
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
With Hedge = 0 (NFA broker), when I enter a trade in the opposite direction of an existing one with a limit order, Zorro will first close the existing position with a market order. Ideally I want to reverse the position by sending a limit order in the opposite direction with twice the Lots basically. I want to only pay maker fees.

I wanted to try exiting positions first manually, bu noticed that exitLong/exitShort calls ignore OrderLimit seemingly and always transmit market orders. Can I not exit with limit orders?

Last edited by MegaTanker; 06/08/22 20:19.
Re: Reversing positions without market orders? [Re: MegaTanker] #486099
06/08/22 21:26
06/08/22 21:26
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I have an unconventional solution: Only use Hedge = 2 even though you have an NFA plugin.

In this case, you can only enterLong and enterShort trades. But you must never close trades. Instead, you cancel all trades for a given asset once its position is zero, using cancelTrade.

Also probably a good idea to set AutoConfirm =1 in ZorroFix.ini.

(Hopefully there's a better conventional solution....)

Re: Reversing positions without market orders? [Re: MegaTanker] #486108
06/09/22 10:09
06/09/22 10:09
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
The more conventional solution: Just exit the current trade at limit, then open the new one. As you would also do in manual trading.

Re: Reversing positions without market orders? [Re: MegaTanker] #486109
06/09/22 10:17
06/09/22 10:17
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
This has two problems:

- Creates an unnecessary trade. If I use a trade management function that has to "work" to get a good fill, it should be avoided to make more trades than necessary.
- exitLong/exitShort seems to ignore OrderLimit. Logging in the plugins BrokerBuy2 function shows that it is called with limit = 0 while OrderLimit is set. I read in the manual that exit calls can also use limit orders if supported by the plugin but I'm not sure how to implement that then.

Re: Reversing positions without market orders? [Re: MegaTanker] #486110
06/09/22 10:23
06/09/22 10:23
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
That trade is necessary. Any NFA broker requires it.

Zorro sends Orderlimit in entry and exit. It indeed depends on the plugin, but most plugins should support it since they use anyway the same function for entering and exiting. Make sure that you have the latest Zorro version.

Re: Reversing positions without market orders? [Re: MegaTanker] #486119
06/09/22 13:19
06/09/22 13:19
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
If your objective is to go from a positive position to a negative position with a single limit order (instead of two orders), my unconventional solution does exactly that.

Re: Reversing positions without market orders? [Re: MegaTanker] #486121
06/09/22 13:36
06/09/22 13:36
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
The unconventional solution would work, but you then need to increase the order. You need to add the open position on the size of the short order.

Re: Reversing positions without market orders? [Re: MegaTanker] #486124
06/09/22 14:12
06/09/22 14:12
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
The super-unconventional method is to supply the order() function in the script to suppress all trading activity to the broker plugin. Then manually place all orders using extra interfaces supplied by the broker plugin (or whatever trading interface you are using). Then update the status of order fills by modifying the TRADE structs. This virtually guarantees that Zorro will give you no surprises, but it's extra work for the script writer.

Re: Reversing positions without market orders? [Re: jcl] #486125
06/09/22 15:06
06/09/22 15:06
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
Originally Posted by jcl
That trade is necessary. Any NFA broker requires it.

Zorro sends Orderlimit in entry and exit. It indeed depends on the plugin, but most plugins should support it since they use anyway the same function for entering and exiting. Make sure that you have the latest Zorro version.


I'm using the FTX plugin which was recently published by a Zorro user. I don't think FTX requires NFA, but the plugin doesn't have BrokerSell2 implemented and Zorro complains that it can't exit positions without the NFA flag set. So I'm guessing Zorro requires NFA when BrokerSell2 is missing?

FTX does allow reversing orders by entering a larger trade in the opposite direction. If the broker allows it and is not NFA compliant, is there a way to achieve this in Zorro in a more conventional way?

Re: Reversing positions without market orders? [Re: MegaTanker] #486126
06/09/22 16:47
06/09/22 16:47
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
Also, using cancelTrade to remove the old position will completely drop this trade from Zorro's trade history, no? So most of Zorro's metrics will report nothing useful for monitoring the strategy.

Page 1 of 4 1 2 3 4

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1