No announcement yet.

Partner 728x90


Stop Loss in Strategy Builder question

  • Filter
  • Time
  • Show
Clear All
new posts

    Stop Loss in Strategy Builder question

    Hey all,

    I have a very simple, quick and easy question (I think). I did my due diligence but couldn't come up with the answer.

    In the Strategy Builder, under Stops and Targets, I set a "Trailing Stop." I start the strategy and it works fine; I enter positions according to my conditions. However, once I'm in the position and my Trailing Stop loss is set, how do I simply move the trailing stop, manually, in chart trader, without the stop automatically moving, once I've clicked and held on the stop loss with my cursor?

    Thank you!

    Hello Sh00tHerMcGavin,

    Thanks for your post and welcome to the NinjaTrader forums!

    The trailing stop method is intended to operate autonomously as are most strategies meaning that they are not intended to be operated with intervention such as manually moving an order. The strategy code specifies the stop position and will continue to assert that.

    If you would like to create a strategy where you can adjust the stops and targets on the fly then you would need to work directly in Ninjascript using specific ATMstrategy methods. The strategy builder cannot be used to create this type of strategy. You can create a script that will locate entries according to your conditions and upon an entry fill will apply a preselected ATM strategy template that applies the stop and target as defined in the ATM strategy. This then allows you to manually adjust on the fly the stop and profit target. Once either have been filled, control returns back to the Ninjascript strategy to find the next entry. A working example of this type strategy is in your Ninjatrader platform called "SampleAtmStrategy". The strategy code contains comments that help explain the method functions used.

    Here is a link to the help guide section for the special ATM methods required:

    Paul H.NinjaTrader Customer Service



      Thanks a lot for your reply, that all makes sense.

      Also, I have another question. And I think you can answer it directly. I was searching on how to build two different MACD crossover time frames. I found this forum in which (coincidentally) you had replied to. The video you posted helped tremendously. However I wanted to take it a step further. Can I create two MACD crossovers in the same condition? You created a 10,000 Tick on CL, and applied it to the MACD. Could you also create different Tick value, applied to the MACD? For example. A MACD, based on a 10,000 Tick chart, that is greater than 0. Then, a MACD, based on a 1000 Tick chart, cross above 0. Here's what it looks like in the strategy builder.

      "If All"
      MACD(<Primary>(10000 Tick), 12,26,9).MACD[0]>0
      CrossAbove(MACD(<Primary>(1000 Tick), 12, 26, 9).Default, 0, 1)

      Enter Long- duh

      I hope this makes sense. Here's is the forum I'm referencing.

      Thanks Paul!


      Looking back, you may have answered this question as well.

      Last edited by Sh00tHerMcGavin; 01-05-2019, 12:48 PM.


        Hello Sh00tHerMcGavin,

        Thanks for your reply.

        In the strategy builder, if you have added the secondary data series then yes you can create a condition set that looks at the MACD crossing of both the primary (chart) bars and the added data series.

        I've attached an example of MACD crossing above the average line for both the chart bars and an added 10k tick data series in the strategy builder.

        Click image for larger version

Name:	shootermcgavin-1.PNG
Views:	302
Size:	11.5 KB
ID:	1044528
        Paul H.NinjaTrader Customer Service


          Hi. I have a similar to #1 question. My goal is to have a button, after clicking on it position automatically opens (the quantity of contracts, stop loss and profit target prices are calculated on the moment of click). I made it, then (after opening the position) on chart appears a handler to control stop loss position. But when I am dragging it up/down then it returns back to original position (probably when price changes). I've read about ATM strategies but I don't understand how to control them by code. For example, how to open position with exact contracts quantity? In the example I don't see anything helpful.

          Or maybe you can suggest the optimal way to develop this hybrid strategy (when user manually opens and closes the market position and can change stop loss/profit target prices) but the initial position params (contracts quantity, stop limit, profit target) calculates automatically by an algorithm.


            Hello alvik48,

            Thanks for your post and welcome to the NinjaTrader forums.

            The strategy builder does not work with ATMs. When looking at a chart with the chart trader on and running a ninjascript strategy you will see the same "handles" for the profit target and stop target as an ATM but they behave according to the code of the Ninjascript strategy meaning you can move them but the strategy logic will move them right back. Strategies in general are not intended to work with manual interactions.

            There is a special hybrid strategy that combines the Ninjascript strategy and an ATM template but it uses special methods found here: You can also review the strategy SampleAtmStrategy in your NinjaTrader that uses these methods and the code is well commented to help understand the special methods and properties used.

            Your post in this thread is welcome but I suggest that you create a new thread as the topic here relates to the strategy builder and if I read your post correctly it does not relate to the strategy builder.

            To create a new thread: At the very top of this thread, you can click on "strategy Development" which will take you to that forum top and in the gray bar you will see a blue button called "new topic" and that is how you can create a new topic. Thanks for your help in keeping these forums organized.

            Paul H.NinjaTrader Customer Service


            Latest Posts


            Topics Statistics Last Post
            Started by swcooke, Today, 07:17 PM
            0 responses
            Last Post swcooke
            by swcooke
            Started by aguison, Today, 04:20 PM
            1 response
            Last Post s.kinra
            by s.kinra
            Started by timko, Today, 04:11 PM
            0 responses
            Last Post timko
            by timko
            Started by djkiwi, Today, 03:25 PM
            2 responses
            Last Post djkiwi
            by djkiwi
            Started by hdge4u, Today, 12:29 PM
            1 response
            Last Post NinjaTrader_Manfred