• 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

How to Add Breakeven Stop in Strategy Wizard

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

    How to Add Breakeven Stop in Strategy Wizard

    I've done a lot of searching on this forum, and maybe it's just because I literally don't understand code, but for the life of my I can't understand how to add a simple breakeven stop in the strategy wizard. I have a stop loss in place of $160 (I tried 16 ticks for CL, but I was getting single drawdowns of over $700, so obviously I was doing something wrong).

    But I want to add in addition to my $160 stop loss, moving my stop to breakeven plus 1 tick after the trade goes in my favor 20 ticks. I've tried a lot of different things, all wrong.

    Can someone please walk me thru the 2nd grader addition (because that's the peak of my "code" education) on how to add this with my $160 stop loss in the strategy wizard? Thanks

    #2
    Hello MFinMO,

    Thanks for your post and questions.

    You cannot use both a trailing stop and a set stop loss within the wizard on the same position (entry name). If both are chosen, the trailing stop is ignored. You could use both if they refer to different positions (different entry names).

    For the set stop loss, in your example, please make sure you set "Mode" to ticks, set Value to "16", keep simulated to "False".


    I have attached an example of a Breakeven strategy that does not use the wizard stop, it is only an example and you would need to adapt and test to your needs and will give you something to work with within the limits of the strategy wizard. The sample strategy enters a position, places an initial stop and when position is X ticks in profit the stop is moved to breakeven. It does run in CalculateOnBarClose=false so that the stops are placed and moved as quickly as possible, otherwise in true it delays action to the next bar.

    The user inputs are a profit trigger, in ticks, for the breakeven and an initial stop value in ticks from the entry. This example only shows a long entry.

    In Condition Set 1, the only condition is to make sure that there is no current entry (This is the area where you would have your entry criteria in your strategy). The actions then are to enter a long position, set user variables, Variable0 = the breakeven trigger, Variable1 is the initial stop, variable 2 & 3 are simply set to zero.

    In Condition Set 2, we test to see that we have a long entry and check that Variable2 = 0. the actions in set 2 are to adjust the breakeven trigger level based on the filled price and set Variable2 = 1.

    In Condition Set 3, we test to see we are in a long position, we test to see if Price is >= the trigger (Variable0) and we test that variable3 = 0. The actions in set 3 are to set Variable1 = the entry price, draw a diamond and set Variable 3 = 1 (to act as a conditional flag)

    In Condition Set 4, we test to see if we are in a long position and the action is to set a long stop according to the value of Variable1. Note: In the first pass through the stop is at the initial stop value and will stay that way until the breakeven trigger is exceeded in set 3 and then the very same variable1 is set to the entry price. So through the use of Variable1 value, we are manipulating the stop price.

    For a trailing stop you would employ somewhat the same methodology.

    Please let me know if you have any questions.
    Attached Files
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul,
      Thanks, but I'm not trying to use a trailing stop. I want to move my stop loss to breakeven +1 tick after 20 of ticks of profit.

      I downloaded that sample strategy last night, it's of no help to me.

      I really need to be walked thru this like the idiot I am, i.e. screen shots or very specific instructions for do this, then this, then this, etc.

      Comment


        #4
        I can do the simple wizard stuff like:
        Close<FastEMA
        FastEMA>SlowEMA
        FallingFastEMA == true

        EnterShort

        StopLossTotalPosition(cash) $200

        But I can't for the life of me figure out how to add a simple: move stop to breakeven after 20 ticks of profit.

        Comment


          #5
          Hello MFinMO,

          In the strategy wizard there is no easy way to set a breakeven stop. It wasn't built to provide that automatic functionality. That said, the example strategy is a way in which you can implement a breakeven strategy within the Strategy wizard.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            You have to understand, this is very easy for you & this harder than astro physics for me. I see everything in your example & have downloaded it and looked at....and it's completely Greek to me.

            I'm sorry for being so ignorant on this, but can't someone just walk me thru the steps such that a child could follow? That's my level of intelligence on this subject matter. Sorry.

            Comment


              #7
              Hello MfinMO,

              Based on your interest in learning NinjaScript, I wanted to let you know that there are a number of resources available through NinjaTrader Ecosystem. Whether you are interested in learning NinjaScript from literature, videos, or one-on-one with a professional, there are NinjaTrader Ecosystem partners that can help you out understanding the logic of NinjaScript and get you on track creating your very own strategies and indicators.

              It appears you already have some basic knowledge of NinjaScript, which will provide a great foundation to learn more. If you'd like to have a conversation with me about these companies and what it is you are needing, please send an email to Info[at]ninjatraderecosystem[dot]com and reference this forum thread.
              Wesley S.NinjaTrader Customer Service

              Comment


                #8
                I just wish there was a simple way to add a breakeven stop after XX ticks or dollars of profit in the wizard, in addition to the regular stop loss. But obviously not. I can't be the only code illiterate person using the wizard that wants to know how to do this?

                Comment


                  #9
                  I would think someone from NT could do a very simple & quick video on how to create stops using the strategy wizard: stop losses, trailing stops, breakeven stops etc & show exactly how to do achieve it.

                  With the amount of time the poor folks at NT are spending on just me & trying to help me understand and create this, there could've been hours worth of how-to videos produced for the code dummies like myself.

                  Comment


                    #10
                    Below is from a NT tech, but my questions are in Red:

                    Here is how the script works.

                    Condition set 1 checks that the position is flat
                    If true:

                    Variable0 is set to the trigger price

                    Variable1 is the to initial stop price

                    Variable2 is set to 0 to reset the trigger (the trigger will only trigger if this is 0)

                    Condition set 2 checks that the position is long, that the close price has met the trigger price (Does this need to read "Close == BreakEvenTrigger" - where I've already set my BreakEvenTrigger in the User Defined Inputs? Or do I need to also add my breakeven ticks in the offset for "Close"?), and that Variable2 is set to 0 and ready to trigger (How do I do this? Whenever I hit the "Add" button in the "When the following conditions are true:" section up top in Set 2, and select Variable2, there's nothing there that allows me to enter 0.)

                    Once these are true:

                    Variable1 is set to the Position.AvgPrice which is the entry point

                    Variable2 is set to 1 so the breakeven is not triggered again

                    DrawDiamond is called to mark the chart where the breakeven was triggered. (When I select DrawDiamond in the "Do the following:" section at the bottom in Set 2, do I add Anything Else? Will it automatically draw the diamond at the breakeven spot?)

                    Condition set 3 checks that we are in a long position
                    If true:

                    ExitLongStop is called to set the stop to the current value of Variable1 which is set in condition set 1 and then condition set 2. (I already have Condition Set 3 as my ExitLong. Do I move my ExitLong to Set 4 or do I just add the ExitLongStop script in addition to my ExitLong?)

                    Comment


                      #11
                      Hi MFinMO,

                      If you are referring to the BreakEvenWizardExample script in post #2, this will be looking for the Variable that contains the trigger price. In the example this is Variable0 which at entry is set to the Close[0] + Breakeven * TickSize (breakeven is a number of ticks, when multiplied by the tick size this will give the amount of profit. We add this to the Close[0] price to set the price of the trigger).

                      DrawDiamond will draw when the condition is true. The condition should be the breakeven condition set.
                      (All actions in the 'Do the following' area will trigger when that condition set is true.)

                      If you already have a Condition set 3, you can add the Condition set 3 from the example to your strategy's Condition set 4. But be aware both of these condition sets will be able to exit your position.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello;
                        Has anyone tried this breakeven example and confirmed that it works?
                        I imported it into NT7 and tested with EMA crossovers. The strategy does not move to breakeven after x amount of ticks, nor does the initial stop work.It does draw a diamond where it is supposed to.That’s the only thing that works.

                        Comment


                          #13
                          Hello guest001,

                          Thanks for your post and welcome to the forums.

                          To assist, please advise the instrument and time frame used and post a copy of your strategy code. Was you code set to run CalculateOnbarClose = true or false?

                          Alternatively, please feel free to send into platformSupport[at]NinjaTrader[dot]Com with a subject line AttenPaul and a link to this thread.
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            How can we do exactly this in NT8?

                            Hi Paul, regarding out exchange today... how can the below done in NT8? Is it possible? I tried to edit the NT7 which was attached to the original thread from you but had no success...

                            Originally posted by NinjaTrader_Paul View Post
                            Hello MFinMO,

                            Thanks for your post and questions.

                            You cannot use both a trailing stop and a set stop loss within the wizard on the same position (entry name). If both are chosen, the trailing stop is ignored. You could use both if they refer to different positions (different entry names).

                            For the set stop loss, in your example, please make sure you set "Mode" to ticks, set Value to "16", keep simulated to "False".


                            I have attached an example of a Breakeven strategy that does not use the wizard stop, it is only an example and you would need to adapt and test to your needs and will give you something to work with within the limits of the strategy wizard. The sample strategy enters a position, places an initial stop and when position is X ticks in profit the stop is moved to breakeven. It does run in CalculateOnBarClose=false so that the stops are placed and moved as quickly as possible, otherwise in true it delays action to the next bar.

                            The user inputs are a profit trigger, in ticks, for the breakeven and an initial stop value in ticks from the entry. This example only shows a long entry.

                            In Condition Set 1, the only condition is to make sure that there is no current entry (This is the area where you would have your entry criteria in your strategy). The actions then are to enter a long position, set user variables, Variable0 = the breakeven trigger, Variable1 is the initial stop, variable 2 & 3 are simply set to zero.

                            In Condition Set 2, we test to see that we have a long entry and check that Variable2 = 0. the actions in set 2 are to adjust the breakeven trigger level based on the filled price and set Variable2 = 1.

                            In Condition Set 3, we test to see we are in a long position, we test to see if Price is >= the trigger (Variable0) and we test that variable3 = 0. The actions in set 3 are to set Variable1 = the entry price, draw a diamond and set Variable 3 = 1 (to act as a conditional flag)

                            In Condition Set 4, we test to see if we are in a long position and the action is to set a long stop according to the value of Variable1. Note: In the first pass through the stop is at the initial stop value and will stay that way until the breakeven trigger is exceeded in set 3 and then the very same variable1 is set to the entry price. So through the use of Variable1 value, we are manipulating the stop price.

                            For a trailing stop you would employ somewhat the same methodology.

                            Please let me know if you have any questions.

                            Comment


                              #15
                              Hello JBU1314,

                              Unfortunately, due the code breaking changes to the structure of NinjaScripts as well as changes to the NinjaScript properties and methods, no scripts created for NinjaTrader 7 will import into NinjaTrader 8.

                              Below is a link to the migration guide which lists what can migrate from NinjaTrader 7 to NinjaTrader 8.
                              http://ninjatrader.com/NinjaTrader-8-MigrationGuide

                              If this is a script you have created that you would like to port to NT8, my advice is to start by creating as much of the script as possible in NinjaTrader 8 using the Strategy Builder (or Strategy Wizard).
                              This will create the framework of the indicator or strategy which has large changes from NT7 to NT8.
                              Then copy all code from the NT7 scripts OnBarUpdate to the OnBarUpdate of the NT8 script.
                              This will introduce errors that will need to be resolved.

                              Below I am including a link to a list of the code breaking changes from NT7 to NT8.
                              http://ninjatrader.com/support/helpG...ng_changes.htm

                              The help guide will be the best way to see how things have changed from nt7 to nt8.
                              When first starting to port scripts, I myself would open the NT7 help guide and the NT8 help guide to the same sections so that I could compare.
                              The majority of code supported by NinjaTrader is included in the help guides.

                              If you get stuck at anytime looking for equivalent code for NT8, please send an email our way (platformsupport [at] ninjatrader [dot] com), or create a post on our forums and we will be happy to assist.
                              Last edited by NinjaTrader_ChelseaB; 01-09-2018, 08:20 AM.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by tgn55, Today, 09:14 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post tgn55
                              by tgn55
                               
                              Started by mrwarkhan, Yesterday, 03:45 PM
                              1 response
                              23 views
                              0 likes
                              Last Post koganam
                              by koganam
                               
                              Started by onevefiefe, Today, 07:42 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post onevefiefe  
                              Started by J_o_s, Today, 06:09 AM
                              0 responses
                              11 views
                              0 likes
                              Last Post J_o_s
                              by J_o_s
                               
                              Started by jeronymite, 03-23-2020, 12:27 AM
                              3 responses
                              35 views
                              0 likes
                              Last Post leontancfa  
                              Working...
                              X