Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AtmStrategyCreate()

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

    AtmStrategyCreate()

    In a strategy that did not link to the ATM I used;

    Code:
     
    tsLabel.Text ="Pending Buy @ " + order.StopPrice.ToString();

    I would like to do the same thing in a strategy that does link to the ATM, with the stopPrice data from AtmStrategyCreate().

    How do I reference the stopPrice data?

    #2
    Hi TMFT,

    There is a method call for that:


    string[,] orders = GetAtmStrategyStopTargetOrderStatus("TARGET1", "idValue");

    // Check length to ensure that returned array holds order information
    if (orders.Length > 0)
    {
    for (int i = 0; i < orders.GetLength(0); i++)
    {
    Print("Average fill price is " + orders[i, 0].ToString());
    Print("Filled amount is " + orders[i, 1].ToString());
    Print("Current state is " + orders[i, 2].ToString());
    }
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hi TMFT,

      There is a method call for that:


      string[,] orders = GetAtmStrategyStopTargetOrderStatus("TARGET1", "idValue");

      // Check length to ensure that returned array holds order information
      if (orders.Length > 0)
      {
      for (int i = 0; i < orders.GetLength(0); i++)
      {
      Print("Average fill price is " + orders[i, 0].ToString());
      Print("Filled amount is " + orders[i, 1].ToString());
      Print("Current state is " + orders[i, 2].ToString());
      }
      }
      Thanks for the fast reply. I read that and thought it was referring to the StopLoss/ProfitTarget. prices.

      I am trying to reference the stopPrice (see attached). Will the above method reference the stopPrice that is in AtmStrategyCreate() ?

      Click image for larger version

Name:	stopPrice.png
Views:	1
Size:	40.4 KB
ID:	861357

      Comment


        #4
        If it's the entry order details you're trying to access, the sample AtmStrategy offers technique for this.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_RyanM View Post
          If it's the entry order details you're trying to access, the sample AtmStrategy offers technique for this.
          Noooo....

          It shows how to access the filled price ,the average price, and it shows you how to create an order with AtmStrategyCreate()..... but nowhere that I can find does it reference how to access the stopPrice used in AtmStrategyCreate().

          Can you show me where that code is?

          Code:
           
          // 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 (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
          {
          atmStrategyId = GetAtmStrategyUniqueId();
          orderId = GetAtmStrategyUniqueId();
          AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
          }
           
          // Check for a pending entry order
          if (orderId.Length > 0)
          {
          string[] status = GetAtmStrategyEntryOrderStatus(orderId);
           
          // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
          if (status.GetLength(0) > 0)
          {
          // Print out some information about the order to the output window
          Print("The entry order average fill price is: " + status[0]);
          Print("The entry order filled amount is: " + status[1]);
          Print("The entry order order state is: " + status[2]);
          // If the order state is terminal, reset the order id value
          if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
          orderId = string.Empty;
          }
          } // If the strategy has terminated reset the strategy id
          else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
          atmStrategyId = string.Empty;
           
          if (atmStrategyId.Length > 0)
          {
          // You can change the stop price
          if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
          AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);
          // Print some information about the strategy to the output window
          Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
          Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
          Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId));
          Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
          }
          }

          Comment


            #6
            You set the order price when you create the ATM strategy. After it is placed there is not a way to read it programatically until filled.

            AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_RyanM View Post
              ...... After it is placed there is not a way to read it programatically until filled.

              AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
              That's what I suspected from working with it.

              But on the bright side, I was able to get everything else working the way I wanted it.

              Thanks for an honest reply.

              Regards,
              TMFT

              Comment


                #8
                Hello..can you help me..this is my first time on here )
                I have an autotrader active and working on my live Ninja Sim account.
                How do I activate it on my live funded account.
                I do have an active Ninja license key
                Thanks...Burt
                [email protected]

                Comment


                  #9
                  Hi Burtm1,

                  First, make sure that global sim mode is unchecked from File menu.

                  You can run live NinjaTrader strategies from the control center or the chart. When running the strategy you can select a specific account. This link can help with running strategies in NinjaTrader:
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    FOR EXAMPLE THIS ORDER SETTING
                    Code:
                    EnterLongStopMarket(Convert.ToInt32(Quantity), (MAX2[0] + (1 * TickSize)) , @"B")
                    HOW CAN ADD IT TO THE SAMPLE ATM STRATEGY CODE ? SHOULD I REMPLACE LOW[0] by (MAX2[0] + (1 * TickSize)) ?

                    Comment


                      #11
                      Hello marioac19,

                      Thanks for your notes.

                      I see you have asked this question on a different forum thread that you created and I have replied with an answer to that forum thread.

                      Please see the answer on the other forum thread you created regarding this inquiry.

                      Hello, I am currently seeking to create a condition using strategy builder , that involves two consecutive bearish bars, followed by a green candle . My objective is to place a buy limit order at the highest point of the previous two bearish bars once the condition is true and waiting what will happened , so if the 4th bars
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #12
                        hello again ,
                        now all is going fine , but some time happend that i get this error message when my strategy try to put a trailing stop order to keep some profit from market at the time that the price move or change fast so it can not catch it , and the error message it get is :
                        Sell stop or sell stop limit orders can’t be placed above the market. Strategy submitted an order that generated the following error - order rejected. Strategy has sent cancel requests, attempted to close the position and terminated itself
                        an also this error message
                        sell stop or sell limit can't be placed aboe the market affected order : sell 1 stopmarket@15322
                        . and the strategy desactivited from the chart .

                        i know that we can solve this using the RealtimeErrorHandling but the problem as you know before , i am using a personal script in witch i was add the ATMStrategy ( subject of my previous question ) so will it be helpful to use RealtimeErrorHandling in this case too to keep the strategy active on chart and also allow tit to put an alternative trailing stop ( less then the fiirst one by 2 ticks or however , the important is to activate the trailing stop) ?

                        Comment


                          #13
                          Hello mariorac19,

                          This could mean the template supplied to the AtmStrategyCreate() call has trailing setting that are too tight and the order is too close to the market action and ending up on the wrong side of the market.

                          Try using a greater distance for the 'Stop loss' column in the Stop Strategy of the Atm template.

                          That said, it would be unexpected that an order submitted with AtmStrategyCreate() would disable a NinjaScript Strategy. Are you certain you have not clicked the Close button in Chart Trader?
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hi , i am sure that i did not click on close button in chart .
                            BY the way is the RealtimeErrorHandling () can solve this ?

                            Comment


                              #15
                              Hello mariorac19,

                              Are you certain there are no native strategy order methods called like EnterLong(), SetStopLoss(), etc?

                              Setting RealtimeErrorHandling to RealtimeErrorHandling.TakeNoAction should prevent the strategy from being disabled.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by yertle, Yesterday, 08:38 AM
                              7 responses
                              28 views
                              0 likes
                              Last Post yertle
                              by yertle
                               
                              Started by bmartz, 03-12-2024, 06:12 AM
                              2 responses
                              21 views
                              0 likes
                              Last Post bmartz
                              by bmartz
                               
                              Started by funk10101, Today, 12:02 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post funk10101  
                              Started by gravdigaz6, Yesterday, 11:40 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by MarianApalaghiei, Yesterday, 10:49 PM
                              3 responses
                              11 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X