Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Loss at Low or High of Enter Candle

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

    Stop Loss at Low or High of Enter Candle

    How can I set stoploss at Low of enter candle when enter Long or High when enter long. I´tried this but does not work


    SetStopLoss(@"Long", CalculationMode.Ticks, SLLONG, false);
    SetStopLoss(@"Short", CalculationMode.Ticks, SLSHORT, false);



    SLLONG = (int) Math.Round((Close[0]-Low[0])/5);
    SLSHORT =(int) Math.Round ((High[0]-Close[0])/5);


    #2
    Hello wagner4691,

    Thanks for your post and welcome to the NinjaTrader forums!

    The SetStopLoss() you are using is set to Ticks, this means it will apply the ticks relative to the actual entry price. I am unsure what your /5 is doing for the ticks value. You may want to debug by print out the actual values of Close, Low, High, SLLONG and SLSHORT to see what is actually being used and calculated.

    To set the stop loss at the low of a candle you could use SetStopLoss(@"Long", CalculationMode.Price, Low[0], false);

    If you are working in the strategy builder this would not be possible as you would not be able to dynamically assign to the set methods, they must be fixed values.

    Comment


      #3
      I´ve di it but does not work

      Comment


        #4
        Hello wagner4691,

        Thanks for your reply.

        Can you clarify or provide more context as to what environment you are using and what you mean by it doesn't work? Let me ask some questions to help gather info:

        1) What specific version of NinjaTrader8 are you using? (Look under help>about in the NinjaTrader control center)
        2) Are you working with the strategy builder or a Ninjascript strategy?
        3) What doesn't work? It does not compile? It does not exit the trade? It exits the trade at the wrong price?
        4) Do you see any error messages in the "log" tab of the NinjaTrader8 control center when you run the strategy?
        5) are you testing on Live data, playback with market replay data, or using the strategy analyzer (Historical data).
        6) What are the values you found by using the print statement?

        Comment


          #5
          Now it is working. Tks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          51 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          127 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X