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

How to tell if a stop loss/target has been hit in NinjaScrpt?

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

    How to tell if a stop loss/target has been hit in NinjaScrpt?

    How would you check if your stop has been hit, and at what price?

    #2
    imported post

    Do you mean in the strategy isself or in the NT UI?

    Comment


      #3
      imported post

      In the strategy.
      For example, I want to fire an alert and/or email when the stop is hit.

      Easy to do if the strategy just uses ExitShort/Long as I have control.
      But Stops are set and then triggered outside my program logic.

      Comment


        #4
        imported post

        Hmm, let me think. You could monitor Position.MarketPosition and Position.Quantity and check for changes in your OnBarUpdate method. If your position "goes down" an exit must have triggered.

        Comment


          #5
          imported post

          Dierk Droth wrote:
          You could monitor Position.MarketPosition and Position.Quantity and check for changes in your OnBarUpdate method.
          Hi, I can't find any reference to the Position.MarketPosition and Position.Quantity members in the Help doucmentation (NT6beta11). I think there was an empty page titled 'Position' in the NinjaScript section of the manual of the NT6beta10, but now it seems to be gone.

          a) Is it not possible to access these fields any more?

          b) If they are still accessible (and will remain in the forseeable future), what exactly do they return (i.e. I guess that Position.MarketPosition holds the total current position of the primary instrument - that is all filled orders, but what does Position.Quantity hold?).

          c) are there other undocumented position related fields of interest for an automated strategy?

          Thanks in advance for clarification.

          Peter Lipa


          PS: FYI, the current Nt6beta11 online docu http://www.ninjatrader-support.com/H...l?ReleaseNotes has some missing .jpg's in the updated NinjaScript Tutorial sections. The installed (local) docu, however,is fine.


          Comment


            #6
            imported post

            See here - http://www.ninjatrader-support.com/H...tPosition.html

            Thanks for the missing images comment.

            Ray
            RayNinjaTrader Customer Service

            Comment


              #7
              imported post

              Ahh, many thanks!

              Sorry, that was a stupid question...

              Comment


                #8
                Query Stop Loss Event

                Hi I am having the same stop loss query issue here. However, I am writing 2 independent strategies where I want to query for a stop loss within each strategy. For example if I use

                if (Position.MarketPosition = MarketPosition.Flat)

                is the above statement global or local in nature? If strategy#1 has an open position & strategy #2 just got stopped out when using the above line in strategy#2 give flat? If not, how to query for stoploss event WITHIN the strategy?

                Comment


                  #9
                  Originally posted by geekodude View Post
                  Hi I am having the same stop loss query issue here. However, I am writing 2 independent strategies where I want to query for a stop loss within each strategy. For example if I use

                  if (Position.MarketPosition = MarketPosition.Flat)

                  is the above statement global or local in nature? If strategy#1 has an open position & strategy #2 just got stopped out when using the above line in strategy#2 give flat? If not, how to query for stoploss event WITHIN the strategy?
                  Same question in this thread: http://www.ninjatrader.com/support/f...osition+global

                  Comment


                    #10
                    Originally posted by geekodude View Post
                    Hi I am having the same stop loss query issue here. However, I am writing 2 independent strategies where I want to query for a stop loss within each strategy. For example if I use

                    if (Position.MarketPosition = MarketPosition.Flat)

                    is the above statement global or local in nature? If strategy#1 has an open position & strategy #2 just got stopped out when using the above line in strategy#2 give flat? If not, how to query for stoploss event WITHIN the strategy?
                    The Position would report per individual strategy instance, strategies would unfortunately not cross communicate. Some users have reported success by exchanging the info needed via text files for example.

                    Another option is combining signals into one 'master' strategy so individual fills for each entry become querable.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Christopher_R, Today, 12:29 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post Christopher_R  
                    Started by sidlercom80, 10-28-2023, 08:49 AM
                    166 responses
                    2,235 views
                    0 likes
                    Last Post sidlercom80  
                    Started by thread, Yesterday, 11:58 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post thread
                    by thread
                     
                    Started by jclose, Yesterday, 09:37 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post jclose
                    by jclose
                     
                    Started by WeyldFalcon, 08-07-2020, 06:13 AM
                    10 responses
                    1,415 views
                    0 likes
                    Last Post Traderontheroad  
                    Working...
                    X