![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jan 2008
Location: Austria
Posts: 31
Thanks: 0
Thanked 0 times in 0 posts
|
Hi!
I created a strategy with two timeframes (primary is on 1-tick, secondary on 1 Min) on the same instrument what allows me to update the value of a dynamic stop-loss (takes its value from a custom indicator) every tick. This is needed, because the StopLoss should take the maximum value of the indicator ever reached (calculated on every tick) since a position was entered. In Market Replay environment the strategy behaves like expected without any problems. But when I start a backtest with the same setup, I don't get any results and the log-tab shows me following message: Failed to call mehtod "Initialize" for strategy "AATrailProb"; "Position" property can not be accessed from within "Initialize" method. 1. What does this mean? 2. In general: Is my logic right that I should get "near to live-trading"-behaviour of my strategy when I backtest this strategy calculating indicator values on a timeframe that should represent the live-trading-primary-bar-intervall (eg 1 Min) but letting the strategy run on a one-tick-primary-timeframe when backtesting? I'm using the Position-method for resetting purposes within the strategy: Here is my code:
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
- please make sure you are on latest 6.5.0.8 or 6.0.1000.9
- somehow you access the Position property directly or indirectly in the Initialize method in your code. This is not allowed. Please revisit your code - any backtest is different than the "real" thing. Please read more here why: http://www.ninjatrader-support.com/H...sBacktest.html
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jan 2008
Location: Austria
Posts: 31
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Dierk!
1.) I updated from 6.0.1000.7 to 6.0.1000.9 but I still get the same error in the log tab. 2.) you wrote "- somehow you access the Position property directly or indirectly in the Initialize method in your code. This is not allowed." If you take a look at my code, you can see, that I only access the values of the custom dataseries "StopValueSCalc" and "StopValueLCalc", which have to be defined within the Initialize-Method, havn't they? Anyway I moved the DataSeries-definition to the beginning of the OnBarupdate-Section and changed the code in the Initialize-section to: Code:
{
Add(PeriodType.Minute, 1);
CalculateOnBarClose = true;
}
I still get the same error message after starting the backtest-procedure. Does that mean, the Position-method cannot be used within a MTF-Strategy? 3.) Of course I already read the chapter in the NT-help-section and some other articles on backtesting-problems in general. Historical tick-data is provided by my data-supplier so I try to come as close as possible to real-time-conditions (of course there are systemical restrictions). The Market-Replay-Tool of NT is the only alternative to this, though I don't have enough replay data yet to get valid results. Also optimization of input parameters of a strategy can only be done on historical basis economically (instead of trying several set ups manually). Would you agree that my approach of a 1-Tick-MTF-Strategy is right concerning that target or would you suggest something completely different? I'd be glad for just a little push in the right direction! thx |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Could you please mail be your complete strategy and a screenshot of any settings needed to reproduce the problem to "dierk AT ninjatrader DOT com"? Thanks
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| data box showing real time? | zq655 | Charting | 4 | 02-01-2008 12:04 PM |
| Changing Indicators in Real Time | Agamenon | Strategy Development | 1 | 11-21-2007 06:35 AM |
| Next bar and Real time | Agamenon | Strategy Development | 4 | 11-19-2007 06:16 PM |
| Backtesting Multi-Timeframe does not match real market data. | MONTERO | Strategy Analyzer | 17 | 10-01-2007 06:48 PM |
| RemoveDrawObject not working in real time | JangoFolly | Indicator Development | 2 | 07-12-2007 10:13 AM |