Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit on opposite signal

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

    Exit on opposite signal

    Hello All,

    I am wondering if it is possible, and how if so, to create an exit/TP at a reversal. Example, using the TSSupertrend I get in at the beginning of an uptrend, and want to exit when the downtrend signal fires. Is this possible? Still new to strategy coding so please be gentle.

    #2
    Helllo sprks7979,

    To exit at a reversal you would just submit an exit market order to exit the position. If you wanted to set a target at that point you could use one of the target methods like SetStopLoss or SetProfitTarget during that condition if you waned to activate the target at that point.

    Comment


      #3
      NinjaTrader_Jesse Thanks for the explanation. Another question if I may. I am currently using the strat builder since I'm not very adept at C# yet. In the builder, is there a way to exit a position based on the signal of an indicator. Perhaps additional sets?

      example, I go short when the price is below the Parabolic and would like to exit when the price closes above the 14 EMA.

      Also, where are the strategies running? I know this may seem to be a convoluted question but are they "ran" locally on my machine or ninjatrader servers? My question arises because if I am in a trade and my strat is supposed to exit for whatever reason, if I load a chart at that moment, it misses the exit and runs wild. I just found the "keep strat running" option with a disconnect but I wouldnt think that applies since Im still technically connected just loading.

      Thanks for your assistance and sorry for the mundane questions. Im just trying to learn a bit more.

      Comment


        #4
        Hello sprks7979,

        In the strategy builder you can use exit orders as an action of a condition. Targets cannot be used in the Sets so if you wanted to base a target off an indicator you would need to instead make a target from an exit order. You can find an example of that concept here: https://ninjatrader.com/support/foru...rategy-builder


        Strategies run from the control center strategies tab. You can apply strategies to a chart as well to visualize them, you can still manage the strategy from the control center. These are run locally on your machine. You would need to ensure your platform is connected and you keep your PC on while running a strategy.

        Comment


          #5
          Ninjatrader_Jesse, thanks again, I think I can get that to work, now one final issue, at least for now. I am running into an issue where a buy signal fires, and then closes out for profit or stop loss and then, since the signal is still positive it fires on the next bar close. I have a fairly simple PSAR/MACD/EMA strat that im using to test and in one day of trading there were some 300 trades. My question, if possible in the builder, how would one go about only having one trade per signal. Example, price closes above PSAR, MACD crosses average buy signal happens, TP = 40 ticks. I would then want the strat to cool until a "reset" occurs such as PSAR is still good but MACD is no longer valid AND when MACD comes back to valid it issues a new signal. Is something like this possible in the Strat builder? I think this may be my last question today as I am still trying to figure out the unique orderId errors while live trading.

          Thanks for your continued time and patience.

          PS. Is there a place/forum that you know of that has "mentors" for ninjatrader strategy and indicator building? I would like to learn a bit more but have some issues with some of the concepts.

          Comment


            #6
            Hello sprks7979,

            You can use the BarsSinceEntryExecution to do that or also a user variable. The bars since entry would be easier if the condition stops being true after one or more bars.

            BarsSinceEntryExecution returns -1 if no previous entry was found or reports 0,1,2,3 etc as the bars progress.

            To use this in a set in the builder you would need to create a Group condition. Click the Group button and then add the two following conditions:

            Left: Misc -> Bars since entry
            Center: equals
            Right: Misc -> Numeric value -> -1

            Add another condition:

            Left: Misc -> Bars since entry
            Center: greater
            Right: Misc -> Numeric value -> 1 or the number of bars you want to wait before another entry.

            The alternative would be to use a bool variable. The variable could start with a default value of true to indicate that the entry condition can be true. As part of the entry condition you would check if that user variable is true in addition to your other conditions. As an action in the entry condition you would set the bool variable to false. This would prevent the condition from ever happening again until you reset the variable to true in a different set based on some other condition.

            You can always ask individual questions on the forum here for help. You can also seek out third party educators however I am not aware of any myself. Please contact [email protected] for further assistance with third party developers or educators.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            54 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            130 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            72 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X