NexusFi: Find Your Edge


Home Menu

 





Limit Order - Auto Cancel


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 5 posts (8 thanks)
    2. looks_two Vientomarsol with 4 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 MartinHHH with 1 posts (1 thanks)
    1. trending_up 7,547 views
    2. thumb_up 9 thanks given
    3. group 3 followers
    1. forum 10 posts
    2. attach_file 0 attachments




 
Search this Thread

Limit Order - Auto Cancel

  #1 (permalink)
Vientomarsol
Port St. Lucie, FL.
 
Posts: 25 since May 2016
Thanks Given: 17
Thanks Received: 9

I’m looking for a way to code the following in TradeStation EL:

Cancel a limit order after XX minutes, if my price has been hit, but the order has not been filled.”

I found the following post on Futures.io which began with this question , but somehow evolved into a discussion of brokers and slippage.

Here is the link:•

The initial response in this post was: “All orders are canceled and replaced at the start of each new bar. To cancel it in effect, just don't reissue the Buy or Sell order.”.

I don’t understand this answer. If I have a strategy order to “buy at XX on a limit”; and xx is hit, but the order is not filed; then certainly the order will sit there, waiting to be filled until:
a) it is filled, or
b) it is cancelled.

So; can anyone tell me how to code (in TS EL) a command to “Cancel a limit order after XX minutes, if my price has been hit, but the order has not been filled.” ?

Thank you in advance for your consideration.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


Vientomarsol,

an order will remain "alive" as long as the condition you use to issue the order is valid. You can use this to your benefit by making the condition invalid after X minutes for example.
In your case you will likely require intrabar order generation and you need to detect if the price hit your limit price within your code.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
Vientomarsol
Port St. Lucie, FL.
 
Posts: 25 since May 2016
Thanks Given: 17
Thanks Received: 9


ABCTG View Post
Vientomarsol,

an order will remain "alive" as long as the condition you use to issue the order is valid. You can use this to your benefit by making the condition invalid after X minutes for example.
In your case you will likely require intrabar order generation and you need to detect if the price hit your limit price within your code.

Regards,

ABCTG


Hello ABCTG,
Thanks (as always) for your prompt reply. You are a 'Beacon of Light' to all of us amateurs.

I'm using Kase charts in my trading, so Intrabar Order Generation is not allowed.

TradeStation offers a (non-EasyLanguage) option to convert an unfilled Limit Order to a Market Order after xx seconds. It seems like we should be able to code something similar for cancelling the unfilled Limit Order after xx seconds. No??

Any thoughts?

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Vientomarsol,

you are welcome. What I wrote is still valid, with or without intrabar order generation. However without IOG you can only reset the conditions at the end of the bar and thus cancel your order at that point (which will likely not match X minutes after the order was triggered).

You might be able to walk around this with OOEL, but you couldn't backtest your code then.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
Vientomarsol
Port St. Lucie, FL.
 
Posts: 25 since May 2016
Thanks Given: 17
Thanks Received: 9

I'm OK with cancelling at end of bar (or beginning of next bar), but I can't seem to find the proper EL language.

Here is my entry code: (works well)

If Condition1
Then begin Buy ("LE") Next Bar (Close - .24) limit;
MP = 1;
End;


Here is my best guess at the 'Cancel' Code: (not working):

If Condition1[1] {referring to the prior bar with a Limit Entry signal}
and MP = 0 {referring to "Did not Get Filled"} then .CancelLastOrder;

TradeStation only allows the word 'Cancel' in one context (not this one). What other EasyLanguage word would do the trick?

Again, Thanks.

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Vientomarsol,

based on my above statement "an order will remain "alive" as long as the condition you use to issue the order is valid", the order would be cancelled by TS as soon as Condition1 (in your case) is not "true" anymore.

You would have to debug your code (using print statements for example) to check if setting MP = 1 at the location where you do it actually means you are filled, as from the code snippet I wouldn't necessarily expect that.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
Vientomarsol
Port St. Lucie, FL.
 
Posts: 25 since May 2016
Thanks Given: 17
Thanks Received: 9

Thanks for your prompt reply. I don't know how (or why) you find the time to babysit guys like me.

OK - so per your response; I'll determine my Market Position (MP = 0 versus MP = 1) before and after my Limit Order has been triggered, but not filled.
Along with this, I'll determine my 'Condition 1' status on the 'Trigger bar' and subsequent bars.

Using these two data-points, I'll see if I can noodle-out a way to auto-cancel the order.

As always, thanks for your feedback. I learn something new about EasyLanguage from each of your posts.

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Vientomarsol,

you are welcome. Based on your code snippet you set MP = 1 when your Condition1 is fulfilled. Now it depends on what you mean with "your limit order got triggered" - as it could be the act of TS sending the limit order to the exchange/execution network or price touching/crossing your limit price. If you are looking for the sending of the order the code is fine, but if it's the latter you'd need to monitor if price touched/crossed your limit price.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
MartinHHH
Montréal Québec
 
Posts: 6 since Mar 2019
Thanks Given: 21
Thanks Received: 5


Hello all,

I am posting here, since it is the closest post I found regarding what I want to do.

My strategy will enter long with a limit order -1 tick of the actual price when the conditions of the strategy are met. One of the condition is the crossover of the MACD, so that condition will not remain satisfied on the next bar update, so the limit order get cancelled on bar update (my order is only valid for 5 minutes..., the time of one bar).

I would like to keep the order good till 'x' amount of bar updates. Seems to be a simple concept, but I didn't find anyone doing it on ninjatrader, neither on other Platform.

I thanks in advance anyone who can help on that. Be aware that I am using NinjaTrader8 and I am not a coder...

martin

Reply With Quote
Thanked by:




Last Updated on March 20, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts