Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy not working properly

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

    Strategy not working properly

    HI and Thank you in advance for your help

    Using the SampleATMStrategy as the base

    I am trying to get this Strategy to work but there is a small issue that i just cant see

    I want that after the bar is complete a BUY order is triggered 2 Ticks above the high of the bar and a Sell order 2 Ticks below the bar

    This seem to just trigger both immediatly at the current price

    It must be simple but i just cant see it

    // Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
    // **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
    if (orderIdS.Length == 0 && atmStrategyIdS.Length == 0 )

    {
    atmStrategyIdS = GetAtmStrategyUniqueId();
    orderIdS = GetAtmStrategyUniqueId();
    AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Limit, Low[
    0] + 2 * TickSize, 0, TimeInForce.Day, orderIdS, "TF3", atmStrategyIdS);
    }
    if (orderIdB.Length == 0 && atmStrategyIdB.Length == 0 )

    {
    atmStrategyIdB = GetAtmStrategyUniqueId();
    orderIdB = GetAtmStrategyUniqueId();
    AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, High[
    0] + 2 * TickSize, 0, TimeInForce.Day, orderIdB, "TF3", atmStrategyIdB);
    }



    #2
    Hi richbois,

    For this scenario you'll want to use stop orders instead of limit orders. A buy limit order above the last traded price is marketable and will be filled at current market prices.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I tried that but then nothing gets triggered

      // Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
      // **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
      if (orderIdS.Length == 0 && atmStrategyIdS.Length == 0 )

      {
      atmStrategyIdS = GetAtmStrategyUniqueId();
      orderIdS = GetAtmStrategyUniqueId();
      AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Stop, Low[
      0] + 2 * TickSize, 0, TimeInForce.Day, orderIdS, "TF3", atmStrategyIdS);
      }
      if (orderIdB.Length == 0 && atmStrategyIdB.Length == 0 )

      {
      atmStrategyIdB = GetAtmStrategyUniqueId();
      orderIdB = GetAtmStrategyUniqueId();
      AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Stop, High[
      0] + 2 * TickSize, 0, TimeInForce.Day, orderIdB, "TF3", atmStrategyIdB);
      }

      Comment


        #4
        Originally posted by richbois View Post
        This seem to just trigger both immediatly at the current price
        Using stop orders instead of limit orders solves the item you first posted here. If the signal is not triggering as you expect, I suggest simplifying to one direction at a time before adding the additional structure for both long and short.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          thank you for your prompt responses but that was the way I started and was not getting results either.

          using only the SampleAtmStrategy and only changing these few lines i dont get any trigger

          if (orderId.Length == 0 && atmStrategyId.Length == 0 )
          {
          atmStrategyId = GetAtmStrategyUniqueId();
          orderId = GetAtmStrategyUniqueId();
          AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Stop, High[
          0]+ 2 * TickSize, 0, TimeInForce.Day, orderId, "TF3", atmStrategyId);
          }

          Comment


            #6
            Your stop price is currently 0. Try switching these two fields like example below:
            Code:
            AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Stop, [COLOR="Blue"]0, High[0]+ 2 * TickSize[/COLOR], TimeInForce.Day, orderId, "TF3", atmStrategyId);
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              I knew it was simple but I needed a Genius to figure it out

              Thank you very much and have a great weekend

              Comment


                #8
                one more question

                this is the code i have and it works fine except for the order cancel section at the bottom

                the strategy will not compile with that CancelOrder line

                can you tell me what is wrong with it

                Thank you in advance
                Attached Files
                Last edited by richbois; 07-19-2012, 08:36 AM.

                Comment


                  #9
                  Hello,

                  This CancelOrder is meant for unmanaged approach and takes in a parameter of iOrder. Here you are passing in a string.

                  You appear to be using ATMStrategies however so you need to actually use a whole different command that does take in your string ID.



                  or



                  To close out the entire trade.

                  -Brett

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Javierw.ok  
                  Started by timmbbo, Today, 08:59 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post bltdavid  
                  Started by alifarahani, Today, 09:40 AM
                  6 responses
                  41 views
                  0 likes
                  Last Post alifarahani  
                  Working...
                  X