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

Strategy Builder

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

    Strategy Builder

    Hello! Is it possible after entering deals to activate the Trailing stop and Take profit in a Strategy Builder?

    Thanks!

    #2
    Hello U0000999,

    Thank you for your inquiry.

    A simple trailing stop (which will trail by 1 tick for each tick in profit starting from a defined offset from the entry price) may be set on the Stops and Targets screen, as may a profit target. I'm attaching a simple example below.

    For more complex trailing behaviors, you can use exit orders to create a trailing stop. Going this route would require you to use a ExitLong or ExitShort to mimic a profit target as if you try to use a limit order for this you'll run afoul of order handling rules for managed strategies and either the profit target or the trail stop order would be ignored. I'm also attaching an example below that demonstrates using exit orders to set up the trailing behavior.

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

    Comment


      #3
      I have two questions regarding the strategy builder:

      1) How do I add an arrow to the chart as an action? What I am wanting to do is when the conditions are met, I want an arrow to paint on the current candle, so many pips above the high/low of the current candle. I looked at the strategy builder user manual, but it seems that their example is cutoff before it explains the entire instruction.

      2) I am trying to include the Wiseman alligator in my strategy. I am trying to figure out a way of adding 5 above 8 and 8 above 13 as a condition. I am new to using the strategy builder, so if someone could explain it in a very simplistic way I would greatly appreciate it.

      Thank you for your help!!!

      Comment


        #4
        Hello gregorious13,

        Thank you for your note.

        As far as adding an arrow to the chart, the things to note would be that you will need to add the CurrentBar to the tag if you want a new drawing to be generated on each time there's a new signal - if you leave the tag as is it will draw a single arrow and update that drawing each time it is called. You'll also need a Y value which if I want to draw it above or below the bar, I will usually choose the high or the low price of the bar + a positive or negative number of ticks so it's a little above or below the bar. I'm attaching a simple example which is basically the built in Sample MA Crossover, but plots arrows when the two MAs have crossed instead of submitting orders.

        For the Wiseman Alligator, when you say 5 above 8 and 8 above 13, I believe you're referring to the periods of the three plots (Lips, Teeth, and Jaws). You'd want to select the Wiseman Alligator on both sides, and if you want to check when the 5 period (Lips) is above the 8 period (Teeth), you'd select those plots in the Condition Builder when creating the condition:

        Click image for larger version

