• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change CalculationMode for sometime (during active orders)

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

    Change CalculationMode for sometime (during active orders)

    Hi NinjaTrader Team!

    First thanks for making such a good product possible. It's the best programming engine I've seen so far.

    Now to my question:
    I coded an trading strategy for creating orders based on bars close. So calculation mode is set to OnBarClose wich works fine so far. Now, when I submitted an EntryOrder I need to keep track of price changes, for example for trade cancelation when the signal is no longer valid (if not already executed).

    How could I achive that?
    Is there something like a OnTick Event I could subscribe on during the time I have any working orders?
    I don't want to change the hole calculationMode to OnPriceChanged if there is a better or simple solution.

    Thanks in advance,
    Johnny

    #2
    Hello Johnny90,

    Welcome to the NinjaTrader support forums.

    Generally, in this case, you would need to change to using OnEachTick or OnPriceChange. If you are just trying to keep track of something you may be able to use OnMarketData instead of changing the calculation mode. This would only work in realtime though, so if you needed historical results based on this information you would either not be able to or would have to make separate logic for TickReplay.

    https://ninjatrader.com/support/help...b=onmarketdata
    https://ninjatrader.com/support/help...sub=tickreplay

    This override could be used to observe the live data which is called frequently so you could also use this to execute logic frequently.

    Alternatively, if you change the Calculation mode, you can also use IsFirstTickOfBar to simulate OnBarClose while working tick by tick.

    https://ninjatrader.com/support/help...FirstTickOfBar


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse, that's enough so far.

      One off-topic thing: On manual trading with IB I'm able to attach a stop loss order to the entry order. So if the entry order is executed the stop loss order is immediately active. When I use the SetStopLoss() method I'm just wondering: Is the order immediately send to the broker's side or gets the order send to the broker after the entry order is triggered?

      Best regards,
      Johnny

      Comment


        #4
        Hello Johnny,

        When using SetStopLoss, the stop loss would be sent as upon the entry filling. As this is part of the managed approach the stop would be handled internally without other logic needed in the script. This can be configured once at the start of the script be to have a set value away from the entry or you can use this in your logic where you would like.

        You can find further information about SetStopLoss and the other "Set" methods in the help guide:
        https://ninjatrader.com/support/help...ub=setstoploss

        Stop loss orders are submitted in real-time on incoming executions from entry orders
        I look forward to being of further assistance.
        Last edited by NinjaTrader_Jesse; 12-19-2018, 08:08 AM.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse,
          so is there a way to attach the stop order to the entry order if the Broker supports this?

          Best regards,
          Johnny

          Comment


            #6
            Hello Johnny90,

            Thank you for the reply.

            Is there a specific feature that you are referring to with your broker that you can provide the name of?

            In NinjaScript, the Managed order entry system uses "Signal Name" and "From Entry Signal" to link entries and exits together so this could be used to logically associate orders. This is described in parent page to the link I had provided in the last post, https://ninjatrader.com/support/help...d_approach.htm (How to close a position section)

            There is a small sample that shows how the signal name can be used to exit and link the exit with a specific entry.


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,
              yes the managed approach works fine the difference is that in IBs TWS I'm able to attach the stop loss to the entry order and send both to the Broker. In case of connection loss the stop order gets activated on the Brokers side immidiatly after the order ist triggered.
              But when using SetStopLoss () and a connection loss occurs during the time the order gets triggered the position is not secured until the Connection is reetablished am I right?

              Best regards,
              Johnny

              Comment


                #8
                Hello Johnny90,

                the stop order gets activated on the Brokers side immediately after the order is triggered.
                In this case what you are describing would not necessarily be a feature that NinjaTrader would have, this would likely be more of a broker-specific feature that IB offers. Do you know the name of this specific order type in TWS where the order is activated upon filling the entry at the broker end with IB? I would like to review this and submit a feature request where I can.

                You are also correct if your connection were to be interrupted before the entry fills the script would be unable to do other actions until it reconnects. The entry is submitted to the broker but NinjaTrader is working as a radio waiting to receive feedback from the broker for further actions. If you are disconnected, you cannot have this feedback. If the disconnect happened after the stop submitted, that would reside with the broker in most cases so that would still protect a position but the platform would have no control or other feedback while disconnected. This is, of course, a situation to use the emergency trade desk number (if offered) to manage your account.

                If the connection is a major concern or ongoing problem we generally suggest using a VPS (virtual private server) that has a reliable connection so that you do not need to severely consider this in your logic. You can remote into the server to manage NinjaTrader from any PC that supports remote desktop which is an added benefit of this use case.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse,
                  I don't know how this feature is called but I attached a small screenshot from my TWS mobil where you can see that the stop loss can get attached to the entry order. The status is then blue(working order received by broker but condition not met) and when the entry order is filled the stop loss order turn to green(order active and running). This works even the connection is lost or I close the TWS mobile instance so I guess both orders are send to the broker. In TWS desktop there's the same functionality. Would be very great to have this feature in NT strategies.

                  Thanks for the help so far,
                  Michael

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ralett, Today, 11:44 AM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_Spencer  
                  Started by DMDINAZ, Today, 11:03 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by sukhob, Today, 10:14 AM
                  4 responses
                  10 views
                  0 likes
                  Last Post sukhob
                  by sukhob
                   
                  Started by beaacontreras, Today, 09:27 AM
                  1 response
                  20 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Started by fxSol, 03-17-2019, 04:17 AM
                  5 responses
                  28 views
                  0 likes
                  Last Post NinjaTrader_ChristopherS  
                  Working...
                  X