PDA

View Full Version : Miscelleneous Questions


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.

mazachan
07-08-2007, 09:07 AM
One thing that I have not seen clarified about the MarketPosition.Flat function is that does it work for the account that the strategy is running on, or does that apply to all the active accounts you have in Ninja Trader?

In my testing, I have been making the assumption that it is for the particular account that the strategy is running on.

For example, if I had a Sim101 and a Sim102 and the strategy is running on Sim101, it only checks on Sim101 and not for both Sim101 and Sim102.

NinjaTrader_Ray
07-08-2007, 09:14 AM
It is ONLY for the account the strategy is running on.

gert74
07-08-2007, 06:44 PM
I actually thought that it was the market position of the individual strategy and NOT the whole account.

Please correct me if I am wrong.

NinjaTrader_Ray
07-08-2007, 07:02 PM
It represents the position of the strategy for the account its trading on.

mazachan
07-10-2007, 10:08 AM
Ok, so does the MarketPosition.Flat work based on both the account and strategy?

So if I have 2 strategies running on the same account (say StrategyA and StrategyB), StrategyA will only check for positions initiated by itself so even if there are open positions created by StrategyB, it will still say that the positions are flat for StrategyA.

Sorry if this is getting too confusing, but apparently the strategy was still firing off orders left and right even though I'm checking for open positions. Also, does MarketPosition.Flat work if the orders were initiated by an ATM strategy?

NinjaTrader_Ray
07-10-2007, 10:18 AM
So if I have 2 strategies running on the same account (say StrategyA and StrategyB), StrategyA will only check for positions initiated by itself so even if there are open positions created by StrategyB, it will still say that the positions are flat for StrategyA.

Correct if StrategyA is flat.


Also, does MarketPosition.Flat work if the orders were initiated by an ATM strategy?
No it will not since an ATM stategy's position is not monitored by the Position property of the parent NinjaScript strategy. Use GetAtmStrategyMarketPosition() method instead.

http://www.ninjatrader-support.com/HelpGuideV6/ASMStrategyPosition.html