NexusFi: Find Your Edge


Home Menu

 





IOG causing my limit order to cancel and replace intrabar


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one tradersheldon with 6 posts (0 thanks)
    2. looks_two RM99 with 2 posts (4 thanks)
    3. looks_3 Big Mike with 2 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 8,865 views
    2. thumb_up 5 thanks given
    3. group 4 followers
    1. forum 10 posts
    2. attach_file 0 attachments




 
Search this Thread

IOG causing my limit order to cancel and replace intrabar

  #1 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50

I would appreciate any help in figuring out how to fix this problem. My orders just keep firing and then being canceled immediately. It will do this like 15 times right in a row. I am running an automated strategy on MC 7 beta 4 with rithmic as my broker.

When my condition is met intrabar (3 min bars), I need a limit order to be placed at the low ( this is when the strategy is going long) of the last 3 bars:

begin
BUY One CONTRACT NEXT BAR Lowest (LOW, 3)[1] LIMIT ;

So my scripts places the limit order at the proper place at the low of the last 3 minute bars. A limit order is placed, then a second later it will be canceled. It will just keep rapid firing orders and then canceling them. Without IOG turned on, a limit order will be placed and then stay there until the 3 min bar forms and any outstanding orders are canceled and that strategy will recalculate to decide if it wants to reenter the order. I understand that with intrabarorder generation (IOG) turned on, every tick is considered a bar. So therefore on every tick, a order is generated and then canceled unless the price is very close by. I really need IOG turned on because of stop loss and day loss limit occurrences that happen intrabar and need an order to be fired to go flat.

Multicharts help desk tells me that if I have IOG turned on, my script needs to resend the order on every tick until the end of the three min bar in order for the standing limit order not to be canceled intrabar.
Anyone else ever run into this problem or similar problems with IOG?
I have tried placing intrabarpersist in front of all the variables and that doesn't help anything.
Any suggestions or comments?
Sheldon

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Request for MACD with option to use different MAs for fa …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
55 thanks
NexusFi site changelog and issues/problem reporting
48 thanks
What percentage per day is possible? [Poll]
31 thanks
GFIs1 1 DAX trade per day journal
29 thanks

  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,322 since Jun 2009
Thanks Given: 33,143
Thanks Received: 101,477


I believe it is normal behavior. You might try setting a var to track whether or not you've submitted an order on that bar already, and if so, stop doing it again. But what I think will happen is MultiCharts will cancel the pending/unfilled order and not resubmit it in this case.

In this regard, NinjaTrader has the upper hand because it has the ability to let you override how long an order stays in the market.

Are you absolutely certain it is actually resending the orders to your broker? It was my understanding that a duplicate order (limit bid, etc) would not be resent across the wire.

While not of huge help to you today, in August we're having a webinar on Systematic trading with an expert who uses MultiCharts. He may be able to comment

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
  #4 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

Definitely need a coding guru here.

Might be a "hold" issue.

I know I was having issues with IOG and reissue and part of the code solution was to "hold" a value.

I'm at the limit of my computer science understanding when I say I still do not understand how it works...

but placing

variable=variable at the end of a sequence somehow "holds" the value and keeps it from being variable (in some instances).

Try searching for "hold value" etc on some of the programming support forums.

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
The following user says Thank You to RM99 for this post:
  #5 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50


Big Mike View Post
I believe it is normal behavior. You might try setting a var to track whether or not you've submitted an order on that bar already, and if so, stop doing it again. But what I think will happen is MultiCharts will cancel the pending/unfilled order and not resubmit it in this case.

In this regard, NinjaTrader has the upper hand because it has the ability to let you override how long an order stays in the market.

Are you absolutely certain it is actually resending the orders to your broker? It was my understanding that a duplicate order (limit bid, etc) would not be resent across the wire.

While not of huge help to you today, in August we're having a webinar on Systematic trading with an expert who uses MultiCharts. He may be able to comment

Mike


I am sure that it is resending the order. I have R-Trader open as well to track the trades in my account. It will keep sending the order and then canceling it for about 10 to 15 times, then the limit will stick there. I am just trying to eliminate all of the canceled orders. CME does not like too many canceled orders.
I will also try to find out what I can about the hold values. It is really annoying to see all the cancelled orders. Plus it will throw an error message saying:
The order management system rejected request.
I think this has to do with trying to change targets and stops after the original order has already been canceled.
Thanks for the input.
Sheldon

Started this thread Reply With Quote
  #6 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50


RM99 View Post
Definitely need a coding guru here.

Might be a "hold" issue.

I know I was having issues with IOG and reissue and part of the code solution was to "hold" a value.

I'm at the limit of my computer science understanding when I say I still do not understand how it works...

but placing

variable=variable at the end of a sequence somehow "holds" the value and keeps it from being variable (in some instances).

