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

Triggering orders to be submitted by addon via indicator

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

    #16
    Hello Kylemcfar57x,

    No those are available on the account object as well. As a learning exercise to help know what is available I would suggest do do the following:
    1. Open the help guide and use the left side toolbar to drill down to the following section: NinjaScript -> Language reference -> Addon -> Account
    2. Then look at the left side bar at the various topics surrounding Account. You can see the different collections/events for the account and each page will have samples.
    You can always reference the main Account help guide page for an example of finding an account and it also includes the order events: https://ninjatrader.com/support/help...ount_class.htm

    You likely can accomplish your goal fully from the indicator, the indicator class has all of the same ability as the addon class will in respect to using the Account.

    JesseNinjaTrader Customer Service

    Comment


      #17
      ok i spent the past few days reworking order handling i made methods to separate each action and checking filled ect, but my issue is that even on the initial entry from flat, im getting multiple fills, on a signal, the events dont help in this situation since they come in until after, unless im missing something, i tried to use a flag so it would only execute once but that doesn't seem to be working either

      im currently at a loss as to get my order to fill only once, on market reply it works flawlessly but on sim i always get multiple fills, i would greatly appreciate any suggestions

      Comment


        #18
        Hello Kylemcfar57x,

        It sounds like the condition to submit the order is happening multiple times if you are getting multiple fills. You would have to look at the entry logic, that has nothing to do with the account events.

        A general flow for a complete Trade (entry + exit) would be that you have a condition for example in OnBarUpdate and it submits a single order one time. This logic needs to happen only 1 time and then stop happening so no more orders are submitted. This condition won't know that the position is not flat until later so you need to make your own way of ensuring this condition only happens 1 time to submit the order. Generally a condition like a Crossover or something that can only logically happen one time per bar could be used to control that. Depending on the configuration of your script you may need to add some extra complexity to the entry condition or use your own variables to control when it is allowed.

        Once the entry condition is satisfied it will submit the order which then gets filled. When the fill happens the account events like ExecutionUpdate trigger. That execution event can be used to then submit targets for that entry because we know the entry was filled at that point. Once your target fills and the strategy has completed the trade you could allow the entry condition to happen again at that point.





        JesseNinjaTrader Customer Service

        Comment


          #19
          yea i was beginning to think that was the case, i was just trying to think of a condition that could work for my strat, i found this post about current bar, im going to explore that option, thanks for your help https://ninjatrader.com/support/foru...1Ig0P9Tuc00Oe0

          Comment


            #20
            Originally posted by Kylemcfar57x View Post
            well i may have been a bit too optimistic, i finished on Saturday so the market was closed, long story short it works flawlessly on market reply, but live i get an occasional double entry on reversal, so i figured it was flipping too fast before the ui thread returned that the pos was not long yet so it entered again, i tried to use await but every time i try pass orderers through the thread dispatcher it just spams orders instead of doing one even without the dispatcher just an async method with await does the same thing, even tried executing the code to simulate clicks on chart trader for entry same result not sure what im messing up i was never good with threading, commented stuff is what i tried before, it all executes but i think its not letting market position get to the argument, thats also passed through a thread, the instrument to flatten data is also passed through a thread but held in a list so i dont think its that, it runs as expected in market replay in this form but i cant get it to work using await Click image for larger version Name:	image.png Views:	0 Size:	23.2 KB ID:	1233222​
            instead of

            if (marketPosition != 1)
            Try
            if ( Position.MarketPosition ==MarketPosition.Flat )​

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by junkone, Today, 11:37 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by frankthearm, Yesterday, 09:08 AM
            11 responses
            42 views
            0 likes
            Last Post frankthearm  
            Started by quantismo, 04-17-2024, 05:13 PM
            5 responses
            35 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by proptrade13, Today, 11:06 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            35 views
            0 likes
            Last Post love2code2trade  
            Working...
            X