![]() |
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 |
|
Senior Member
Join Date: Apr 2009
Posts: 161
Thanks: 0
Thanked 5 times in 5 posts
|
Hi guys
I need a hook which will allow me to run some code when a custom strategy is started. At the moment I've overridden the Initialize() method and placed my setup code in there. However, I've got all kinds of problems (such as TickSize not being accessible) because that method is called any time an instance strategy is created. Obviously this can happen before any instrument has been selected. There must be some way for me to determine when the strategy has started and pick up info such as the TickSize. Thanks. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Please try this:
- define a boolean flag variable, set to true - first time OnBarUpdate is called check if flag is true and then * run your Init() stuff * set flag variable to false
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2009
Posts: 161
Thanks: 0
Thanked 5 times in 5 posts
|
Already tried that. The problem is the L2 order book gets built before OnBarUpdate() is called for the first time. What I need is a hook which allows me to setup my strategy before any market data events get fired.
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
ScoobyStoo,
Maybe I am missing something but I am not seeing why there is such a requirement of doing this before receiving data events. What is it that you need to build beforehand?
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Apr 2009
Posts: 161
Thanks: 0
Thanked 5 times in 5 posts
|
Quote:
Would be really handy for NT7 to expose proper hooks to all the strategy lifecycle events (start, pause, stop etc). Obviously, I don't know how difficult that would be to do though... Thanks for the help |
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,407
Thanks: 252
Thanked 974 times in 957 posts
|
Great you got it working, thanks for the suggestions ScoobyStoo.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ross Hook and 1-2-3- Pattern | razorbuzz | Charting | 4 | 09-12-2010 11:15 AM |
| Two CCI hook | MartinBrr | Strategy Analyzer | 3 | 06-09-2009 05:55 AM |
| Start Strategy | volpiemanuele | Automated Trading | 5 | 08-07-2008 02:14 AM |
| start strategy again | max-td | Strategy Development | 5 | 04-24-2008 04:32 AM |
| MB Trading Hook-up | Savage1701 | Connecting | 3 | 08-03-2005 05:11 AM |