Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Information on stop losses

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

    Information on stop losses

    Hi, I'm new to Ninja script and trying to figure out any limitations of using it to automate a pre-planned trade strategy. I have a couple of questions about effective use of stoplosses with ninja script and IB.

    1. Am I correct in thinking that when a stoploss is attached to a limit order through Ninja Script, the limit order would be sent to IB's server (via TWS) to await execution but the stoploss order would not be sent to the IB server until Ninja Trader received a signal confirming execution of the limit order?

    If this is the case then it is a concern as there is the possibility, however slight, of my connection going down leaving my limit order able to execute with no stoploss in place. TWS and its API allow for the stoploss order or a bracket order (OCO stoploss and take profit) to be attached to the limit so that they wait on the IB server together, reducing the risk of any connection errors or delay in activating the stop orders. Is this possible to achieve through Ninja Script?


    2. If the stoploss is only sent after the original limit order has executed, is there any advantage to attaching it as a stoploss or would a stand alone stop order be just as effective? The only advantage I can see is that the stoploss is automatically cancelled if I cancel the limit order but it would be pretty simple just to cancel them both.

    An advantage of placing the stoploss as stand alone order would be that I could set the order size to a different quantity than the original entry order. Therefore I would be able to enter the trade with a single order and scale out with multiple exit orders. Is this correct?


    3. Is it possible to use Ninja Script to create OCO groups to exit trades without them being linked to an entry order? For example, enter a trade with a buy limit order and once the strategy receives confirmation of execution, to place one stop order to act as a stoploss and a limit to act as a profit taker, with whichever of these secondary orders that executes first cancelling the other. I haven't come across a way of creating OCO groups in Ninja Script, any pointers would be great.

    Many thanks,
    Fred.

    #2
    Originally posted by manfish77 View Post
    ...
    3. Is it possible to use Ninja Script to create OCO groups to exit trades without them being linked to an entry order? For example, enter a trade with a buy limit order and once the strategy receives confirmation of execution, to place one stop order to act as a stoploss and a limit to act as a profit taker, with whichever of these secondary orders that executes first cancelling the other. I haven't come across a way of creating OCO groups in Ninja Script, any pointers would be great.

    Many thanks,
    Fred.
    You do that by using OnExecution() to determine when to place your exit orders. There is a reference sample covering exactly that scenario.

    ref: http://www.ninjatrader.com/support/f...ead.php?t=7499

    Comment


      #3
      Hello Fred,

      Welcome to the NinjaTrader Support Forum!

      1. If you are using the Managed Approach yes, that would be correct. We do also recommend that you do not leave your computer unattended while running your NinjaScript Strategy as well for cases like this and so that you can make sure that order are processing the way you want.

      Using the Unmanaged Approach it is possible to do what you wish.

      2. Using the SetStopLoss() method you would not be able to call the Cancel() method to be able to cancel the order but yes if the Entry order is closed the StopLoss would be automatically cancelled. Both work similiarly effective.

      Yes, that would be correct, but you would also have to have multiple Entry Orders each with a different Signal name to be able to scale out of an order.

      If you have never created a strategy before, I would recommend starting with our point and click interface Strategy Wizard.

      Please see our Help Guide articles on How to use the Strategy Wizard as well as NinjaScript Strategies. More information on these subjects can be found below:
      Click here for more information on Developing Strategies with the Strategy Wizard
      Click here for a Tutorial on Developing Strategies

      I'm also proving a link to a recently recorded 'Automated Strategy Development Webinar' video for you to view at your own convenience: Automated Strategy Development Level 1 - NinjaTrader Training - 3/26/2013

      There are a few Sample Automated Strategies which come pre-configured in NinjaTrader that you can use as a starting point. These are found under Tools--> Edit NinjaScript--> Strategy. You will see locked strategies where you can see the details of the code, but you will not be able to edit (you can though always create copies you can later edit via right click > Save as)

      We also have some Reference samples online as well as ‘Tips and Tricks’ for both indicators and strategies:
      Click here to see our NinjaScript Reference Samples
      Click here to see our NinjaScript Tips

      These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

      Lastly, you can attend one of our live Automated Strategy Development Webinars to help you get up to speed on developing strategies:


      We also have Premium Paid Educational events where you will join a NinjaScript expert for a pair of 6-8 hour long intensive courses designed to provide you with in-depth training on how to create, test and deploy fully automated strategies.



      If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
      Click here for a list of certified NinjaScript Consultants
      JCNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      646 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      367 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X