Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Some basic questions

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

    Some basic questions

    Hi,

    I'm trying to write a very simple breakout strategy, just to get started with NT scripting, but I'm kinda stuck. Hope you guys can answer me some of my questions.

    1.) I'd like to submit a single order above the current bar and if, at the end of the bar's time, it's not filled (because price level was not hit) I'd like to move the order to some other price level. My first approach was to use AtmStrategyCreate() and AtmStrategyChangeEntryOrder() to create and change my order and then have my stop loss, breakeven and auto trail managed by a custom ATM strategy. This works well as long as I'm not running this strategy in the strategy analyzer. ATM strategies do not work on backtests. This would be my first question: Why not? How am I supposed to test and optimize my strategy then? I could use market replay and manually see how my strategy performs, but that doesn't seem very desirable to me.

    2.) My next approach was to have a look at the 'managed approach order methods'. These would probably work on a backtest (as far as I understand), but they do not support a ChangeOrder() method. I've found somewhere on the forums that the recommended way to change my order is to first cancel it and then submit a new order at the new target price. I haven't tested this, because it just doesn't feel right. Why should I first cancel an order and then submit a new one, when I can simply change my existing order?

    3.) I then had a look at the 'unmanaged approach'. This approach offers a ChangeOrder() method, but no order management at all (as the name says...). I would have to implement it myself. This is not a problem in general, but I would end up programming exactly what your ATM strategies are allready capable of. Again, this doesn't feel right.


    I hope I could make myself clear and you can show me a best pratice solution for my problem. Also, I'm curious to find out why ATM strategies do not work on backtests. Would have been so easy..

    Kind regards,
    Kai
    Last edited by wooosh; 12-25-2012, 02:10 PM.

    #2
    Hi Kai,

    1) It would be really nice if Ninja 8 has this feature.
    2) on the managed approach, you submit the order at each bar refreshing the entry price. If no order is submited at some onbarupdate() then the order is cancelled.
    3) ..you are correct, you need to program almost everything again...

    What you are looking for seems to be possible using the managed approach.

    Best wishes

    Pablo Maglio
    www.theindicatorstore.com
    pmaglio
    NinjaTrader Ecosystem Vendor - The Indicator Store

    Comment


      #3
      Originally posted by wooosh View Post
      Hi,

      I'm trying to write a very simple breakout strategy, just to get started with NT scripting, but I'm kinda stuck. Hope you guys can answer me some of my questions.
      ...

      2.) My next approach was to have a look at the 'managed approach order methods'. These would probably work on a backtest (as far as I understand), but they do not support a ChangeOrder() method. I've found somewhere on the forums that the recommended way to change my order is to first cancel it and then submit a new order at the new target price. I haven't tested this, because it just doesn't feel right. Why should I first cancel an order and then submit a new one, when I can simply change my existing order?


      I hope I could make myself clear and you can show me a best pratice solution for my problem. Also, I'm curious to find out why ATM strategies do not work on backtests. Would have been so easy..

      Kind regards,
      Kai
      1. Use an IOrder for your order.
      2. Use the liveUntilCancelled overload
      3. On the start of the next bar, check if the order has been filled, by checking the IOrder state, and if not, change the IOrder's price by resubmitting the same IOrder with a different price.
      ref: http://www.ninjatrader.com/support/h...nt7/iorder.htm

      Comment


        #4
        Thanks a lot Pablo and Koganam! It works so far.

        I'd like to ask two more questions:

        1.) Let's say I'm running my strategy on a 1-minute chart but I want to move my trailing stop on every tick if necessary. Would I use a "multi timeframe strategy", containing a 1-minute and a tick data series, to achieve this? (I've read about it somewhere on the forums)

        2.) On my chart the order entry and exit markers are only painted when the trade is finished (position closed). Can I change this behaviour so that the markers are painted as soon as a position is opened? Or would I need to program an indicator which does exactly that?

        Thanks and kind regards
        Kai

        Comment


          #5
          Originally posted by wooosh View Post
          Thanks a lot Pablo and Koganam! It works so far.

          I'd like to ask two more questions:

          1.) Let's say I'm running my strategy on a 1-minute chart but I want to move my trailing stop on every tick if necessary. Would I use a "multi timeframe strategy", containing a 1-minute and a tick data series, to achieve this? (I've read about it somewhere on the forums)

          2.) On my chart the order entry and exit markers are only painted when the trade is finished (position closed). Can I change this behaviour so that the markers are painted as soon as a position is opened? Or would I need to program an indicator which does exactly that?

          Thanks and kind regards
          Kai
          "Yes" to both questions.

          For question 1, on a Strategy that is running real time, all you would need to do is to make COBC false, rather than have 2 BarSeries: for backtesting and using the Strategy Analyzer, you would need the multiple BarSeries.

          Comment

          Latest Posts

          Collapse

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