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

Best Way for Dynamic Change of StopLoss

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

    Best Way for Dynamic Change of StopLoss

    hi guys,

    i'm trying to understand the best way for change the stoploss in a strategy:

    my favourite method is SetStopLoss(), that i use it in OnBarUpdate every time i need to change the SL dynamically when i'm having an open position.. in this mode i try to make a trail stop more elastic (the initial trigger is 5 point over the position.AvgPrice and change SL over of 1 point, the next ones changes (after the first) is every 2 point / added value of 2 point by the prev stoploss)...

    i read some others methods, such as use the direct method EnterLongStop / EnterShortStop inside OnOrderUpdate or OnExecution..

    which is the best way for do this?

    thanks in advance

    wyatt

    #2
    Hello wyatt,
    Thanks for writing in and I am happy to assist you.

    EnterLongStop() etc are entry orders. To place an exit order, please look into ExitLongStop/ExitShortStop order methods.



    The Set orders and the Exit orders are 2 ways of exiting your position. There is no best way to do this as it is depended on how one codes his strategy.

    You can place/modify your Set orders from OnExection etc events too.

    However a Set order and an Exit order cannot be placed simultaneously. You have to select one method only.

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      A set order and an exit order cannot be placed simulateously...
      if in OnUpdateBar i place

      Code:
      SetStopLoss():
      SetProfiTarget();
      EntryLongLomit();
      Could be tht my stoploss and profit taret isn't right for the last order?

      Comment


        #4
        Hello wyatt,
        To place the Set orders via the OnExecution etc event, please refer to this sample code
        The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()


        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Ok, but my question is:

          to obtain better stoploss performance (in general),

          is better the way:
          put SetStopLoss() in OnBarUpdate()

          or the way:
          put EnterLongStop/EnterShortStop in OnExecution()


          ?


          thanks!

          Comment


            #6
            Hello Wyatt,
            Enter() methods are for entering a position. To exit a position please use the Exit methods (like ExitLongStop etc).

            What method you choose depends on how you construct you strategy. For example if you want your stop to be based on the positions average price then putting the stop in the OnExecution will be preferred over OnBarUpdate. If your stop is based on a fixed amount (like stop = $500) then you can place it in OnBarUpdate etc.

            Same with whether you use Set() orders or Exit() orders. It depends on how you construct your strategies and what suits you best.

            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Thanks!

              when i "said" enterlongstop i refer to exitlongstop :-) , it's my error...

              if I want to change my stoploss in relation by my currentPrice (in this moment that i've a long position in market) then the initial price what i choose for entry in market and place my order, (like currentPrice - initialPrice), is better in OnBarUpdate() for me...

              OnExecution is called only some order is executed, and not while i'm in market with a position.. is it right? I need to calculate the difference for every bars..

              Comment


                #8
                Hello Wyatt,
                OnExecution will be called only when an order gets filled/partfilled and the Position class will be updated accordingly. If you need to update the stop at regular interval then you can’t do it on OnExecution. You have to shift to OnBarUpdate.

                If you are comparing local price variables then OnBarUpdate will be fine for your requirement.

                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by llanqui, Today, 08:32 AM
                1 response
                5 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by lollers, Yesterday, 03:26 AM
                1 response
                51 views
                0 likes
                Last Post lollers
                by lollers
                 
                Started by Salahinho99, 05-05-2024, 04:13 AM
                7 responses
                59 views
                0 likes
                Last Post Salahinho99  
                Started by knighty6508, 05-10-2024, 01:20 AM
                4 responses
                29 views
                0 likes
                Last Post knighty6508  
                Started by OllieFeraher, 05-09-2024, 11:14 AM
                6 responses
                19 views
                0 likes
                Last Post OllieFeraher  
                Working...
                X