• 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

Request Breakeven Functions in Strategy Builder

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

    #31
    Hello JMont1,

    Thank you for your post.

    Just wanted to follow up with you to see if you'd updated the script.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #32
      Originally posted by NinjaTrader_Kate View Post
      Hello JMont1,

      Thank you for your post.

      Just wanted to follow up with you to see if you'd updated the script.

      Thanks in advance; I look forward to assisting you further.
      NinjaTrader_Kate, Yes it is updated and attached. I wanted to show the BreakEven StopMarket not working but it mainly takes the Trailing Stop exit. Fortunately this exit has the same issues - it ignores the first two (2) exit types and takes the third. This is due to it ignoring the first two for some reason. You can delete the last exit in the trail exit and Break Even exit and you will see it does not execute either of the first two (2) exit types.

      Thanks for following up.
      Last edited by JMont1; 07-25-2019, 11:22 AM.

      Comment


        #33
        Hello JMont1,

        Thank you for your reply.

        I'm seeing it take the third stop every time. I believe this to be because that, as a market order, the third exit order would fill immediately, taking you back to a flat position. I would suggest turning on the Trace Orders function.

        Here we can see that all three were submitted in the NinjaScript Output window
        :
        7/22/2019 2:56:42 PM Strategy 'aBEtrailStarterv6/174663525': Entered internal SubmitOrderManaged() method at 7/22/2019 2:56:42 PM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=2993.50 SignalName='Trail-Mkt' FromEntrySignal='LongA'
        7/22/2019 2:56:42 PM Strategy 'aBEtrailStarterv6/174663525': Entered internal SubmitOrderManaged() method at 7/22/2019 2:56:42 PM: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=1 LimitPrice=2993.50 StopPrice=0 SignalName='TrailXit' FromEntrySignal='LongA'
        7/22/2019 2:56:42 PM Strategy 'aBEtrailStarterv6/174663525': Entered internal SubmitOrderManaged() method at 7/22/2019 2:56:42 PM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='XitTrailNoLmtMkt' FromEntrySignal='LongA'
        Flat Trail

        Here we can see same time frame in the log:
        2019-07-22 14:56:42:989|1|16|NinjaScript strategy 'aBEtrailStarterv6/174663525' submitting order
        2019-07-22 14:56:42:989|1|32|Order='93aa6af1fc7248da97f9d7562 8e5526f/Sim101' Name='XitTrailNoLmtMkt' New state='Submitted' Instrument='ES 09-19' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
        2019-07-22 14:56:43:099|1|32|Order='93aa6af1fc7248da97f9d7562 8e5526f/Sim101' Name='XitTrailNoLmtMkt' New state='Accepted' Instrument='ES 09-19' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
        2019-07-22 14:56:43:100|1|32|Order='93aa6af1fc7248da97f9d7562 8e5526f/Sim101' Name='XitTrailNoLmtMkt' New state='Working' Instrument='ES 09-19' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
        2019-07-22 14:56:43:102|1|32|Order='93aa6af1fc7248da97f9d7562 8e5526f/Sim101' Name='XitTrailNoLmtMkt' New state='Filled' Instrument='ES 09-19' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=1 Fill price=2993.5 Error='No error' Native error=''
        2019-07-22 14:56:43:103|1|8|Execution='c5e4db8846204040a56dd4 8832ebbe6f' Instrument='ES 09-19' Account='Sim101' Exchange=Default Price=2993.5 Quantity=1 Market position=Short Operation=Operation_Add Order='93aa6af1fc7248da97f9d75628e5526f' Time='07/22/2019 14:56:43'
        2019-07-22 14:56:43:106|1|32|Order='c9be4bd7a59240c9b642061d4 d657d08/Sim101' Name='Trail stop' New state='Cancel submitted' Instrument='ES 09-19' Action='Sell' Limit price=0 Stop price=2991.75 Quantity=1 Type='Stop Market' Time in force=GTC Oco='178fca5020484d7180af538e47881615' Filled=0 Fill price=0 Error='No error' Native error=''
        2019-07-22 14:56:43:108|1|32|Order='84df3ccefd524d0eaa8741479 056fedb/Sim101' Name='Profit target' New state='Cancel submitted' Instrument='ES 09-19' Action='Sell' Limit price=3004.25 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='178fca5020484d7180af538e47881615' Filled=0 Fill price=0 Error='No error' Native error=''
        2019-07-22 14:56:43:122|1|64|Instrument='ES 09-19' Account='Sim101' Average price=0 Quantity=0 Market position=Flat Operation=Remove
        2019-07-22 14:56:43:209|1|32|Order='c9be4bd7a59240c9b642061d4 d657d08/Sim101' Name='Trail stop' New state='Cancelled' Instrument='ES 09-19' Action='Sell' Limit price=0 Stop price=2991.75 Quantity=1 Type='Stop Market' Time in force=GTC Oco='178fca5020484d7180af538e47881615' Filled=0 Fill price=0 Error='No error' Native error=''
        2019-07-22 14:56:43:229|1|32|Order='84df3ccefd524d0eaa8741479 056fedb/Sim101' Name='Profit target' New state='Cancelled' Instrument='ES 09-19' Action='Sell' Limit price=3004.25 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='178fca5020484d7180af538e47881615' Filled=0 Fill price=0 Error='No error' Native error=''
        2019-07-22 14:59:15:997|1|128|Strategy 'aBEtrailStarterv6/174663525': Exit on session close handling started

        It appears that by the time the other two would have been submitted the market order you've got for that last exit has already been submitted since it's a market order. If you just use the stop market, what results do you get?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #34
          NinjaTrader_Kate Here is the updated version with the 3rd (last) exit removed. The other two are in the trace but all of the orders end with a standard trail stop from the last page of the Strategy Builder so they are not executing.

          Look at the charts or the analysis and the all fail then finally exit from the trail stop.

          Thank you for taking another look.
          Last edited by JMont1; 07-23-2019, 01:03 PM.

          Comment


            #35
            NinjaTrader_Kate Interesting test found that a possible issue is with having those coded steps AND the TrailStop from the last page. It appears that not having that automated trail stop lets the limit stop work. The first stop still does not actively get me out.

            So if I remove the "Stops and Targets" Profit target and trailing stop - then the limit exits work. Does this make any sense to you?
            Takiing another stab at a version for your review that might illustrate this easier.

            Comment


              #36
              Hello JMont1,

              Thank you for your reply.

              I must have missed that you were using the stops and targets screen for the trail stop on my previous looks at your code.

              That would be expected.

              From our help guide:
              Methods that generate orders to exit a position will be ignored if:
              A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
              A position is open and an order submitted by a set method (SetStopLoss() for example) is active
              https://ninjatrader.com/support/help...antedPositions

              This is intentional and is meant to help prevent you from having multiple exits hit, leaving you in an unintended position.

              Please let us know if we may be of further assistance to you.
              Kate W.NinjaTrader Customer Service

              Comment


                #37
                NinjaTrader_Kate Modified this base BreakEventrAilSTop (BEAST) set up based on your advice. It seems to be working at this point. Posting here for others that may be looking for Strategy Build basic starting point. So far it is only for longs since it took so long for me to get it working I am moving on to my own logic rather than the sample MA cross used to keep it simple.

                It does provide oputput to the NT8 Output window as well as what I expect will be fairly obvious screen drawings.

                BEWARE that you cannot use these "manual" stops if you use the traditional and BETTER alternatives on the Strategy Builder "Stops and Targets." The likely question is then WHY build this? First half of 2019 NT8 has a bug that cancels the Stops and Targets on the first new bar of a trade leaving it without either. They work in Strategy Analyzer but not in live trading. I have spent months trying to get around this with the hope that a bug fix would be coming. It is promised for the next release but I was told that for the last release and so far no idea when another release is coming. (forgive the venting.)

                I do think that once the bug is fixed I may still use the move to break even function learned here. If anyone takes the initiative to expand this long only to include short it would be great if you posted it here. The short would not need all the printing and drawing the long took to correct it.

                NinjaTrader Kate, Thank you for your assistance and patience as I continually modified my posts rather than create a huge list of minor edits.

                Good Luck Trading All !!!

                On a personal note Kate: I searched for a name for my daughter so I could call her Kate. I finally named her Kaitlyn. Worked fine till about 4 years old when she said stop calling me that - my name is Kaitlyn. " Man plans and Gold laughs!"

                UPDATE: Made a step for taking a manual profit since the previous focus was all about stops this was left out until now. It does a bool set to FALSE so it is not active unless you click the bool before starting the strategy. It has a different profit from the ProfitA which is there for the standard Stop and Target used on the last page of Strategy builder.

                So both work but not together. Either use as is and use the manual profit - WHICH CANNOT BE CHANGED while in the trade, except by cancelling the strategy - at which point you could go to position page of control center, right click and add an ATM. Or you could kill that last page - delete it -- and add a standard profit on the Stop and Target page of Strategy Builder.

                I do not expect to post any additional version of this in the future.
                Last edited by JMont1; 07-31-2019, 12:28 PM. Reason: Deleted previous version of BOT and placed new one on next post.

                Comment


                  #38
                  Strategies can either use standard Stop and Targets from Strategy Builder OR a manual method as described and applied to the attached strategy. This version includes not just the Break Even and Trigger Stops but a target set for manual trading. The benefit of this manual trading is that you could really get intricate in the trade management for long term trades. But still the standard stop and targets likely best to use.

                  If you want to use the standard ATM then you MUST delete the step for manual profit or it could be an issue.

                  Not being a programmer I cannot trust this completely for live trading but trade in SIM then decide if you want to enter a matching entry.

                  Again this is only for longs. If anyone modifies it for shorts or adds more profitable logic it would be appreciated if a URL to that strategy is sheared by a post here.

                  BTW, it appears to do well in CL using a 150 second (2 1/2 minutes) timeframe.
                  Attached Files

                  Comment


                    #39
                    Hello,

                    I too request.. ID #SFT-2212 to be implemented..!!

                    FYI.... It's been appx: 20 months later since the original request was made...

                    Thank You.....

                    Comment


                      #40
                      Hello Mykro,

                      Thank you for your post.

                      I have added a vote for you to SFT-2212. Currently I am unable to report any update in the status of this request.

                      Please let us know if we may be of further assistance to you.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #41
                        Originally posted by JMont1 View Post
                        Strategies can either use standard Stop and Targets from Strategy Builder OR a manual method as described and applied to the attached strategy. This version includes not just the Break Even and Trigger Stops but a target set for manual trading. The benefit of this manual trading is that you could really get intricate in the trade management for long term trades. But still the standard stop and targets likely best to use.

                        If you want to use the standard ATM then you MUST delete the step for manual profit or it could be an issue.

                        Not being a programmer I cannot trust this completely for live trading but trade in SIM then decide if you want to enter a matching entry.

                        Again this is only for longs. If anyone modifies it for shorts or adds more profitable logic it would be appreciated if a URL to that strategy is sheared by a post here.

                        BTW, it appears to do well in CL using a 150 second (2 1/2 minutes) timeframe.
                        NinjaTrader_ChelseaB NinjaTrader_Kate I understand the reasoning that using a stop and target sort of obviates or obstructs using other exits like the Break Even.

                        Oddly I have a BOT that has stops and targets and break even does not work BUT another exit does work based on an indicator. I am not ready to share this BOT publicly yet and would appreciate if you would allow me to send it to you and see why the "MaxBars" exit works but the similar Break Even does not.

                        Perhaps you can recommend a way to make the Break Even exit based on an indicator instead of the way it is currently calculated.

                        Hopefully you will allow that -- thanks for your support!
                        Last edited by JMont1; 08-14-2019, 11:01 AM.

                        Comment


                          #42
                          Hello Jmont1,

                          Thank you for your post.

                          We're happy to take a look at your code and give our feedback. Please feel free to attach your strategy to an email and send it to PlatformSupport [AT] NinjaTrader [DOT] com along with a quick note regarding what's happening with it.

                          Please let us know if we may be of further assistance to you.
                          Kate W.NinjaTrader Customer Service

                          Comment


                            #43
                            +1 vote for the Breakeven request in the Strategy Builder, but thanks for the code samples in the meantime!

                            Comment


                              #44
                              Hello Nagash,

                              Thank you for your reply.

                              I have added a vote for you to SFT-2212 as well.

                              Please let us know if we may be of further assistance to you.
                              Kate W.NinjaTrader Customer Service

                              Comment


                                #45
                                Please add my vote as well for breakeven functionality within strategy builder
                                Thank you!

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by morrnel, Today, 01:13 PM
                                1 response
                                8 views
                                0 likes
                                Last Post NinjaTrader_Jim  
                                Started by babouin77, Today, 12:41 PM
                                6 responses
                                16 views
                                0 likes
                                Last Post babouin77  
                                Started by punkiy2111, Today, 12:17 PM
                                1 response
                                9 views
                                0 likes
                                Last Post NinjaTrader_Tabor  
                                Started by GLFX005, Today, 11:22 AM
                                7 responses
                                33 views
                                0 likes
                                Last Post GLFX005
                                by GLFX005
                                 
                                Started by mintxom, Today, 10:25 AM
                                1 response
                                11 views
                                0 likes
                                Last Post NinjaTrader_Melissa  
                                Working...
                                X