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

SetTrailStop wih SetStopLoss

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

    SetTrailStop wih SetStopLoss

    Hello

    According to your documentation:
    "The SetTrailStop() method can NOT be used concurrently with the SetStopLoss() method for the same position".

    Suppose I used the SetStopLoss for my first position. Then, after my first position is closed, I want to use a trailing stop, can I call the SetTrailStop before entering the second position?

    Thanks

    #2
    Hello kiss987,

    Thank you for your post.

    If each position in your example used a different Entry Signal Name and you called those specific Entry Signal Names in your Set methods, then yes.

    For example:
    Code:
            protected override void Initialize()
            {
    			SetStopLoss([B]"Entry1"[/B], CalculationMode.Ticks, 10, false);
    			SetTrailStop([B]"Entry2"[/B], CalculationMode.Ticks, 5, false);
            }
            protected override void OnBarUpdate()
            {
    			if (Close[0] > Open[0])
    				EnterLong([B]"Entry1"[/B]);
    			if (Close[0] < Open[0])
    				EnterShort([B]"Entry2"[/B]);
            }
    Please let me know if you have any questions.

    Comment


      #3
      Thank you for your reply.

      What if both entries are using the same signal name but the first entry is already flat? Can I now use SetTrailStop for the second entry?

      Comment


        #4
        Hello kiss987,

        Thank you for your response.

        It would not work in that manner. You could just implement logic to adjust the SetStopLoss() as a trailing stop. We have an example on adjusting the Stop Loss to breakeven that will help get you started: http://ninjatrader.com/support/forum...ead.php?t=3222

        Please let me know if you have any questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        148 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        5 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        5 views
        0 likes
        Last Post tkaboris  
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,282 views
        0 likes
        Last Post Leafcutter  
        Working...
        X