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

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
    Chris L.NinjaTrader Customer Service

    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
        Chris L.NinjaTrader Customer Service

        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
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ZenCortexHurry, Today, 01:07 PM
            0 responses
            2 views
            0 likes
            Last Post ZenCortexHurry  
            Started by ZenCortexHurry, Today, 01:04 PM
            0 responses
            0 views
            0 likes
            Last Post ZenCortexHurry  
            Started by f.saeidi, Today, 12:14 PM
            3 responses
            9 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Russ Moreland, Today, 12:54 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by philmg, Today, 12:55 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Working...
            X