Gamestudio Links
Zorro Links
Newest Posts
Binance Futures Plugin
by OptimusPrime. 11/27/20 17:03
DirectX : 3d Hardware Reset Failure
by Emre. 11/27/20 11:06
Sortino(vars Data, int TimePeriod): var
by danatrader. 11/26/20 20:45
Need code for Williams Sentiment Index
by danatrader. 11/26/20 20:42
Optimizing global & local parameters
by dBc. 11/25/20 15:16
Enter FOK orders simultaneously
by jcl. 11/25/20 10:55
looking how basic functions are made
by jcl. 11/25/20 10:47
AUM Magazine
Latest Screens
Paradox Vector
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
Who's Online Now
4 registered members (AndrewAMD, 3run, Ayumi, danatrader), 479 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
MMK, raed, liquidbread, Dmitry_Shesterin, ddczp
18543 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Cancel GTC OrderLimit trade with IB #481902
11/17/20 02:44
11/17/20 02:44
Joined: Oct 2020
Posts: 5
R
ruins Offline OP
Newbie
ruins  Offline OP
Newbie
R

Joined: Oct 2020
Posts: 5
Hi,

I am using a script to enter a GTC OrderLimit order with Interactive Brokers.

OrderLimit = roundto(0.999*priceClose(),PIP);
int GTCFlag = brokerCommand(SET_ORDERTYPE,2); //set order type to good till cancelled.
ThisTrade = enterLong();

I want a GTC order as I dont want the script to wait for the order to be filled before moving onto the next Asset.

If the GTC order in not filled within 1 hour, I want to cancel it, however exitLong() or exitTrade() dont appear to work as for some reason the Quantity associated with the trade is 0 - probably because it is unfilled.

From the API Log I see this:
12:30:00:098 <- 3-43-554732-0-RCL-STK--0---SMART--USD-----SELL-0-LMT-75.51--DAY--xxxxxxxxxx-O-0-Zorro-1-0-0-0-0-0-1-0--0-------0---1-0---0-0--1-1--0------0-----0-----------0---0-0---0--
12:30:00:098 -> 4-2-554732-321-Error validating request.-'bO' : cause - The size value cannot be zero:-

So I cant cancel the LimitOrder within IB from Zorro - however I can cancel it easily from within TWS.

Any ideas on how I can cancel the order from Zorro or achieve the same outcome with other strategies ?

Alternatively, there is a GTD (goodtilldate) option in the TWS API which might be useful however I cant see how that can be exercised from within Zorro.

Thanks.

Re: Cancel GTC OrderLimit trade with IB [Re: ruins] #481904
11/17/20 11:12
11/17/20 11:12
Joined: Oct 2020
Posts: 5
R
ruins Offline OP
Newbie
ruins  Offline OP
Newbie
R

Joined: Oct 2020
Posts: 5
I did find the following command:

"OrderDuration"
-GTC order duration in seconds.

This would appear to be the same as GTD.

However doesnt appear to cancel the GTC - with IB at least.

Code snippet:
Lots = 100;
OrderDuration = 30;
setf(TradeMode,TR_GTC);
OrderLimit = roundto(0.999*priceClose(),PIP);
ThisTrade = enterLong();

Last edited by ruins; 11/17/20 11:13.
Re: Cancel GTC OrderLimit trade with IB [Re: ruins] #481914
11/19/20 08:00
11/19/20 08:00
Joined: Jul 2000
Posts: 27,401
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,401
Frankfurt
For cancelling the remainder of an unfilled order, select the trade and set TradeLots = TradeLotsTarget-TradeLots, then exit the trade. This should work at least in theory.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1