NexusFi: Find Your Edge


Home Menu

 





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 Zoethecus with 3 posts (4 thanks)
    3. looks_3 traderwerks with 3 posts (5 thanks)
    4. looks_4 zeller4 with 2 posts (5 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 8,275 views
    2. thumb_up 18 thanks given
    3. group 7 followers
    1. forum 22 posts
    2. attach_file 0 attachments




 
Search this Thread

Is NT fast enough to autotrade small timeframes?

  #1 (permalink)
 David 
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 88 since Jun 2009
Thanks Given: 35
Thanks Received: 84

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

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #3 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404


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
Thanked by:
  #4 (permalink)
 David 
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 88 since Jun 2009
Thanks Given: 35
Thanks Received: 84

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
  #5 (permalink)
 Crow 
Las Vegas, Nevada
 
Experience: None
Platform: MultiCharts
Posts: 52 since Apr 2010
Thanks Given: 20
Thanks Received: 19

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
Thanked by:
  #6 (permalink)
 David 
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 88 since Jun 2009
Thanks Given: 35
Thanks Received: 84


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
  #7 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404

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
Thanked by:
  #8 (permalink)
 Zoethecus 
United States of America
 
Experience: Advanced
Platform: NT
Posts: 1,145 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
  #9 (permalink)
 David 
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 88 since Jun 2009
Thanks Given: 35
Thanks Received: 84


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
Thanked by:
  #10 (permalink)
 David 
UK
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 88 since Jun 2009
Thanks Given: 35
Thanks Received: 84



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




Last Updated on October 5, 2010


© 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