Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling Entry Bar

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

    Calling Entry Bar

    Hi,

    Is there a way to call an entry bar ?

    Context: I want to send in a fixed Stop Loss order when I enter a trade.
    I use the SetStopLoss( ) in the OnBarUpdate method.
    The problem is that with every new OnBarUpdate iteration,the stop loss value changes..
    For example.... SetStopLoss(Close[1] + ATR(14))
    With every new OnBarUpdate iteration, close and ATRs values change and this changes the stop price

    Therefore, to remedy this.. I'd like something like SetStopLoss(EntryBar + ATRofEntryBar);
    that would ensure that my stop loss value stays the same..

    Is this possible ?
    Is there a better way to fix a stop loss ?

    #2
    Hello akvevo,

    Thank you for your post.

    For your purpose you could use BarsSinceEntryExecution: http://ninjatrader.com/support/helpG...yexecution.htm

    Please let me know if you have any questions.

    Comment


      #3
      Thanks Patrick,

      This seems useful, but I don't how it can be used to ensure my stop loss doesn't dynamically updated on every OnBarUpdate iteration.

      The SetStopLoss() method take a calculation.price take a value, but how can BarsSinceEntryExecution be used to FIX a stop loss ?

      Comment


        #4
        Originally posted by akvevo View Post
        ...
        Is there a better way to fix a stop loss ?
        Yes. Use a Position gate.

        Psuedocode:
        Code:
        if MarketPosition is Flat
        {
        SetStopLoss();
        Enter Trade
        }
        As long as the position is not flat, which it will never be if you are in a trade, the block will never be entered, so the Stop will not be adjusted.

        ref for Position handling: http://ninjatrader.com/support/helpG...etposition.htm

        Comment


          #5
          Hello akvevo,

          Thank you for your response.

          koganam has a good suggestion as it would alleviate the need for the BarsSinceEntryExecution.

          If you were to use the BarsSinceEntryExecution you would want to have the Stop Loss at the beginning of the OnBarUpdate. However, koganam's suggestion makes it so the SetStopLoss is not being called over and over, but only once when the entry is submitted.

          Please let me know if you have any questions.

          Comment


            #6
            Thanks to both of you.
            The Flat position seems to do exactly what I need.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            54 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            130 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X