Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Support and Resistance levels order management

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

    Support and Resistance levels order management

    I am working on a strategy trading around levels. When market price hit the bottom level will buy and when market price hit the top level will sell.

    After setting support and resistance levels as user defined multiple variables R1, R2, R3, R4... and S1, S2, S3, S4...

    private double r1 = 1;
    private double r2 = 1;
    private double r3 = 1;
    private double r4 = 1;
    private double s1 = 1;
    private double s2 = 1;
    private double s3 = 1;
    private double s4 = 1;

    For instance, when market price hit S1
    EnterLongLimit(DefaultQuantity, S1, "long1");
    and EnterShortLimit()

    The Question is:
    How do I put in EnterShortLimit() order on the next level minus 1 tick (above the entry level, in this case it is R1 - 1 tick)?

    #2
    er111222, when would you place the order - if the initial entry reports filled?

    This could be done via the OnExecution() method if you wish to send the order before the next bar would then have the position update from the first filled order, so for example your EnterLongLimit here.



    Do you use any exit bracket here for stop and target as you trade this?

    Comment


      #3
      This strategy does not use any target or stop loss order, instead it use Limit order to get in and out.

      I am reworking on my idea on managing orders around levels, forget about the last question... ...my new thinking is always has 2 orders around levels and cancel 1 order when price is say 3 ticks from the level and put the order back when price is say 6 ticks away from the level. So when price move around between 2 levels, this cancelling order and entering order repeatedly working.

      How do I assign the conditions "the level above the market price" and "the level below the market price"?

      How do I go about this condition? When Position.MarketPosition == MarketPosition.Long and market price goes through 2 levels above the entry price.

      Comment


        #4
        Thanks for the clarification, you would then for example need to monitor the difference between the current close and your stored levels for trade entry exit, this way you would know which level is now closest and could be considered for an entry.

        If you're working in real-time on a bar close basis (CalculateOnBarClose = true) then you would also need to consider the case that price is moving too far away from an entry, so basically you likely need a check to determine when to abandon a level setup - same as in manually trading these.

        Comment


          #5
          "my new thinking is always has 2 orders around levels and cancel 1 order when price is say 3 ticks from the level and put the order back when price is say 6 ticks away from the level. So when price move around between 2 levels, this cancelling order and entering order repeatedly working."

          After searching around I decided to use a list to reference which is the nearest levels around market price and code as follow:

          protected void FindNextSR()

          {
          listSR.Sort();
          for (int x = 0; x < listSR.Count; x++)
          {
          if (listSR[x] > Close[0])
          {
          SRNextHigh = listSR[x];
          if (x != 0) SRNextLow = listSR[x - 1];
          Print(SRNextHigh + " High Close=" + Close[0] + " Low " + SRNextLow);
          break;
          }
          if (listSR[x] < Close[0]) SRNextLow = 0;
          if (listSR[x] > Close[0]) SRNextHigh = 0;
          }
          }

          private void FlatOrderManagement()
          {
          //Cancel and add order around SRNextHigh
          if (Position.MarketPosition == MarketPosition.Flat
          && Close[0] >= SRNextHigh - 3*TickSize)
          CancelOrder()

          I have problem in the last bit: CancelOrder(). As it have many working orders sitting on the levels. My question is how to reference the particular working limit order 1 tick below the SRNextHigh?
          Last edited by er111222; 04-17-2012, 02:52 AM.

          Comment


            #6
            Hi, via the IOrder objects you can check at which price a specific order would be resting - http://www.ninjatrader.com/support/h...nt7/iorder.htm

            This would give you a way to CanceOrder() only the one sitting at your next sequential level.

            Comment


              #7
              To move one step backward and look at order entry first, what should the blue code be? I like to reference the entry by different levels int x:

              for (int x = 0; x < listSR.Count; x++)
              {
              if (listSR[x] > Close[0])
              {
              shortLevel_(x.ToString()) = EnterShortLimit(DefaultQuantity, listSR[x], "shortLevel + x.ToString()");
              shortUnderLevel_(x.ToString()) =EnterShortLimit(DefaultQuantity, listSR[x] - 1*TickSize, "shortUnderLevel + x.ToString()");

              Comment


                #8
                Sorry I do not follow your question here, I would suggest you working with IOrders to reference specific order properties such as prices or qty's

                Comment


                  #9
                  OK, how about work with the order.LimitPrice, can you have a look at the following code:

                  protected override void OnOrderUpdate(IOrder order)
                  {
                  if (Position.MarketPosition == MarketPosition.Flat
                  && Close[0] >= SRNextHigh - 3*TickSize
                  && order.OrderState == OrderState.Working
                  && (double)order.LimitPrice = SRNextHigh - 1*TickSize)
                  CancelOrder(working order 1 tick below SRNextHigh)
                  }


                  The question is what should I put in the blue area?

                  Comment


                    #10
                    er111222, you would need to use here the IOrder object that would hold your 'working' order you would need to cancel now. What you would need to custom code is logic to find which IOrder that would be, assumed you would use multiple ones.

                    Comment


                      #11
                      I have many levels and each level has set 2 Iorders - limit orders. If I have the limit price of the orders on a particular level, how do I call the 2 working orders on that level and cancel one of them?

                      Comment


                        #12
                        You will need to keep track of the IOrder names assigned to each level, so you can then CancelOrder() the needed ones.

                        Comment


                          #13
                          If I only know the limit price, how can I find the IOrders with that limit price?

                          Comment


                            #14
                            Best would be building then a collection (for example dictionary) to store your IOrders and limit prices associated, so you could quickly look up the next sequential one.

                            Comment


                              #15
                              Thanks will take a look at that.

                              Comment

                              Latest Posts

                              Collapse

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