Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing Stop - New to NinjaScript

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

    Trailing Stop - New to NinjaScript

    Hello commuity,

    I'm normally a mql5 developer, but I'm interested in developing NinjaScript and want to get my first script working.

    I don't know how commands are used in NinjaScript. Can you give me some examples like OrderModify() in MQL5 for setting StopLoss? Or how can I step through every open order of the current chart and set the StopLoss to 2 Points?

    My strategy sets an initial stoploss to 2 points and trails after the order is in +1 point profit.

    Thank you very much and best regards.
    Max.

    #2
    Welcome to our forums here Max - for a basic go with our Set() methods for stop / order placement and further custom trailing I would recommend this reference sample - http://www.ninjatrader.com/support/f...ead.php?t=3222

    The strategy instance itself would only have access to it's own placed orders though.

    If you look for deeper event based processing such as with fill states or orderstatus updates, the IOrder archtitecture would be ideal - http://www.ninjatrader.com/support/h...nt7/iorder.htm

    Here's how this more advanced concept would be used to submit protective exits upon seeing the exact fill event happen - http://www.ninjatrader.com/support/f...ead.php?t=7499

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Welcome to our forums here Max - for a basic go with our Set() methods for stop / order placement and further custom trailing I would recommend this reference sample - http://www.ninjatrader.com/support/f...ead.php?t=3222

      The strategy instance itself would only have access to it's own placed orders though.

      If you look for deeper event based processing such as with fill states or orderstatus updates, the IOrder archtitecture would be ideal - http://www.ninjatrader.com/support/h...nt7/iorder.htm

      Here's how this more advanced concept would be used to submit protective exits upon seeing the exact fill event happen - http://www.ninjatrader.com/support/f...ead.php?t=7499
      Thank you for your fast reply.

      One question: If I place an order manually, can the strategy set a stoploss for every manual placed order? That's what my strategy does in MQL5.

      Comment


        #4
        Your strategy would not be aware of that order, there's no cross communication over from manual trading. That is currently an item though on our list of feedback collected for potential enhancement going forward.

        What customers have been looking into is, setting a historical entry for a script that would be attempting to mimic then your manual entry > you have a script then running that would be managing a strategy position and thus you could issue a stop for it and adjust.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Your strategy would not be aware of that order, there's no cross communication over from manual trading. That is currently an item though on our list of feedback collected for potential enhancement going forward.

          What customers have been looking into is, setting a historical entry for a script that would be attempting to mimic then your manual entry > you have a script then running that would be managing a strategy position and thus you could issue a stop for it and adjust.
          Thank you Bertrand. So I have to wait till the cross-communication is possible. That is the only way my strategy with setting a stoploss for every manually opened order will work.

          Thank you very much!

          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
          108 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