Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Miscelleneous Questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Miscelleneous Questions

    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/H...TickOfBar.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/H...tPosition.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.
    RayNinjaTrader Customer Service

    #2
    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.

    Comment


      #3
      It is ONLY for the account the strategy is running on.
      RayNinjaTrader Customer Service

      Comment


        #4
        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.

        Comment


          #5
          It represents the position of the strategy for the account its trading on.
          RayNinjaTrader Customer Service

          Comment


            #6
            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?

            Comment


              #7
              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/H...yPosition.html
              RayNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by michaelsh, Today, 04:28 PM
              0 responses
              4 views
              0 likes
              Last Post michaelsh  
              Started by Bmatarese, Today, 03:13 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by sdauteuil, Today, 12:32 PM
              4 responses
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Gaterz, 09-27-2020, 05:52 PM
              10 responses
              51 views
              0 likes
              Last Post tcea9
              by tcea9
               
              Started by derivtrader, Today, 12:04 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Spencer  
              Working...
              X