Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Loss Set at previous bar's High/Low Assistance Request

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

    Stop Loss Set at previous bar's High/Low Assistance Request

    Hello,

    I'm attempting to create a stop loss that triggers with the current bar's closing below/above the previous bar's high/low. Actually I'd prefer the stop loss to trigger when the current price breaks the previous bar's high/low, but I don't know how to do that either lol . I've attached what I have created so far, the logic made sense to me but when I'm in a postion, the stop loss doesn't trigger. I don't want to set conditions on entering long/short postions, I prefer to do those manually, I just want the stop loss.

    Thank you,
    Attached Files

    #2
    Hello Wsummers,

    To confirm, you want to submit a manual order, detect the manual order from the Account.OrderUpdate event, and then submit a stop supplying the High[1] of the previous bar as long as the High[1] of the previous bar is less than GetCurrentBid() (to ensure the stop price is a valid price), is this correct?

    It looks you are using the Strategy Builder. A NinjaScript Strategy is not able to detect manually submitted entry orders with native methods. You will need to unlock the script and add advanced code from the Addon approach to add an event handler method to the Account.OrderUpdate event to detect the manually submitted order.

    Below is a link to the help guide.


    As well as a link to an example named 'ProfitChaseStopTrailIndicatorExample' when demonstrates adding event handler methods to account events.



    Where you have mentioned:
    " I've attached what I have created so far, the logic made sense to me but when I'm in a postion, the stop loss doesn't trigger."

    If you want to understand the behavior of the code you have written, you will need to debug using Print() and TraceOrders.
    Below is a link to a forum post that demonstrates using Print() to understand behavior and includes videos.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thank you for your response, to answer your question, if I'm understanding it correctly, yes, for a short position, with a manual entry, I'd like to have a stop trigger at the high of the previous bar, ideally the current bar's price break of that high and not just the current bars close over that high.


      ​​​​​​I'll review your links, thank you again.

      Comment


        #4
        Hello,

        I've reviewed of your links, unfortunately though I was unable to completely interpret the first link's information as I'm not a programmer. I see in your second link you have created templates, and I've imported your recommended 'ProfitChaseStopTrailIndicatorExample'. Does this not fall under strategies, I can't find it in the strategy section, and if not, where can I find it?

        Thank you,

        Comment


          #5
          Hello Wsummers,

          This indicator is using the Addon approach.

          As mentioned in post # 2, "A NinjaScript Strategy is not able to detect manually submitted entry orders with native methods. You will need to unlock the script and add advanced code from the Addon approach to add an event handler method to the Account.OrderUpdate event to detect the manually submitted order."

          The indicator demonstrates using the Addon approach to Account level orders, which would include manually submitted orders.

          Manual orders will not update a strategies order overrides like OnOrderUpdate() or OnExecutionUpdate(), so you would need to attach event handler methods to the Account object.

          The Addon approach demonstration in the indicator can also be used in a strategy (or any script).


          You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Do you have educational content that teaches how to create these scripts, if so I'd prefer to use those so I can learn?

            Comment


              #7
              Hello Wsummers,

              The NinjaScript Editor 401 is a beginner training video that shows basic C# syntax.

              However, there is not much training video material as there are text based tutorials.

              Below is a link to a forum post with helpful resources on getting started with C# and NinjaScript.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thank you Chelsea, I have a lot to learn, I better get to studying lol.

                Comment


                  #9
                  Wsummers, You may find this useful. https://ninjatraderecosystem.com/use...uttons-v5-0-2/

                  RR Mode will set your stop at the Low/High of the previous Candle/Candles selected. See the video linked in the description for a full guide on how to use it.

                  You do have to enter the trade with one of the strategies buttons for it to work but there are several options there to choose from.

                  May not be 100% what you're looking for but may be worth a look
                  TradeSaber Inc.NinjaTrader Ecosystem Vendor - TradeSaber Inc.

                  Comment


                    #10
                    TradeSaber bro that is 100% exactly what I'm looking for, it's not like my entries are super complicated... I do market orders and your system is perfect for what I'm trying to do. Just finished your video, this really is amazing, just subscribed to you and joined your discord. Thank you so much!!!
                    Last edited by Wsummers; 01-24-2023, 12:54 PM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Yesterday, 05:17 AM
                    0 responses
                    65 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    139 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    75 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    45 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    50 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X