NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Reply
 
Thread Tools Display Modes
Old 07-16-2012, 01:53 PM   #1
anachronist
Senior Member
 
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
Default Preventing live orders from submitting when backtesting

This isn't a question about the strategy analyzer itself. Rather I want to ask about running a strategy on a chart.

Is there any way to prevent a strategy from sending a live order on the last bar? As a temporary fix I tried

if (!Historical) return;

at the beginning of OnBarUpdate() but it doesn't seem to matter -- if the strategy generated an order on historical data prior to the next live tick, the order gets sent.

The reason I want to prevent this is so that my ATM backtesting framework will work properly. It uses unmanaged orders on historical data, but I want it to switch over to ATM strategies on live data, and I don't want a lingering historical order to end up sitting there in the DOM ladder.

-Alex
anachronist is offline  
Reply With Quote
Old 07-16-2012, 02:24 PM   #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

Hi Alex,

You can work with CurrentBar in relation to Count to identify the last bar on the chart. This will depend on CalculateOnBarClose settings.

Code:
bool isLastBar = CalculateOnBarClose ? Count - 2 == CurrentBar : Count - 1 == CurrentBar;
You could work that bool into your entry conditions. Pseudo code:
if (entryCondition && !isLastBar)
{
}
Last edited by NinjaTrader_RyanM; 07-16-2012 at 02:33 PM.
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
Submitting 2 orders on 1 chart maratrm Charting 3 02-22-2012 03:44 PM
Problem when submitting orders freewind Strategy Development 1 01-27-2012 05:19 AM
Submitting Live Orders John833 Version 7 Beta General Questions & Bug Reports 15 04-19-2010 11:52 AM
Delay when submitting orders tommyjames SuperDOM and other Order Entry Windows 5 02-11-2008 11:23 AM
Submitting GAT orders Up Miscellaneous Support 4 01-09-2005 07:46 AM


All times are GMT -6. The time now is 03:13 AM.