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 as high of previous candle

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

    Stop loss as high of previous candle

    How would i do this as an exit strategy? i know i cannot set a dynamic stop loss

    #2
    Hello RainIsWet,

    Thanks for writing in.

    You could use Exit order methods, such as ExitLongStopMarket(), to place a stop loss at the previous candle's High price (High[1]).

    By passing in a BarsAgo value of 1 when accessing the High price, we get the High price 1 bar ago.

    For example, the syntax might look something like this to submit 1 sell stop market order at the previous bar's High price :

    ExitLongStopMarket(1, High[1]);

    See the help guide documentation below for more information.

    ExitLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm
    High[]: https://ninjatrader.com/support/helpGuides/nt8/high.htm

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you. I have set this is strategy builder and it still is not triggering an stoploss on a short position based on the trigger candle highClick image for larger version

Name:	image.png
Views:	277
Size:	30.2 KB
ID:	1226457

      Comment


        #4
        Hello RainIsWet,

        Thanks for your note.

        If the Exit() methods in your script are not being submitted as expected this would indicate that the condition to place the order is not evaluating as true or the order is being ignored for other reasons.

        To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        Also, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.

        https://ninjatrader.com/support/foru...121#post791121

        That said, I have attached an example video demonstrating that the ExitShortStopMarket() order would place a stop loss at the High[1] value when the conditions to do so become true.

        See this demonstration video: https://brandonh-ninjatrader.tinytak...OV8yMDY0NDczNQ

        Let us know if we may assist further.​
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          where did the "mystop" and "myentry" values come from? is there another part of the video that shows how those values are established?

          Comment


            #6
            Hello RainIsWet,

            Thanks for your note.

            "myStop" is the SignalName of the ExitShortStopMarket() order. "myTarget" is the SignalName of the ExitShortLimit() order. "myEntry" is the SignalName given to the EnterShort() method. We also use the "myEntry" for the FromEntrySignal properties of our Exit order methods to tie those Exits to that Enter order method.

            Here is a quick demonstration video showing where these properties are located: https://brandonh-ninjatrader.tinytak...NF8yMDY1MzM4Mg

            More information about SignalNames could be found on this help guide page: https://ninjatrader.com/support/help...#EntryMethods]

            Information about FromEntrySignal could be found here: https://ninjatrader.com/support/help...oCloseAPositio n

            You will see these properties available when creating your Enter and Exit order methods in the Strategy Builder.

            This publicly available training video, Strategy Builder 301', briefly touches on this topic: https://www.youtube.com/watch?v=_KQF2Sv27oE&t=13s

            Please let me know if you have further questions.
            Last edited by NinjaTrader_BrandonH; 12-08-2022, 04:02 PM.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NM_eFe, Today, 05:15 PM
            0 responses
            2 views
            0 likes
            Last Post NM_eFe
            by NM_eFe
             
            Started by vitaly_p, Today, 05:09 PM
            0 responses
            1 view
            0 likes
            Last Post vitaly_p  
            Started by cmtjoancolmenero, Today, 05:05 PM
            0 responses
            1 view
            0 likes
            Last Post cmtjoancolmenero  
            Started by lucasmelo152, 06-28-2021, 12:51 PM
            8 responses
            2,124 views
            0 likes
            Last Post Ymcapital  
            Started by Creamers, 04-27-2024, 05:32 AM
            11 responses
            69 views
            0 likes
            Last Post Creamers  
            Working...
            X