• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    Patrick H.NinjaTrader Customer Service

    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.
          Patrick H.NinjaTrader Customer Service

          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 saltminer, Today, 05:19 PM
            0 responses
            3 views
            0 likes
            Last Post saltminer  
            Started by martyn73, Today, 04:18 PM
            0 responses
            2 views
            0 likes
            Last Post martyn73  
            Started by aprendiz, Today, 03:42 PM
            0 responses
            2 views
            0 likes
            Last Post aprendiz  
            Started by 1001111, Today, 09:10 AM
            1 response
            18 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by usero86, Today, 06:02 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Working...
            X