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 NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            55 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            132 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X