Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple ATM order handle

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

    Multiple ATM order handle

    Hi,

    I have a question about how to handle multiple ATM orders,
    Eg. I have 3 ATM entries,( each entry have atmStraegyID ) how do I know which ATM is finished.
    Finished means the ATM order meet target/stopLost.
    In fact, I put atmStraegyID in an array list. when one order meet target/stopLost. I want to remove this atmStraegyID from array list.

    How can I get rid of 'dead' atmStraegyID?

    Thanks,
    Thomson

    #2
    Hello Thomson,

    You may set the atmStrategyId string to Empty so that way you know this atmStrategyId is not longer working or being used. So for just a string you may just use "atmStrategyId = string.Empty;" or since you have an array you may just set the index of that array to "string.Empty" to clear this out.
    JCNinjaTrader Customer Service

    Comment


      #3
      JC,thanks for your quickly respond.
      How do I know what is the time I set atmStrategyID is string.empty? I mean I filled an atm order with stoplost 3 and target is 10.
      When the price meet stoplost/target, how do I know it happened?
      How to kill out of date atmStrategyID ?

      Thanks
      T
      Last edited by thomson; 02-06-2014, 03:13 PM.

      Comment


        #4
        Hello T,

        You could do something like check to see if the "atmStrategyId" is not empty and if the "GetAtmStrategyMarketPosition()" is flat so that you know if the order is filled or cancelled to reset this.

        For example:

        Code:
        if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
        {
        	atmStrategyId = string.Empty;
        }
        We have an example of this as well that you may view by going to Tools -> Edit NinjaScript -> SampleAtmStrategy
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,
          Thanks for your code. This is what I need.
          But consider the pending order, (eg. price currently is 90,but I want to long at 100. I pending ATM order at 100,but not filled this time. At the same time, I want to kill atmStraegyID which is out of date on onbarupdate)
          How can I write the code?

          Many thanks.
          T

          Comment


            #6
            Hello T,

            The code would still be the same outside OnBarUpdate().

            You may still want to call it inside of OnBarUpdate() since ATM Strategies will be called a bit different, but if you are worried about that the order not being entered yet if you check out the sample strategy that we have loaded into NinjaTrader the "SampleAtmStrategy" it will demonstrate this.

            They check the orderId or the Entry order state to make sure that it is filled. Once filled then they check the atmStrategyId to see if the stop or target has been filled.
            JCNinjaTrader Customer Service

            Comment


              #7
              They check the orderId or the Entry order state to make sure that it is filled. Once filled then they check the atmStrategyId to see if the stop or target has been filled.
              Yes, you are right.
              But how can I get stop or target has been filled information?

              I think the code as below just for check ATM strategy entry order position is Long, short or Flat. Is it correct?
              Code:
              GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat
              How to check this atmstrategy stop lost/target marketposition? Code please.

              Many thanks,
              T
              Last edited by thomson; 02-07-2014, 08:43 AM.

              Comment


                #8
                Hello T,

                There is no direct way to get this value, but you may get your Entry order fill price and then after your Stop or Target order is filled you may get the Realized PnL of your ATM Strategy and calculate the exit price manually.



                Where you may take the Realized Pnl and divide it by the Point value (Instrument.MasterInstrument.PointValue) to get the number of ticks away from the entry price that your order has been filled at.
                JCNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by helpwanted, Today, 03:06 AM
                0 responses
                4 views
                0 likes
                Last Post helpwanted  
                Started by Brevo, Today, 01:45 AM
                0 responses
                7 views
                0 likes
                Last Post Brevo
                by Brevo
                 
                Started by aussugardefender, Today, 01:07 AM
                0 responses
                5 views
                0 likes
                Last Post aussugardefender  
                Started by pvincent, 06-23-2022, 12:53 PM
                14 responses
                242 views
                0 likes
                Last Post Nyman
                by Nyman
                 
                Started by TraderG23, 12-08-2023, 07:56 AM
                9 responses
                384 views
                1 like
                Last Post Gavini
                by Gavini
                 
                Working...
                X