Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

use 2 orders for entry for ATM strategies.

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

    use 2 orders for entry for ATM strategies.

    i want to enter a market and a limit order for entry.
    can i do the following

    Code:
    AtmStrategyCreate(OrderAction.SellShort, OrderType.Market,0, 0, TimeInForce.Gtc, orderId1, "OPENING GAMBIT", atmStrategyId, (atmCallbackErrorCode, atmCallBackId) => {
    //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
    if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
    isAtmStrategyCreatedMarket = true;
    });
    
    AtmStrategyCreate(OrderAction.SellShort, OrderTypeLimit,Limitprice, 0, TimeInForce.Gtc, orderId2, "OPENING GAMBIT", atmStrategyId, (atmCallbackErrorCode, atmCallBackId) => {
    //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
    if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
    isAtmStrategyCreatedLimit = true;
    });
    would the exits be automatically adjusted basedon the template?

    #2
    Hi junkone, thanks for posting. This is OK to do. You can use different templates for each strategy if you wanted to do that. It looks like you have the same template for each order.

    Kind regards,
    -ChrisL

    Comment


      #3
      it does not like if i reuse the same strategy id

      orderids are different but i am reusing same strategy id

      2022-07-19 22:03:01:101|3|4|'AtmStrategyCreate method error: ATM strategy ID 'f29b68e6c0d84857a255769d8e743e65' already used


      Code:
       AtmStrategyCreate(Openingaction, OrderType.Market,0, 0, TimeInForce.Gtc, [B]orderId_Opening_Gambit_Market[/B], "OPENING GAMBIT", [B][I]atmStrategyId[/I][/B], (atmCallbackErrorCode, atmCallBackId) => {
      //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
      if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
      isAtmStrategyCreated = true;
      });
      // Check that atm strategy was created before checking other properties
      if (!isAtmStrategyCreated)
      return;
      
      AtmStrategyCreate(Openingaction, OrderType.Limit, openingLimitprice, 0, TimeInForce.Gtc, [B]orderId_Opening_Gambit_Limit[/B], "OPENING GAMBIT", [B][I]atmStrategyId[/I][/B], (atmCallbackErrorCode, atmCallBackId) => {
      //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
      if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
      isAtmStrategyCreated = true;
      });
      Attached Files

      Comment


        #4
        Hi junkone, You will need to call this code twice, basically duplicate this with its own variables Take this example from the SampleATMStrategy script, I just make more variables to accommodate the second entry:

        Code:
        private string atmStrategyId1 = string.Empty;
        private string orderId1 = string.Empty;
        private bool isAtmStrategyCreated1 = false;
        
        
        if (orderId1.Length == 0 && atmStrategyId1.Length == 0 && Close[0] > Open[0])
        {
         isAtmStrategyCreated1 = false; // reset atm strategy created check to false
         atmStrategyId1 = GetAtmStrategyUniqueId();
         orderId1 = GetAtmStrategyUniqueId();
         AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId1, "AtmStrategyTemplate", atmStrategyId1, (atmCallbackErrorCode,   atmCallBackId) => {
          //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
          if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId1)
          isAtmStrategyCreated1 = true;
         });
        }

        Comment


          #5
          ok. i kinda use similar idea. However is there a way for me to retrieve the stop price setup for the ATM strategy programmatically?

          Comment


            #6
            Hi junkone, the ATM templates must be defined before submitting them. The only way to access the values are to use a C# XML reader to read the files within Documents\NinjaTrader 8\templates\AtmStrategy.

            Kind regards.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            80 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            63 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            63 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X