![]() |
|
|||||||
| 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. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
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! |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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]);
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
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! |
|
|
|
|
|
#8 | |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
Quote:
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." |
|
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Yes, that applies to managed orders only.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Member
Join Date: Sep 2010
Posts: 84
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |