• 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

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, 0, High[0]+ 2 * TickSize, 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, 07: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.

                  http://www.ninjatrader.com/support/h...entryorder.htm

                  or

                  http://www.ninjatrader.com/support/h...ategyclose.htm

                  To close out the entire trade.

                  -Brett
                  BrettNinjaTrader Product Management

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by vivekniwas, Today, 11:31 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_Heath  
                  Started by Austiner87, Yesterday, 04:59 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by rlcheny, Today, 10:38 AM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Tyler  
                  Started by JAtrades, Today, 05:38 AM
                  5 responses
                  24 views
                  0 likes
                  Last Post rlcheny
                  by rlcheny
                   
                  Started by RobotSyndicate, Today, 08:27 AM
                  1 response
                  13 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X