![]() |
|
|||||||
| Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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; if (entryCondition && !isLastBar) { }
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 07-16-2012 at 02:33 PM.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |