Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best way to use ninjascript to trail or close a manually entered trade?

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

    Best way to use ninjascript to trail or close a manually entered trade?

    I'm just looking for simple exit logic or a trail stop to take over after I discretionarily place a trade. Not a distance-based trail stop, a stop that is updated using logic.

    I'm currently using my own buy/sell/flatten buttons on the chart to enter orders from within the strategy to achieve this.

    Is there a better way?

    #2
    Hi Walter, thanks for posting.

    Your strategy will need to use OnMarketData or OnBarUpdate to update the stop to the correct price level. Assuming you are using Account.Submit to place the order, you will place the initial stop when the entry order fills from ExecutionUpdate. While the trade is active, monitor OnBarUpdate or OnMarketData to change the stop order to an appropriate price.

    Best regards,
    -ChrisL

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi Walter, thanks for posting.

      Your strategy will need to use OnMarketData or OnBarUpdate to update the stop to the correct price level. Assuming you are using Account.Submit to place the order, you will place the initial stop when the entry order fills from ExecutionUpdate. While the trade is active, monitor OnBarUpdate or OnMarketData to change the stop order to an appropriate price.

      Best regards,
      -ChrisL
      For manually entered trades?

      I have a strategy that I currently use for this that uses WPF buttons rather than hotkeys or chart trader buttons, so that the strategy can "take ownership" of the trade once I put it on. I'm basically asking if there's another way to do this.

      For example can I use a hotkey to get into a trade with a stop and targets using chart trader, and then have a strategy running on the chart with exit logic that will take care of the rest?

      Comment


        #4
        Hi Walter, thanks for your reply.

        Custom buttons need to be used because the script must be able to identify the entry order for OCO and PnL tracking purposes, Alternatively, you can set up a hotkey through Tools>Hotkeys>Order Entry. When you activate the hotkey with an ATM strategy template selected the atm can manage the order.

        Best regards,
        -ChrisL

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hi Walter, thanks for your reply.

          Custom buttons need to be used because the script must be able to identify the entry order for OCO and PnL tracking purposes, Alternatively, you can set up a hotkey through Tools>Hotkeys>Order Entry. When you activate the hotkey with an ATM strategy template selected the atm can manage the order.

          Best regards,
          -ChrisL
          Oh great I didn't think that I could use custom logic to close a trade using ATM. Can you point me to an example of this?

          I must have done a poor job describing what I'm doing.

          I have two methods currently that I use:

          1. Custom buy/sell buttons that submit the order, so that my code can monitor the trade and exit (or adjust the stop) according to coded logic.
          2. Hot keys and ATM but until your reply I thought that it was not possible to get my coded logic to manage the trade.

          Comment


            #6
            Hi Walter, thanks for your reply.

            You can not use C# logic to close out of a manually placed ATM strategy trade. The ATM strategy will let you define a Stop Strategy within the template that defines trailing stop behavior. To manage the trade with C# logic you must use the custom buttons on the chart.

            Best regards,
            -ChrisL

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            20 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            119 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            63 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            41 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            45 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X