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

Stop Loss and Profit Target concepts

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

    Stop Loss and Profit Target concepts

    Hello
    I want to receive some information about the concept of stop loss and profit target.
    I want to know if i can handle those two manually, i do not know the exact meaning of stop loss and profit target and need to know if i can handle them by code myself

    #2
    Hello Amiralimadadi,
    This is James, I work the Night shift for platform support.

    This ticket inquiry would be best addressed to our Ninjascript team, unfortunately, they are not in at this time and will not return until tomorrow at 8:30 am EST.

    I will assign this ticket to them, so they can reach out to you tomorrow with working on this.
    Please feel free to contact us with any further questions.
    James G.NinjaTrader Customer Service

    Comment


      #3
      Thanks for informing me.
      Let me be more clear in this topic, it will be helpful tomorrow
      I have a strategy on ZF DataSeries. There is an entry point for buying in the strategy, suppose when the price equals to 113'16'2 EnterLong() method will be called and the user wants to sell the order when price is upper than the buy point for 2 ticks (in this example when price equals to 113'18'2).

      Now i do not exactly know what to do for this purpose. Should i SetProfitTarget(CalculationMode.Tick,2)?? is that enough?


      I want to know more about the meaning and concept of StopLoss and ProfitTarget

      After that i need to know about Trailing Stop. I think it is very complicated.

      Comment


        #4
        Hello amiralimadadi,

        Thank you for the post.

        In this situation, you can go as simple as just using one line of syntax to configure the stop or target. The SetStopLoss and SetProfitTarget methods can be set once in State.Configure, or you can call these later from OnBarUpdate to make configurable orders. To know the actual meaning of what a stoploss or profit target is, I would suggest using some public trading information resources like investopedia to look up definitions. For example https://www.investopedia.com/article...-stop-loss.asp

        Regarding NinjaScript use, we have a few short examples showing the most basic uses here:




        We also have more complex examples which show how to track and store orders for later use:





        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks for your answer and links.
          I know the meaning of Stop Loss and Profit Order in the manual investments. I need to know what SetStopLoss() and SetProfitTarget() actually do. I do not know how the methods work inside of a strategy and how can i handle that myself in the code

          Comment


            #6
            Hello amiralimadadi,

            Thank you for the reply.

            If you would like a description of the NinjaScript methods, please see the links I had provided previously. The help guide will contain all the details surrounding NinjaScript methods and also examples of their use. If you are unclear about something you see surrounding these items, please provide more detail surrounding that question specifically.

            The help guide demonstrates the most basic use in NinjaScript, The other samples I had provided are more complex and show how the targets are used in contrast to an Entry.

            The best suggestion I can make here is to use the platform to test this yourself and then see the result. The Sim101 account can be used for testing live or historical orders without affecting any other live account you may already have. You can import the samples from my prior reply to run them on your end to explore the sytntax in more detail.

            We also have a video that covers creating a strategy from start to finish using the strategy builder. This is generally a good place to start to get down the basics of working with strategy and submitting orders. You can use the tutorial to create a working strategy and click "view code" or "unlock code" to see the NinjaScript generated code and continue working manually if you wish.





            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks for your complete answers.
              As i have a multi time frame strategy, i am afraid of cross order effects in stop loss and profit target so i want to get deep information about them. I will see the links, but can you please help me with a small question:
              In multi time frame strategy, how can i handle the stop loss manually through the events like OnBarUpdate() and ... I want to know does stop loss equals to ExitLong() or ExitLongLimit()?

              Comment


                #8
                Hello amiralimadadi,

                Thank you for the reply.

                You are able to control the orders manually from OnBarUpdate, this is part of what I noted originally in the more advanced samples. The third sample specifically shows using this from OnBarUpdate to change a price

                For a multi-instrument strategy, you will likely need to use SignalNames to differentiate your orders. Signal Names and From EntrySignal names will become very important in when using more than 1 entry or multiple instruments. You can read more on multi timeframe scripts here: https://ninjatrader.com/support/help...lightsub=multi

                To better understand signal names you can see the following information: https://ninjatrader.com/support/help...m#EntryMethods

                The help guide will note what type of orders the various order methods use when submitting orders, additionally, you can see this when you test it in the platform. SetStopLoss is not the same as ExitLong or ExitLongLimit, those are specifically for Long entries. SetStopLoss can be used with either a Long or Short entry and will change depending on the use. Stop loss orders are submitted as stop-market orders


                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Thanks for answers
                  These are very useful links for me.
                  There is a question yet.

                  How can i get the signal name of order in OnExecutionUpdate()?
                  As i am coding a multi time frame, so i need the signal name in OnExecutionUpdate to determine the BarsInProgress for ExitLongStopMarket

                  Comment


                    #10
                    Hello amiralimadadi,

                    The SignalName or FromEntrySignal can be read from the Order object that is passed into the OnExecutionUpdate override with the Execution object.

                    For example the Signal Name:
                    Code:
                    if (execution.Order.Name == "myEntryOrder")
                    Or FromEntrySignal name:
                    Code:
                    if (execution.Order.FromEntrySignal == "otherOrderName")


                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks a lot

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by dustydbayer, Today, 01:59 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post dustydbayer  
                      Started by inanazsocial, Today, 01:15 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post inanazsocial  
                      Started by trilliantrader, 04-18-2024, 08:16 AM
                      5 responses
                      22 views
                      0 likes
                      Last Post trilliantrader  
                      Started by Davidtowleii, Today, 12:15 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post Davidtowleii  
                      Started by guillembm, Yesterday, 11:25 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post guillembm  
                      Working...
                      X