Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

AtmStrategyCreate()

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

    #16
    Howie, you could not directly change the trigger and frequency variables as setup in the original template, however you could change the values of the working stop order, for example -

    Code:
    if (myCondition)
    				AtmStrategyChangeStopTarget(0, SMA(Low, 20)[0], "STOP1", "myAtm");    
    				AtmStrategyChangeStopTarget(0, SMA(Low, 40)[0], "STOP2", "myAtm");
    BertrandNinjaTrader Customer Service

    Comment


      #17
      Thank you for the snipet. To be sure I understand this would you say the method is the same as changing them on a chart? Meaning when the stops will be readjusted in accordance with the StopStraregy attached to the Launched ATMstrategy?

      Thanks a gain for the code sample
      Howie

      Comment


        #18
        You're welcome, the stopStrategy itself is still working from the template, this code would just adjust the value of the stop / target directly via code. If you all want to self code this and update with your custom algorithms, just don't setup AutoTrails / AutoBreakevens.
        BertrandNinjaTrader Customer Service

        Comment


          #19
          Bertrand,
          A Ninja Script terminates on reboot right? The ATM's stay alive.
          I'm afraid of the reboot 'cause I want to be in for the long trends.
          Howie

          Comment


            #20
            Ohowie,

            Yes, a reboot will terminate the strategy. A NinjaScript automated strategy will not persist through shutdown and restart of the platform.
            Ryan M.NinjaTrader Customer Service

            Comment


              #21
              Thank You Bertrand

              Could you direct me to a sample NinjaScript strategy that can pick-up where it left off when enabled after reboot? Is there a way to pick up that unique ID again after reboot?

              Thank again and again Bertrand
              Howie

              Comment


                #22
                ohowie,

                Strategies do not pick up from where they leave off. They are always recalculated. In NT7, strategies will recalculate and then try to map back and live orders to matching strategy orders, but this is not the same as picking up where you left off. If you shut down NT and start up again you are recalculating the strategy.
                Josh P.NinjaTrader Customer Service

                Comment


                  #23
                  Thank you Josh... would keeping a public variable (Prompted at enabling strategy) set to true or false (by me at enable) to identify if the position was entered yet.

                  for example:

                  I reboot knowing a position is open with a stopLoss and ProfitTarget.
                  I then set the position to true (already in position).
                  This way it does not enter a new position.
                  Can I modify somehow the existing StopLoss and ProfitTaget set before reboot?

                  Sorry to be a pest. This should be the final question.
                  THANK YOU JOSH

                  Comment


                    #24
                    In the example below the original stoploss and profittarget was set by a called ATM

                    if i wrote the uniqueatmstrategyID to disk and picked it up on re-enable would that work?
                    Last edited by ohowie; 05-21-2010, 06:22 PM. Reason: Text change

                    Comment


                      #25
                      Hello,

                      I am jumping in here, but I will try to help. No, if I understand, you cannot do what you are trying to do.

                      However, your system does see the values you input when you attach it each time. You just can't modify the orders from last time.

                      Additionally, ATM's are a set and forget order system. You can never access them after they are submitted.

                      The all above assumes you are using NT6.5.
                      DenNinjaTrader Customer Service

                      Comment


                        #26
                        AtmStrategyCreate()

                        Originally posted by NinjaTrader_Ben View Post
                        Hello,

                        I am jumping in here, but I will try to help. No, if I understand, you cannot do what you are trying to do.

                        However, your system does see the values you input when you attach it each time. You just can't modify the orders from last time.

                        Additionally, ATM's are a set and forget order system. You can never access them after they are submitted.

                        The all above assumes you are using NT6.5.
                        I'm using NT7. I thought there was a way to access open ATM Positions and change the Stop Order and Profit:
                        Target.AtmStrategyChangeStopTarget()

                        I would just need to obtain the unique ID in the event the strategy that created the ATM is disabled inadvertantly. Surely NT must keep or reasign a unique ATMstategyID when it is rebooted because it continues to function onscreen. Yes/No?

                        Thank you Ben
                        Last edited by ohowie; 05-22-2010, 02:01 PM. Reason: sample

                        Comment


                          #27
                          ohowie,

                          Unfortunately there is no "grab prior ATM strategy's ID" method. You would have had to store that ID when you first created the strategy otherwise it will be lost.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #28
                            Josh, I would write the unique ID to disk with the following code sample and then read it on reboot to obtain the uniqueID used to place the order before reboot. Yes/No/Maybe?

                            Thanks for trying Josh

                            privatevoid WriteFile(string line, string filename)
                            {
                            ///
                            try
                            {
                            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(file,true))
                            {
                            writer.WriteLine(line);
                            writer.Dispose();
                            }
                            }
                            catch (System.Exception exp)
                            {
                            Log(
                            "File write error for file name '" + "' Error '" + exp.Message + "'", LogLevel.Warning);
                            }
                            }


                            publicoverridevoid Dispose()
                            {
                            base.Dispose();
                            }

                            Comment


                              #29
                              ohowie,

                              Unfortunately I would not be able to comment on the validity of the code. You can give it a shot.
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #30
                                Josh,
                                The read and write file work great and recalls the uniqueID from disk but when I pass it as a string to any of the ATM Monitoring methods... no joy. I guess NT7 gets its own additional unique ID for the active ATMs on reboot. Thank you for your efforts.

                                Howie

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Kaledus, Today, 01:29 PM
                                1 response
                                6 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by frankthearm, Yesterday, 09:08 AM
                                13 responses
                                45 views
                                0 likes
                                Last Post frankthearm  
                                Started by PaulMohn, Today, 12:36 PM
                                2 responses
                                16 views
                                0 likes
                                Last Post PaulMohn  
                                Started by Conceptzx, 10-11-2022, 06:38 AM
                                2 responses
                                55 views
                                0 likes
                                Last Post PhillT
                                by PhillT
                                 
                                Started by yertle, Yesterday, 08:38 AM
                                8 responses
                                37 views
                                0 likes
                                Last Post ryjoga
                                by ryjoga
                                 
                                Working...
                                X