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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            89 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            135 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            119 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            69 views
            0 likes
            Last Post PaulMohn  
            Working...
            X