NinjaTrader_Ray
06-18-2007, 07:42 AM
How do I determine whether OnBarUpdate() is called for a bar that has just completed (or just started forming) versus just a tick update?
If you are running a strategy/indicator with "Calculate on bar close" set to false (tick by tick updates) then you can check the property FirsTickOfBar. There is no way to tell if a tick closes a bar since for time based intervals, there is no way to know this until you receive the first tick of the bar.
http://www.ninjatrader-support.com/HelpGuideV6/FirstTickOfBar.html
I am entering into a long position in my script and then adding a stop loss and target profit to it. I can do that fine. Next, when either the SL or target profit gets reached, I want to trigger another action such as enter a new Long order. How would I do this?
Check the Position.MarketPosition property to monitor when you go from not flat to a flat position and then submit your new entry order. With a release in the fall, you will be able to monitor order status events to determine when an order is filled.
http://www.ninjatrader-support.com/HelpGuideV6/MarketPosition.html
If I have different Ninja strategies running in the same chart or different charts, how can I have the strategies communicate with each other? In esignal, there is a way to set up global var's that all strategies have access to. Is there a similar thing in Ninjascript? I am also a newbie at c# so I am not aware yet how to use variables across namespaces.
In C# this is called a static member. Here is a quick reference I found via Google.
http://www.csharphelp.com/archives/archive148.html
Can ninjascripts call external DLLs that I write? Again, I've done this in esignal but struggling to find this capability in ninjascript. Can you point me to the docs if they exist telling me the interface description, etc.
Yes it can, this is a function of C#. What you need to do is add a reference to your DLL via the NinjaScript Editor, right click and select "Add Reference". This only needs to be done once since this is global.
If you are running a strategy/indicator with "Calculate on bar close" set to false (tick by tick updates) then you can check the property FirsTickOfBar. There is no way to tell if a tick closes a bar since for time based intervals, there is no way to know this until you receive the first tick of the bar.
http://www.ninjatrader-support.com/HelpGuideV6/FirstTickOfBar.html
I am entering into a long position in my script and then adding a stop loss and target profit to it. I can do that fine. Next, when either the SL or target profit gets reached, I want to trigger another action such as enter a new Long order. How would I do this?
Check the Position.MarketPosition property to monitor when you go from not flat to a flat position and then submit your new entry order. With a release in the fall, you will be able to monitor order status events to determine when an order is filled.
http://www.ninjatrader-support.com/HelpGuideV6/MarketPosition.html
If I have different Ninja strategies running in the same chart or different charts, how can I have the strategies communicate with each other? In esignal, there is a way to set up global var's that all strategies have access to. Is there a similar thing in Ninjascript? I am also a newbie at c# so I am not aware yet how to use variables across namespaces.
In C# this is called a static member. Here is a quick reference I found via Google.
http://www.csharphelp.com/archives/archive148.html
Can ninjascripts call external DLLs that I write? Again, I've done this in esignal but struggling to find this capability in ninjascript. Can you point me to the docs if they exist telling me the interface description, etc.
Yes it can, this is a function of C#. What you need to do is add a reference to your DLL via the NinjaScript Editor, right click and select "Add Reference". This only needs to be done once since this is global.