Name:	2022-02-02_07-31-35.png
Views:	526
Size:	142.7 KB
ID:	1188023

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

        Comment


          #5
          Thank you, Kate W. for your help. I think I got the alligator part figured out, but I am still not completely understand adding an arrow signal to the chart. So in the "tag field" do I just put "Current Bar" as my description so that the arrows will display for each signal? Will this also display historical signals? Regarding the Y statement, if I wanted a signal to appear 5 pips below the low of the signal candle, what would my statement be?
          Thank you for your help!

          Comment


            #6
            Hello gregorious13,

            Thank you for your reply.

            If you hover over the Tag field in the example and click set, it will be easier to see how I've set that up. You would add a string by clicking add, then click set within that box and select Current Bar from the Misc folder to add that. These will also be displayed historically if the script calculates historically.

            If you want the signal to appear 5 pips below the low of the candle, in the Y field click set, choose the low price, and in the Offset area set the numerical field to -5 and the dropdown to pips and click ok.

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

            Comment


              #7
              Ahhhh, got it. Thank you Kate W., you are a huge help!!!

              Comment


                #8
                Ok, Kate W., I think this is my last questions. I am using two indicators (alligator and a MACD histogram) and their conditions to create a signal are separate from each other. In other words, alligator has to meet certain conditions + MACD histo has to meet certain conditions in order to generate a signal. In the conditions field, should I separate the conditions for each indicator in their own group? If so, by doing this will both groups still be referenced in order to generate a signal?

                Last question (I think), am I right in putting all the "buy" conditions in one set and the "sell" conditions in another set?

                Once again, thank you for your help!!!

                Comment


                  #9
                  Hello gregorious13,

                  Thank you for your reply.

                  You can add multiple conditions that will all be linked with either all "And" comparisons or all "Or" comparisons directly in a condition set without needing to put those in separate groups. You could if you wanted, but it's not necessary. Think about it this way. If you have the dropdown in the upper right set to "If all", all the conditions in the set will need to be true in order for the actions section to be taken, no matter which indicator they refer to. So if the alligator conditions are met AND if the MACD histo conditions are met, then the signal would be generated.

                  Groups would more often be used when you have some conditions where all of them need to be true and some conditions where as long as those first conditions are true and at least one of this other group of conditions are true you want to generate a signal or entry.

                  Yes, you would be correct in creating separate condition sets for buys vs sells - you'd likely want the conditions for those entries to be different so you'd need them in different sets.

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

                  Comment


                    #10
                    Ok, I lied Kate W. I do have one more question. I looked at the user guide and there is very little info on the "stops and targets" section. My idea for the strategy is to have a 25 pip stop from entry, followed by move to break even after +10 pips, followed by +10 pips after +25. Can you explain how to do this?

                    I am assuming that for the stop loss, I will use the "from entry signal" field but I am not sure what to enter here. Then I am assuming in the "value" field I will put 25. Lastly, I am assuming that the remaining parts I will use the trailing stop section but I am not sure nor am I sure how to set it up.

                    Thank you Kate W. for all of your help.

                    Comment


                      #11
                      Hello gregorious13,

                      Thank you for your reply.

                      This is going to be pretty complicated to achieve in the Strategy Builder and would be considerably easier if you unlock your code, but it's not impossible. You would need to use Exit orders in the Conditions and Actions screen to mimic the use of Stops and Targets as Set methods in the Strategy Builder cannot be updated dynamically so it would not be possible to modify the stop to breakeven after x number of pips in profit.

                      I'm attaching a relatively simple example strategy that illustrates the logic necessary to submit an exit order as a stop and modify that stop to BreakEven in the Builder. You could certainly build upon this code to move the stop again after moving it to breakeven initially.

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

                      Comment


                        #12
                        Ok I have built the entire strategy, thank you, Kate W. for your help. However, I am having issues with my stop loss and take profit. So I have a take profit and stop loss in the "inputs" section and they are referenced in the "stops and targets" section. However, when a trade is taken, no stop loss or take profit is triggered. Please see attached pics. Can you please advise?

                        Click image for larger version

Name:	take profit.png
Views:	516
Size:	66.3 KB
ID:	1188837Click image for larger version

Name:	stop loss.png
Views:	519
Size:	69.7 KB
ID:	1188835Click image for larger version

Name:	inputs and variables.png
Views:	521
Size:	73.2 KB
ID:	1188836
                        Attached Files

                        Comment


                          #13
                          Hello gregorious13,

                          Thank you for your reply.

                          You have put what appear to be names for the profit target and stop into the From Entry Signal field. This would be used to link entries and exits. So what happens is that when you put a name in that field is that when an entry is filled, it will check to see if the filled order has an Entry Signal name that matches what's in the From Entry Signal field for the exit order, and if these match only then will the stop or target be triggered. Usually this would be used if you're scaling into or out of a position so you can have stops at different levels.

                          So, for example looking at your screenshots, you've put "ProfitTarget" in the From Entry Signal field for the profit target. If you do not have an entry that has the name ProfitTarget in the Entry Signal field, this target would never be triggered.

                          If you remove the string from this field, the Profit Target would apply to all entries. Same thing with your stop loss.

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

                          Comment


                            #14
                            So if I want it to apply to all trades. Should it look like the attached pic?

                            Click image for larger version

Name:	New Stop Loss.png
Views:	501
Size:	86.4 KB
ID:	1188843

                            Comment


                              #15
                              Hello gregorious13,

                              Thank you for your reply.

                              Yes, it would apply to all trades as you have it in your latest screenshot.

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

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              41 views
                              0 likes
                              Last Post alifarahani  
                              Working...
                              X