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

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 Waxavi, Today, 02:10 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            4 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            4 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            4 views
            0 likes
            Last Post gentlebenthebear  
            Working...
            X