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

set soploss and profit target

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

    set soploss and profit target

    Hello,
    1)I need to set my stoploss at the CurrentDayLow ( the CDL before my entry).
    2) I need to set my Profit X tick from entry, where entry is the hypothetical entry.But , because of particular conditions( for example, sleepage ) my real entry is Z tick from hypothetical entry so I would the strategy sets my profit target X-Z tick from real entry.
    Have you got any suggestions please? Thank you in advance.
    Last edited by zteck; 08-28-2017, 08:26 AM.

    #2
    Hello zteck,

    Thanks for opening the thread.

    This would be possible by adding a dynamic StopLoss in OnBarUpdate(). For example, you could set the price for you stop loss in SetStopLoss() after your entry methods to have that stop loss set to the CurrentLow value of the CurrentDayOHL indicator.

    As this involves setting a dynamic stop loss, you would not be able to use SetStopLoss() if you are using the Strategy Builder, as the Strategy Builder only supports static stop losses. If you are using the Strategy Builder, I would suggest to place exits using specific exit orders instead of the SetStopLoss() methods under Profits and Targets.

    I have created a video demonstrating how the logic can be defined in the Strategy Builder. Keep in mind the entry condition (Close[0] > Open[0]) will not be the same as your entry condition.

    Demo: https://www.screencast.com/t/vgTZg8oSP6uI

    As for Profit Targets being a certain number of ticks away from entry, you will be fine using the syntax from the Strategy Builder as this would be a static Profit Target.

    If you have any additional questions, please don't hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello Jim and thank you so much!
      However, I guess my post wasn't so clear . I would put my stop order below the currentDaylow = the currentdayLow before of my entry and not the next CDlows of the day.
      Last edited by zteck; 08-28-2017, 09:48 AM.

      Comment


        #4
        can you use that same method of setting a trailing stop order with something like an ATR trailing stop indicator or off set by ATR Tick range +- on the line of a moving average? I'm thinking something like an EMA which uses the ATR range as the calculator to determine how many ticks lower then the current EMA the stop order is placed. if you can do that how would you go about attaching the ATR range to the EMA which still needs to be attached to price? It's almost like I'm imagining an EMA line, with a curtain of bargraphs below or above it depending upon the slope direction of the line.

        Comment


          #5
          Also how would you draw such a trailing stop location on the chart of an active trade so that in Backtesting and of course monitoring your charts on the live market you can see where it is? is that a drawing action in the lower window that keeps getting drawn on each new bar? something like a short horizontal line or dot.

          Comment


            #6
            @zteck, I am not quite sure I follow. Are you able to create the logic using the Low PriceSeries and the the CurrentDayOHL indicator?

            Here are some publicly available documentation links on the usage of these items which can be accessed through the Strategy Builder.

            Low - https://ninjatrader.com/support/help.../en-us/low.htm

            CurrentDayOHL - https://ninjatrader.com/support/help...nt_day_ohl.htm

            Referencing the correct bar - https://ninjatrader.com/support/foru...ead.php?t=4769

            @Daryl Haaland, for your first inquiry, SetTrailStop() only accepts a CalculationMode of Ticks. If you wanted to create a Trail Stop using price levels that you calculate based off of indicators, you would want to use SetStopLoss() with the CalculationMode.Price or CalculationMode.Currency. (Dynamic Stop Losses based off of market calculations must be done in OnBarUpdate.)

            You may also use the output of an indicator as input to another indicator. I will include a link to our documentation on valid input for system indicators.

            For your second inquiry, any order (even Stop Losses and Trail Stops from a NinjaScript strategy) will leave an order marker when you have an active order placed with Chart Trader open. Backtesting in the Strategy Analyzer or historical data processing when you you enable a strategy will not show active order markers. The Playback connection will allow you to view these order markers as the orders would be "active."

            Publicly available documentation on the items discussed:

            CalculationModes (as explained in ATM docs) - https://ninjatrader.com/support/help...ndTargetValues

            Valid Input for System Indicators - https://ninjatrader.com/support/help..._indicator.htm

            SetStopLoss() - https://ninjatrader.com/support/help...etstoploss.htm

            SetTrailStop() (see Warnings) - https://ninjatrader.com/support/help...ttrailstop.htm

            If you have any additional questions or have any additional detail for your inquiry, please don't hesitate to write back.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks a HUGE bunch I've been trying to get a good handle on creating dynamic trailing stops since switching over from manual and ATM type trading to automated. and this helps tremendously. I'll be firing questions at you here as well as I'm sure other members of the team via E-mail from time to time to clarify code specifics.
              I know already that there is the Builder 301 course, and the editor 401 course but do you also have 501, 601, and PHD level post graduate type courses available for guys like me who really want to become experts at this stuff? (tongue in cheek, for the course descriptions of course)
              Mind you I'm guessing that after the basics this forum and private email for the more specific things is probably the best way to advance most training. But I was more thinking in terms of intermediate level video courses anyways.

              @Daryl Haaland, for your first inquiry, SetTrailStop() only accepts a CalculationMode of Ticks. If you wanted to create a Trail Stop using price levels that you calculate based off of indicators, you would want to use SetStopLoss() with the CalculationMode.Price or CalculationMode.Currency. (Dynamic Stop Losses based off of market calculations must be done in OnBarUpdate.)

              You may also use the output of an indicator as input to another indicator. I will include a link to our documentation on valid input for system indicators.

              For your second inquiry, any order (even Stop Losses and Trail Stops from a NinjaScript strategy) will leave an order marker when you have an active order placed with Chart Trader open. Backtesting in the Strategy Analyzer or historical data processing when you you enable a strategy will not show active order markers. The Playback connection will allow you to view these order markers as the orders would be "active."

              Publicly available documentation on the items discussed:

              CalculationModes (as explained in ATM docs) - https://ninjatrader.com/support/help...ndTargetValues

              Valid Input for System Indicators - https://ninjatrader.com/support/help..._indicator.htm

              SetStopLoss() - https://ninjatrader.com/support/help...etstoploss.htm

              SetTrailStop() (see Warnings) - https://ninjatrader.com/support/help...ttrailstop.htm

              If you have any additional questions or have any additional detail for your inquiry, please don't hesitate to write back.[/QUOTE]

              Comment


                #8
                Happy to be of help.

                The NinjaScript Editor 401 webinar is the extent of the educational material we provide other than what is in the help guide.

                It can be useful to use View Code within the Strategy Builder to see how the Builder creates NinjaScript code, and then to reference the methods and properties in our documentation for more information.

                We also have tips and reference samples on our forums for more guidance.

                Reference Samples - https://ninjatrader.com/support/foru...splay.php?f=30

                Development tips - https://ninjatrader.com/support/foru...splay.php?f=31

                After that point it is a matter of practicing the concepts outlined in the documentation and building upon your own ideas.

                If you have specific questions on NinjaScript, we are always available here our by email.
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by sidlercom80, 10-28-2023, 08:49 AM
                167 responses
                2,260 views
                0 likes
                Last Post jeronymite  
                Started by warreng86, 11-10-2020, 02:04 PM
                7 responses
                1,362 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by Perr0Grande, Today, 08:16 PM
                0 responses
                5 views
                0 likes
                Last Post Perr0Grande  
                Started by elderan, Today, 08:03 PM
                0 responses
                9 views
                0 likes
                Last Post elderan
                by elderan
                 
                Started by algospoke, Today, 06:40 PM
                0 responses
                10 views
                0 likes
                Last Post algospoke  
                Working...
                X