Is NT fast enough to autotrade small timeframes? - futures io
futures io futures trading



Is NT fast enough to autotrade small timeframes?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one David with 9 posts (1 thanks)
    2. looks_two traderwerks with 3 posts (5 thanks)
    3. looks_3 Zoethecus with 3 posts (4 thanks)
    4. looks_4 gulabv with 2 posts (0 thanks)
      Best Posters
    1. looks_one zeller4 with 2.5 thanks per post
    2. looks_two traderwerks with 1.7 thanks per post
    3. looks_3 Crow with 1.5 thanks per post
    4. looks_4 Zoethecus with 1.3 thanks per post
    1. trending_up 5,695 views
    2. thumb_up 18 thanks given
    3. group 7 followers
    1. forum 22 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Is NT fast enough to autotrade small timeframes?

(login for full post details)
  #1 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received

I'm testing an autotrading strategy that trades CL on 4 range bars.

So far today, the strat has twice encountered the dreaded "sell or stop limit orders can't be placed above the market" condition. That triggers a rejected order and shuts the strat down, as I've not yet coded in rejection handling routines.

I am using NT 7 beta 22, Kinetick data feed and the system was running in Sim mode so it wasn't even connected to a broker API.

I write well optimised code as I have been a pro software developer for years, but I'm starting to wonder if NT is inherently fast enough to cope when a fast moving instrument like CL hits the gas pedal, when using short time frames.

Any thoughts?

