Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Breakeven and Trailing Stop Loss

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

    Breakeven and Trailing Stop Loss

    Hi everyone,

    I am stuck with an issue around trailing SL and breakevens and was hoping for some help.

    Code:
    ...
    protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0)
                    return;
    
                if (CurrentBars[0] < 1)
                    return;
    
                 // Set 1
                if (
                     // My Strategy to determine the Long Entry
    
                   )
    
                {
                    EnterLongLimit(0,true, Convert.ToInt32(DefaultQuantity), (Low[1] - (Long_Negative_Offset_Arithmetic)) , @"LongTrade");
                }
    
            }
    Here is what I would like to achieve. Not being a programmer makes this a little tricky, as other forum posts somehow don't work for me.

    Condition 1: ASK is x ticks > entry price (example: "10")
    Action 1: Set static SL to entry price + y ticks (example: "2")

    Condition 2: ASK is z ticks > breakeven (example: "20")
    Action 2: Replace Static SL with trailing SL to breakeven + y ticks (example: "18", i.e. 20-2)

    Does anybody have an idea how I could do that?
    Thanks so much, learning a lot here!

    PS: the "Long_Negative_Offset_Arithmetic" is simply an adjustment to offset the limit entry price by the low of the previous bar - x ticks

    #2
    Originally posted by Oracletrades View Post
    Hi everyone, I am stuck with an issue around trailing SL and breakevens and was hoping for some help. Thanks so much, learning a lot here!
    Oracletrades Strategy Builder can be used to experiment with code.

    This thread has samples for B/E and trailing loss. You can open them in strategy builder and then do view code to copy and paste.

    Originally posted by 123r34 View Post
    I use the Strategy Builder as I am not a programmer. It would be very helpful if a Breakeven function was available in the Strategy Builder. When I test a trading idea manually the ATM Strategy easily allows a Breakeven setting. When I want to fine tune that idea in Strategy Builder Breakeven isn't available.. The Breakeven feature can really make a difference in the profitability of a strategy.

    Let me know if NinjaTrader has any interest in adding this feature.

    Thank you,

    Comment


      #3
      Hi Oracletrades, thanks for your note.

      Since you can not use SetStopLoss and SetTrailingStop together you must use SetStopLoss alone to modify the stop level. We have this example that shows how to modify your stop and target orders.

      https://ninjatrader.com/support/help...of_stop_lo.htm

      Please let me know if I can assist any further.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by JMont1 View Post

        Oracletrades Strategy Builder can be used to experiment with code.
        Yes, but I've made the leap into the unknown by customizing the code so there's no going back to Strat Builder (besides I want to learn!). Thanks anyway!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Renorail, Today, 01:38 PM
        1 response
        5 views
        0 likes
        Last Post Renorail  
        Started by BrianARice, Today, 01:16 PM
        0 responses
        5 views
        0 likes
        Last Post BrianARice  
        Started by Ousher, Today, 09:08 AM
        0 responses
        6 views
        0 likes
        Last Post Ousher
        by Ousher
         
        Started by Unsuitable, Today, 08:41 AM
        0 responses
        14 views
        0 likes
        Last Post Unsuitable  
        Started by newdill, Today, 07:54 AM
        0 responses
        7 views
        0 likes
        Last Post newdill
        by newdill
         
        Working...
        X