NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 03-16-2011, 11:45 AM   #1
skyholder84
Member
 
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
Default Lack of fills

Hi,

I'd like to know how the slippage setting affects my strategy in real time. I've run backtests over periods where my strategies were running in real life. Many of the trades which occurred in the backtest never materialized in real time.

I suspected that slippage might have been the key, since I left slippage at the default 0 setting. I thought that this would not matter, since my automated strategy uses simple default market orders.

Since I don't use limit orders, I should get a fill, no matter how bad the price. Isn't that so? Or does slippage still determine whether I will get filled even when market orders are used? Is my lack of fills caused by setting slippage to 0?

I've read the guide over and over, so please don't direct me to the guide. The guide simply states that:

During real-time live brokerage trading, orders are filled according to market dynamics.
This doesn't help. I thought that as long as the indicator logic flashed positive, the trade would be executed at market at the end of the bar. Someone pls help!
skyholder84 is offline  
Reply With Quote
Old 03-16-2011, 11:56 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello skyholder84,

Slippage only applies to the strategy historically. For real time, your fills are based on the simulator engine or live market dynamics if you're submitting to a live account.

Yes, backtesting results can vary between real time results. Please see here for discrepancies expected backtesting versus real-time

For market orders you will typically get a fill right away unless there is no bid / ask volume available for the instrument.

For your strategy, it would help to add additional signal confirmation. You can add drawing objects that signal when a condition is true, so will work to alert you to true signals independent of order placement.

If it's not working as you expect, you will want to start to Print() all values that are critical in conditional order placement. To track the flow of strategy order submission, use TraceOrders output. Please see here for help using these debugging tools.

Finally, the strategies tab of the control center should be monitored for helpful information on the state of the strategy. If it's highlighted yellow, for example, the strategy is waiting for a flate state before it starts submitting orders. This page can help with monitoring the status of strategies on the control center.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-16-2011, 12:17 PM   #3
skyholder84
Member
 
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Ryan, I'm not sure how the Print command works, and where I can actually see all the values in the output window you mentioned. How do I reach the output window?
skyholder84 is offline  
Reply With Quote
Old 03-16-2011, 01:06 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

The output window is accessed with Tools > Output Window. This link explains how to use Print(), along with TraceOrders:

http://www.ninjatrader.com/support/f...ead.php?t=3418
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-16-2011, 01:39 PM   #5
skyholder84
Member
 
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi, I'm having trouble printing indicator values which aren't calculated from the primary bars. Ie, the use of BarsArray seems to prevent the values from being reported correctly.

Print(String.Format("StoK={0} StoD={1} StDev={2} SMAStDev={3}", Stochastics(7, 14, 3).K, Stochastics(7, 14, 3).D, StdDev(BarsArray[1],14), SMA(StdDev(BarsArray[1],14), 14)));

The stochastics values are printing fine, but not the StdDev and SMA)StdDev) values.

Any idea how I could get them to print?
skyholder84 is offline  
Reply With Quote
Old 03-16-2011, 02:45 PM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

You'll want to print the double values you're trying to access, and maybe start simple and print one indicator value at a time.

Print("K " + Stochastics(7, 14, 3).K[0] + " D " + Stochastics(7, 14, 3).D[0] + " StdDev " + StdDev(BarsArray[1],14)[0] + " SMA " + SMA(StdDev(BarsArray[1],14), 14)[0]);
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-16-2011, 03:03 PM   #7
skyholder84
Member
 
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
Default

Awesome! Thanks for fixing the code snippet!

Also, I select OnBarUpdate, NT calculates indicator values on every tick.

1) Does this also mean that when the logic is satisfied, an order is immediately sent out? Or is the order submitted only at the end of the bar?

2) If the order is submitted only at the end of the bar, what happens if the logic which triggered the trade is no longer valid at the end of the bar? Does the trade get canceled?

Also, you mentioned that it was possible to program a signal confirmation system independent of order placement. How would you suggest I implement this idea?

Thanks!
skyholder84 is offline  
Reply With Quote
Old 03-16-2011, 03:19 PM   #8
cgeorgan
Senior Member
 
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by skyholder84 View Post
Awesome! Thanks for fixing the code snippet!

