Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATM Strategy access old data

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

    ATM Strategy access old data

    Hello,
    I'm trying to make an ATM Strategy that is destined to be used in the SuperDom.
    So basically the profit target is calculated on the close price of the previous bar but I don't find how to access these data, with normal strategy I was using Close[1].

    Do you have any hint ?
    Thank you

    #2
    Hello Djazairi,

    Thank you for your post.

    When using an ATM strategy template within a NinjaScript Strategy, the stops and targets would be set by the template settings. However, it is possible to move the stop and/or target once they are placed using the initial ATM template.

    You can use ATMStrategyChangeStopTarget() to accomplish this:



    An example of this may be found in the built in Sample ATM Strategy that you can look at in the NinjaScript Editor:

    Code:
     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, please note you access the ATM strategy specific position object here
    // the ATM would run self contained and would not have an impact on your NinjaScript strategy position and PnL
    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)) ;
    }
    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Thank you for your answer Kate, but I don't want to change constantly, what I want is when I place an order in the superDom selecting my ATM template the TP and SL will be set once but calculated with the close price of previous bar, so for example Close[1] + 15 ticks and the 15 would be a value set manually by user (me)

      Originally posted by NinjaTrader_Kate View Post
      Hello Djazairi,

      Thank you for your post.

      When using an ATM strategy template within a NinjaScript Strategy, the stops and targets would be set by the template settings. However, it is possible to move the stop and/or target once they are placed using the initial ATM template.

      You can use ATMStrategyChangeStopTarget() to accomplish this:



      An example of this may be found in the built in Sample ATM Strategy that you can look at in the NinjaScript Editor:

      Code:
       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, please note you access the ATM strategy specific position object here
      // the ATM would run self contained and would not have an impact on your NinjaScript strategy position and PnL
      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)) ;
      }
      Please let us know if we may be of further assistance to you.

      Comment


        #4
        Hello Djazairi,

        Thank you for your reply.

        There would not be a way to accomplish that as the values you want cannot be set in the ATM template itself. You'd have to use ATMStrategyChangeStopTarget, or you could recreate ATM like behavior within a NinjaScript strategy using stop and target orders, but it would not be possible to do what you're wanting without using one of those workarounds.

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Ok thank you but using a strategy like you said I won't be able to change TP/SL only 1 time ? I just want them to be set according to price of previous bar when I place the order but then they don't change in the time
          It would mean that I will need to create an instance of the strategy for each of the instruments I want to trade ? What if I disable the strategy will it close my orders ?

          Originally posted by NinjaTrader_Kate View Post
          Hello Djazairi,

          Thank you for your reply.

          There would not be a way to accomplish that as the values you want cannot be set in the ATM template itself. You'd have to use ATMStrategyChangeStopTarget, or you could recreate ATM like behavior within a NinjaScript strategy using stop and target orders, but it would not be possible to do what you're wanting without using one of those workarounds.

          Please let us know if we may be of further assistance to you.

          Comment


            #6
            Hello Djazairi,

            Thank you for your reply.

            You could certainly use a bool to only modify the stop loss once - Check the bool before modifying the Stop/Target, then flip it when the stop is moved. Then when the position is exited, flip the bool back.

            Disabling the strategy will have different effects depending on the settings you have in Tools > Options > Strategy. You can opt to have exit orders and entry orders automatically cancel when the strategy is disabled or not to have those cancelled. Disabling the strategy will not automatically close any open positions - you would need to close any open position left by the strategy manually.

            Please let us know if we may be of further assistance to you.

            Comment


              #7
              Hello Thank you, but it would mean that I will need to create an instance of the strategy for each of the instruments I want to trade ?

              Comment


                #8
                Hello Djazairi,

                Thank you for your reply.

                With single instrument strategies you'd have to apply a different instance of the strategy to each chart you wish to trade (or to each instrument you wish to trade) in the Control Center. You can certainly create multi-instrument strategies that can submit orders to multiple instruments from a single strategy that you could apply to a single primary instrument and have it trade on your coded in secondary instruments as well, though this may become complex depending on the logic desired.



                If you're wanting different settings for things in different instances of the strategy, it may be simpler to just make anything you want to change between instruments a User Input and make templates for the instruments you're trading.

                Please let us know if we may be of further assistance to you.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                62 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                134 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                75 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
                50 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X