Try searching for "hold value" etc on some of the programming support forums.


Hi,
Thanks for your reply. Is there anyway that you could copy and paste an example of this variable at end of sequence?
Unfortunately, I do not know a whole lot about coding.
Thanks in advance,
Sheldon

Started this thread Reply With Quote
  #7 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

Try this...

 
Code
 
variables: intrabarpersist tradetrigger(0);
 
tradetrigger = 0;
 
if (entry condition = buy) then tradetrigger = 1;
if (entry condition = sell) then tradetrigger = -1;
 
if marketposition = 0 then begin
 
If tradetrigger[1] = 0 and tradetrigger = 1 then begin
Buy next bar at (limit location) limit;
end;
 
if tradetrigger[1] = 0 and tradetrigger = -1 then begin
Sellshort next bar at (limit location) limit;
end;
 
end;
This should hold your entry signals to the "cross" of the entry from flat to positive/negative.

I think what may be happening is that your entry is getting replicated after each tick and because the strategy has no way of tracking an outstanding/unfilled order and it's simply cancelling your order and reissuing it after each tick (until it somehow finally gets filled).

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
The following 3 users say Thank You to RM99 for this post:
  #8 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50


RM99 View Post
Try this...

 
Code
 
variables: intrabarpersist tradetrigger(0);
 
tradetrigger = 0;
 
if (entry condition = buy) then tradetrigger = 1;
if (entry condition = sell) then tradetrigger = -1;
 
if marketposition = 0 then begin
 
If tradetrigger[1] = 0 and tradetrigger = 1 then begin
Buy next bar at (limit location) limit;
end;
 
if tradetrigger[1] = 0 and tradetrigger = -1 then begin
Sellshort next bar at (limit location) limit;
end;
 
end;
This should hold your entry signals to the "cross" of the entry from flat to positive/negative.

I think what may be happening is that your entry is getting replicated after each tick and because the strategy has no way of tracking an outstanding/unfilled order and it's simply cancelling your order and reissuing it after each tick (until it somehow finally gets filled).


Thanks so much for the idea. I tried that and it did not help any. From what I can tell from what I can tell reading about intrabar order generation in the Tradestation Essentials Programmers Guide, orders that are placed when strategy is in IOG mode will only last one tick and then they will be canceled. This would work fine if I was placing market orders, but the strategy is placing orders a few ticks from the market price as a limit order. Therefore most of the time it gets canceled and replaced many times till price gets close enough to get filled.

So the next step is to figure out how to continue to issue the stop or limit orders each bar (or intrabar tick with IOG Turned on) until the order is filled or for as long as your entry / exit conditions in your strategy warrant that the orders should remain active.

Here is a post in the tradestation forum that I cannot access concerning this issue:
https://www.tradestation.com:443/Discussions/Topic.aspx?Topic_ID=36477
Can a tradestation user open it and copy and paste thread back here?
Many thanks,
Sheldon

Started this thread Reply With Quote
  #9 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50


bretter View Post
A problem arises when you start using "next bar ..." and tick data. If Intrabar order generation is enabled, then the order for "next bar ..." may only be valid for the next tick, so you have to keep issuing the order.

Example code:
More detail on IOG:
https://www.tradestation.com:443/Discussions/Topic.aspx?Topic_ID=36421



I hope this helps!
Brett

I found this on another thread. Thanks Brett. I am working (searching for examples) on the exact code to add to my script to have my system keep my limit order open at the broker until the end of the 3 min bar with IOG turned on.
I will posted my script example when I have it working.
Sheldon

Started this thread Reply With Quote
  #10 (permalink)
 tradersheldon 
Western Maryland
 
Experience: Intermediate
Platform: Multicharts
Broker: Vision Financial (Direct)/ CQG, Rithmic
Trading: Gold, Euro, ES
Posts: 39 since Sep 2010
Thanks Given: 20
Thanks Received: 50


I started my coding based on example code that Bretter had posted from the tradestation forum:

variables:
IntraBarPersist Count( 0 ) ;
if BarStatus( 1 ) = 2 then Count = 0 ;
if {trade conditions happens} then Count = Count + 1 ;
if MarketPosition <> 1 and Count > 5 then
begin
{ buy/sell order}
end ;

I got my limit orders to hold now until the new bar opens. This script will repeat the order until Barstatus(1) = 0
(occurs with the first tick of a new bar). The only downside of this is that your charts have to have bar magnifier turned on and set to 1 tick resolution. This is for minute charts or tick bars. But if you want accurate testing, that is what you will want turned on anyway. With multicharts being only 32 bit at this point, I can only use 2 GB of the 12 GB that is available, which really reeks. So backtesting is a limited at this point to smaller time series. Multicharts is supposed to have 64 bit platform by the end of this year. I can't wait.

Started this thread Reply With Quote





Last Updated on August 2, 2011


© 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