Thanks
David

Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(140 thanks from 28 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(106 thanks from 27 posts)
looks_3Wisdom is Emptinessby Mtype
(66 thanks from 24 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(30 thanks from 14 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
Florida
 
Experience: Intermediate
Platform: NT7
Trading: CL, NQ, NG
 
Posts: 469 since Jun 2009
Thanks: 1,401 given, 402 received


David,

I'm going through the same thing using Unmanaged = true. Please don't quit-with your experience, you should be able to improve on code I'm using to handle these rejections.

Right now, I'm using this in Initialize:
 
Code

RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;

(I haven't noticed if this really helps or not)

and this in OnExecution
 
Code

if (entryOrder_1a != null && entryOrder_1a == order)
{ 
// Reset the entryOrder object to null if order was cancelled without any fill
if (order.OrderState == OrderState.Cancelled && order.Filled == 0 ||
order.OrderState == OrderState.Rejected && order.Filled == 0
)
{
entryOrder_1a = null;
}
}
Obviously, the order entry section needs to address where price is with respect to your entry stop or limit. I had to test numerous times with chart trader to make sure I understood which one needs to happen below the current price and which is above.
 
Code

if (longEntryPrice > 0 && Close[0] < longEntryPrice)
{
barState = 2;//need buy stoplimit
barNumberOfOrder = CurrentBar;
//NOT STOP OR LIMIT
entryOrder_1a = SubmitOrder(0, OrderAction.Buy, OrderType.StopLimit, contractQty_1, limitprice, stopprice, "Entry_1a", "LongEntry_a2");
else
{
barState = 3;//need limit
barNumberOfOrder = CurrentBar;
//NOT STOPLIMIT OR STOP
longEntryOrder_1a = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, contractQty_1, limitPriceL, stopPriceL, "Entry_1a", "LongEntry_a3");
// 

So far this seems to help with only the barstate=2 section. Haven't fully tested the barstate= 3 part yet.
Good luck.
Kirk

Reply With Quote
The following 4 users say Thank You to zeller4 for this post:
 
(login for full post details)
  #4 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received

Hi Kirk

Many thanks for the unmanaged code samples. I do actually use unmanaged orders at the moment, though I haven't added code to handle order rejections yet.

I think the issue is that my strat is multi time frame so this seems to slow down its performance, which becomes a problem when CL starts a rapid price movement - by the time the strat places the order for the target price, the market has moved beyond it.

I use COBC = true to try and speed things up.

As my SL is 4 ticks and PT is 8 ticks on a 4 range chart, the system seems too slow to handle it. I don't know if a shorter time frame for the mtf anchor would speed up performance or not.

Any suggestions are more than welcome

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
Las Vegas, Nevada
 
Experience: None
Platform: MultiCharts
 
Posts: 51 since Apr 2010
Thanks: 19 given, 19 received

If you have programming experience and you have a system that really works, you can code it to use your broker's API directly and bypass Ninja. Even if you convert your strategy to unmanaged code, you have no idea what else Ninja is doing with your CPU.

Reply With Quote
The following 2 users say Thank You to Crow for this post:
 
(login for full post details)
  #6 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received


Quoting 
you can code it to use your broker's API directly and bypass Ninja

Interesting idea, thanks Crow. I didn't want to reinvent any wheels, hence using NT for its mtf and inbuilt connectivity and order handling capabilities but I'm starting to wonder if it is just adding another layer of latencies.

I see that you use Java. A friend builds HFT systems in Java with direct connectivity to the exchange APIs running on Linux boxes, and gets stunning performance. Have you got any recommendations for Java libraries?

My broker is Interactive Brokers so they have a great API to exploit.

Thanks

David

Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
Florida
 
Experience: Intermediate
Platform: NT7
Trading: CL, NQ, NG
 
Posts: 469 since Jun 2009
Thanks: 1,401 given, 402 received

David,

You and Crow are in the stratosphere compared to my experience for the API and network setups.

I would think you'd want to check how to set it up as COBC=false if the momentum is high and your stops aren't too tight.

The only other thing I could add would be to test OnMarketData which give OHLCV values differently than OnBarUpdate.

I'm doing a test now and hope to have some results by next week.

HTH,

Kirk

Reply With Quote
The following user says Thank You to zeller4 for this post:
 
(login for full post details)
  #8 (permalink)
United States of America
 
Experience: Advanced
Platform: NT
 
Posts: 1,149 since Aug 2009


David View Post
Hi Kirk

Many thanks for the unmanaged code samples. I do actually use unmanaged orders at the moment, though I haven't added code to handle order rejections yet.

I think the issue is that my strat is multi time frame so this seems to slow down its performance, which becomes a problem when CL starts a rapid price movement - by the time the strat places the order for the target price, the market has moved beyond it.

I use COBC = true to try and speed things up.

As my SL is 4 ticks and PT is 8 ticks on a 4 range chart, the system seems too slow to handle it. I don't know if a shorter time frame for the mtf anchor would speed up performance or not.

Any suggestions are more than welcome

The sad truth is NT isn't fast enough in CL, FDAX or TF. You can try a dedicated server close to the exchange to improve latency and/or adding buffer ticks to the strat. Consider the slippage the price of getting a fill.

Reply With Quote
 
(login for full post details)
  #9 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received


Quoting 
You and Crow are in the stratosphere compared to my experience for the API and network setups.

I'm not so sure about that (I can't speak for Crow, of course). I've been looking at the strat you're working on which looks very promising, not so sure about the entry criteria though


Quoting 
I would think you'd want to check how to set it up as COBC=false if the momentum is high and your stops aren't too tight.

Yep, makes sense, but with multiple time frames, I think that COBC=false would bog the system down even more.

I really don't want to resort to custom programming a trading system from the ground up unless I really have to so I'm thinking of ways to use just one time frame, but the strat is only profitable when it uses a higher time frame anchor at the moment.

I think CL jumps over some prices occasionally when momentum is boosted, which makes good control of order rejections vital. You are also competing with some very low latency systems which makes autotrading it even more challenging.

If I get it working with NT I'm going to host it on a dedicated server in a Chicago datacentre to try and reduce network latencies as much as possible.

David

Started this thread Reply With Quote
The following user says Thank You to David for this post:
 
(login for full post details)
  #10 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received



Quoting 
The sad truth is NT isn't fast enough in CL, FDAX or TF. You can try a dedicated server close to the exchange to improve latency and/or adding buffer ticks to the strat. Consider the slippage the price of getting a fill.

Hi Zoe, our replies crossed. It makes you think about trading an easier instrument, but the volatility of CL and the daily profit potential is enormous and maybe worth the challenge assuming that a solution can be found.

Have you traded Aardvark in a live or papertrade environment yet?


Quoting 
Consider the slippage the price of getting a fill.

The only way I can get good fills is by placing limit orders well ahead of the current price action, which is why I am using MTFs, particularly with an 8 tick profit target where market orders would kill the profit.

David

Started this thread Reply With Quote
 
(login for full post details)
  #11 (permalink)
Taipei Taiwan
 
Experience: Advanced
Platform: NinjaTrader
Broker: AMP Clearing
Trading: TW
 
Posts: 693 since Jun 2009
Thanks: 434 given, 464 received


David View Post

So far today, the strat has twice encountered the dreaded "sell or stop limit orders can't be placed above the market" condition. That triggers a rejected order and shuts the strat down, as I've not yet coded in rejection handling routines.

Don't use stop limit orders with the Ninja API.

Reply With Quote
The following user says Thank You to traderwerks for this post:
 
(login for full post details)
  #12 (permalink)
United States of America
 
Experience: Advanced
Platform: NT
 
Posts: 1,149 since Aug 2009


David View Post
Have you traded Aardvark in a live or papertrade environment yet?

David

I'm trading Aardvark in SIM for now.

I can relate to your problem because I ran into it on a strat that had limit orders placed a bit in advance and got that ugly error message when price moved fast in thin markets shutting the strat down. But since my profit targets were larger than yours, I didn't mind taking a couple of buffer ticks to get a fill. Two ticks wasn't going to be the difference in whether it was profitable or not, since it traded about twice a day.

Check out Steadfast.
Steadfast Networks :: Chicago Web Hosting, Dedicated Servers, and Colocation

Reply With Quote
 
(login for full post details)
  #13 (permalink)
Dallas, TX
 
Experience: Beginner
Platform: Ninjatrader
Broker: Zen-Fire
Trading: ZN, 6E
 
gulabv's Avatar
 
Posts: 286 since May 2010
Thanks: 161 given, 167 received


traderwerks View Post
Don't use stop limit orders with the Ninja API.

Can you elaborate why not?

Reply With Quote
 
(login for full post details)
  #14 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received



They look good - thanks for the suggestion. Have you used them?

David

Started this thread Reply With Quote
 
(login for full post details)
  #15 (permalink)
United States of America
 
Experience: Advanced
Platform: NT
 
Posts: 1,149 since Aug 2009


David View Post
They look good - thanks for the suggestion. Have you used them?

David

No, but they come highly recommended.

Reply With Quote
 
(login for full post details)
  #16 (permalink)
Taipei Taiwan
 
Experience: Advanced
Platform: NinjaTrader
Broker: AMP Clearing
Trading: TW
 
Posts: 693 since Jun 2009
Thanks: 434 given, 464 received


gulabv View Post
Can you elaborate why not?

If you write the stop in your code and just send the limit order, you will never get that error message. The end result is the same.

Reply With Quote
The following 3 users say Thank You to traderwerks for this post:
 
(login for full post details)
  #17 (permalink)
Dallas, TX
 
Experience: Beginner
Platform: Ninjatrader
Broker: Zen-Fire
Trading: ZN, 6E
 
gulabv's Avatar
 
Posts: 286 since May 2010
Thanks: 161 given, 167 received


traderwerks View Post
If you write the stop in your code and just send the limit order, you will never get that error message. The end result is the same.

traderwerks - do you mean call setstoploss() function and then enterlimitlong() function for example at a price above the current ask? Could you share a code sample if you don't mind so I understand your statement better. Thanks!

gulabv

Reply With Quote
 
(login for full post details)
  #18 (permalink)
Taipei Taiwan
 
Experience: Advanced
Platform: NinjaTrader
Broker: AMP Clearing
Trading: TW
 
Posts: 693 since Jun 2009
Thanks: 434 given, 464 received


gulabv View Post
traderwerks - do you mean call setstoploss() function and then enterlimitlong() function for example at a price above the current ask? Could you share a code sample if you don't mind so I understand your statement better. Thanks!

gulabv

Use the OnMarketData call to get the incoming price and then send the order. Also help ful if you want to trigger off the bid/ask instead of last. There is code on the web if you Google for it.

Reply With Quote
The following user says Thank You to traderwerks for this post:
 
(login for full post details)
  #19 (permalink)
Las Vegas, Nevada
 
Experience: None
Platform: MultiCharts
 
Posts: 51 since Apr 2010
Thanks: 19 given, 19 received


David View Post
Interesting idea, thanks Crow. I didn't want to reinvent any wheels, hence using NT for its mtf and inbuilt connectivity and order handling capabilities but I'm starting to wonder if it is just adding another layer of latencies.

I see that you use Java. A friend builds HFT systems in Java with direct connectivity to the exchange APIs running on Linux boxes, and gets stunning performance. Have you got any recommendations for Java libraries?

My broker is Interactive Brokers so they have a great API to exploit.

Thanks

David

I am still in the strategy development phase and I have not yet found a strategy that I feel comfortable enough automating and letting it run on its own. However, I don't use NinjaTrader and built some of my own charting tools based on JFreeChart (java library for graphics, MyDoggy (Java Window Manager), and everything runs inside RapidMiner (#1 open source datamining platform by KDNuggets). It handles real-time data, but I'm mostly using it to look at historical data in search for a profitable strategy. Main reason that I went with a completely custom solution is because I didn't want to be limited with visualization. Secondary is because and I don't know how Ninja handles the data. It makes some great candlestick charts and pretty indicators, but I also use Linux and Ninja doesn't run too well in WINE. That said, I am surprised your friend built an HFT system on Java. I have not had any performance issues with Java, but the garbage collector / virtual machine do add some performance overhead. I really like Java and it's my favorite programming language, haven't really used C# too much (again, Linux), but it's probably very similar.

Reply With Quote
The following user says Thank You to Crow for this post:
 
(login for full post details)
  #20 (permalink)
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 183 received


David View Post
Interesting idea, thanks Crow. I didn't want to reinvent any wheels, hence using NT for its mtf and inbuilt connectivity and order handling capabilities but I'm starting to wonder if it is just adding another layer of latencies....
My broker is Interactive Brokers so they have a great API to exploit.

Thanks

David

Since IB data is 'filtered data', I would recommend an unfiltered data provider before you proceed much further in your systems development.

TJ

Reply With Quote
 
(login for full post details)
  #21 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received


Trader.Jon View Post
Since IB data is 'filtered data', I would recommend an unfiltered data provider before you proceed much further in your systems development.

TJ

Thanks, I don't use the IB data feed but use Kinetick, which seems OK, though occasionally I notice that a few ticks "bunch up" and get delivered in a burst which causes the strategy problems.

I think that is caused by Internet connectivity latencies, which I hope would not happen with the server connected via a big pipe in a datacentre.

Started this thread Reply With Quote
 
(login for full post details)
  #22 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received


Quoting 
I am still in the strategy development phase and I have not yet found a strategy that I feel comfortable enough automating and letting it run on its own. However, I don't use NinjaTrader and built some of my own charting tools based on JFreeChart (java library for graphics, MyDoggy (Java Window Manager), and everything runs inside RapidMiner (#1 open source datamining platform by KDNuggets).

Many thanks for that Crow. I have a strong PHP/MySQL background so it shouldn't be diffcult to pick up Java, if need be. It was straightforward moving to C#.

So far, the only automated strategy that I've found to be reliable uses small profit and stop loss targets for quick scalps where you can have as much control as possible (which still isn't much), however this is causing the problems discussed in this thread.

My mate is a Java wizard and definitely uses it on Linux, so I don't know how he gets around the problems that you mention. He uses large databases for storing historical SR levels, I believe, so he has to handle database interaction under HFT conditions too.

I wish I could talk to him about his systems in more detail, but he works for a large fund and their systems are their business and are therefore highly confidential.

David

Started this thread Reply With Quote
 
(login for full post details)
  #23 (permalink)
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 88 since Jun 2009
Thanks: 35 given, 84 received

I've been investigating further into what is causing the rejected order situation.

It doesn't seem to be the MTF computations, but the fact that the strat is placing a stoplimit order two ticks above the trigger bar. As I am using COBC= true, by the time the trade entry order is placed, the market has moved past it.

Whilst I'm relieved that mtf doesn't seem to be causing problems, at least yet, it does mean that I'm going to have to revisit the trade entry criteria to place the entry further from the immediate price action when trading CL.

David

Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Is NT fast enough to autotrade small timeframes?


Last Updated on October 5, 2010


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Identifying Setups & Targets Using Profile Charts w/Trevor & Tradovate

Feb 25
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts