![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jan 2008
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
The Initialize() function is only called when the first time to start a strategy. If you stop the strategy (but do not remove it), and start it again, the Initialize() is not called. Is there any event that will be trigger when a user click the "start" button in the strategies tab? Thanks, Jason
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Hi Follow Shadan,
You should never place logic in the Initialize() method. Instead you will want to place it in the OnBarUpdate() method. At the top of OnBarUpdate(), you can do something like this: Code:
if (CurrentBar == BarsRequired && start == false)
{
// Do something;
start = true;
}
else if (CurrentBar == BarsRequired + 1 && start)
start = false;
Code:
private bool start = false; Code:
if (CurrentBar == BarsRequired && FirstTickOfBar)
{
// Do something;
}
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting Started | azzurro | General Programming | 1 | 12-26-2008 10:29 AM |
| Some getting started questions about the Chart | johannes | Charting | 1 | 10-26-2008 05:39 PM |
| Multiple Calls to "Initialize()" Method on Strategy Start | tomcat | Strategy Development | 3 | 11-04-2007 01:12 PM |
| Exit Strategy in Initialize() | Oli | Automated Trading | 10 | 03-30-2007 03:06 AM |
| Is there a counterpart of Initialize, called when strategy is stopped? | californiaruby | Automated Trading | 2 | 02-20-2007 03:39 AM |