TradeStation - How to place an order of GTC duration
I am trying to place an order thru a Strategy. The order submitted is defaulted to "DAY" duration. Which means it will get cancelled by end of the day. I am using range chart and hence each bar may span between days. I want to place the order with the duration GTC (Good to Cancel). Thx in advance.
Code used to place the order.
Buy "OrdName" 1 Contracts NEXT BAR AT High+0.01 Stop
This post has been selected as an answer to the original posters question
You can use the OrderTicket object, i have included all properties you can set here
You only need to set the few you want to use.
Its the Duration field you want to change in your case, its a string containing the duration, like "DAY", "GTC", "GTC+", "30 min" etc. you can find the complete documentation in the easylanguage object reference.
The following 2 users say Thank You to ktrader for this post:
Awesome. Thx for the quick response with the solution.
BTW, I had a chat with the TS technical helpdesk on this. They mentioned that the "DAY" order will be closed by end of the session. However, when the session starts again, the same "DAY" order will be placed again automatically. This will happen even though the RANGE bar is still in the midst of completing the range. I am now testing this in the SIM account. Will share the outcome here.
The code you shared gives great deal of flexibility when placing the order. Appreciated.
Let us know how that goes. In my experience, with Forex and TS, my stop order has been cancelled at 5pm EST since it is "day" only but when it goes to renew a few seconds later it responds with a "rejected" message (apparently this is due to some lag on the TS side settling for the day). Anyway, this can leave you in a tricky spot so beware. The problem will usually correct itself when the next bar on the Data1 stream closes, prompting the strategy to run again. This is not a big deal if Data1 is small such as 1m or 5m but can be a big deal if it's larger. You can write some object oriented checks as a safety mechanism but I won't go into that.