Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.



    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.



    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.



    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.

              RayNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Waxavi, Today, 02:10 AM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by Kaledus, Today, 01:29 PM
              5 responses
              12 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Waxavi, Today, 02:00 AM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by alifarahani, Today, 09:40 AM
              5 responses
              23 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X