Also, I select OnBarUpdate, NT calculates indicator values on every tick.

1) Does this also mean that when the logic is satisfied, an order is immediately sent out? Or is the order submitted only at the end of the bar?

2) If the order is submitted only at the end of the bar, what happens if the logic which triggered the trade is no longer valid at the end of the bar? Does the trade get canceled?

Also, you mentioned that it was possible to program a signal confirmation system independent of order placement. How would you suggest I implement this idea?

Thanks!
I just happened across this thread, figured I'd add my two cents since I've worked through this sort of thing in the past.

Be very careful when calculating on bar tick...especially if you use a crossover type system. You can literally find yourself triggering a hundred crossovers in the space of 5 seconds as an 'on tick' calculation causes the final calculation of your indicator to cross above and below whatever reference line you're using.

Best bet, in my experience, is to stick with "on bar close."
cgeorgan is offline  
Reply With Quote
Old 03-16-2011, 04:26 PM   #9
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Yes, if you're using CalculateOnBarClose = false in real time, order are submitted immediately when conditions are true. If you're submitting market orders then they're sent as well, even if the bar closes with the condition false. For stop or limit orders, default behavior is for orders to expire if they are not filled on the bar they're submitted to. If the conditions remain true on the next bar, the orders are resubmitted.

You can add drawing actions to draw on your chart when conditions are true. This sample can help with that:
http://www.ninjatrader.com/support/f...ead.php?t=3419
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-16-2011, 04:38 PM   #10
cgeorgan
Senior Member
 
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_RyanM View Post
For stop or limit orders, default behavior is for orders to expire if they are not filled on the bar they're submitted to.
Can I assume you're referring to managed orders?
cgeorgan is offline  
Reply With Quote
Old 03-16-2011, 04:43 PM   #11
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Yes, that applies to managed orders only.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-16-2011, 09:38 PM   #12
skyholder84
Member
 
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
Default

I've just looked at the output window and I see exactly what you mean cgeorgan. That advice is really a great help. Thanks for the share!
skyholder84 is offline  
Reply With Quote
Old 03-17-2011, 08:56 AM   #13
skyholder84
Member
 
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi,

Something strange is happening. Apparently, the logic for trades has in fact materialized, and an internal PlaceOrder() event occurred. However, no trade signal was sent.

Here are some snippets of the log file, which I have also attached.

3/17/2011 10:00:00 AM Entered internal PlaceOrder() method at 3/17/2011 10:00:00 AM: BarsInProgress=1 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='PSARLONG' FromEntrySignal=''

After the "Entered internal PlaceOrder() method" signal, no trade was placed.

I am using Interactive Brokers and hoping to autotrade YM, ES, TF, CL, BRN, HHI, HSI and GC. Am I able to auto-trade all these products with Interactive Brokers? So far, only ES has traded. The rest have not activated throughout the week. Is the problem caused by an inability to autotrade these tickers on IB?
Attached Files
File Type: txt output1.txt (25.5 KB, 1 views)
skyholder84 is offline  
Reply With Quote
Old 03-17-2011, 09:24 AM   #14
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Thanks, Syholder.

To see the whole progression of order submission, can you please send your log and trace files to support 'at' ninjatrader 'dot' com.

In the subject, write: Attn RyanM

The file you're looking for are:
My Documents\NinjaTrader\log\log.20110317.txt
My Documents\NinjaTrader\trace\trace.20110317.txt
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-17-2011, 10:13 AM   #15
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Thank you for the files. I see a trade placed on CL at 10:00.

Can you please let us know which version you're using? Check with Help > About
NinjaTrader_RyanM is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-instrument problem when lack of data. mdhanafi68 Version 7 Beta General Questions & Bug Reports 3 08-13-2010 06:57 AM
lack of L2 data bfirth SuperDOM and other Order Entry Windows 10 05-18-2009 04:48 AM
Market Replay Fills vs Live Real Money Fills Lusitano Strategy Development 1 03-02-2009 09:38 AM
Discrepancies and lack of functionality. bsamani General Programming 6 12-19-2008 07:02 AM
lack of important features trader65 Suggestions And Feedback 9 05-14-2007 07:17 AM


All times are GMT -6. The time now is 01:55 AM.