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

'AtmStrategyChangeStopTarget' method error: Order name 'STOP1' is invalid

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

    'AtmStrategyChangeStopTarget' method error: Order name 'STOP1' is invalid

    Hello.
    I made my first ATM strategy.

    This line:
    PHP Code:
    AtmStrategyChangeStopTarget(0Stop_Loss_Price"STOP1"Atm_Strategy_Id); 
    caused this error message in OutputWindow:
    'AtmStrategyChangeStopTarget' method error: Order name 'STOP1' is invalid

    Code was copied from SampleAtmStrategy.cs.
    Need help.
    Thank You.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic,

    Thank you for your note.

    If you replace, "STOP1" with fx.practic "Stop1", do you no longer receive the error?



    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      It's work.
      Will it work same way on other systems if I will share strategy to some other peoples?
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment


        #4
        Hello fx.practic,

        If the strategy runs correctly on your machine it should run correctly on any other machine, assuming all else being equal.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Can I change StopLoss and Target price in AtmStrategyCreate call back function, like this:

          PHP Code:
                                  AtmStrategyCreate(OrderAction.BuyOrderType.Market0Sit_Long.Order_Price_ActualTimeInForce.DaySit_Long.Atm_Order_IdC.Atm_Slected_NameSit_Long.Atm_Strategy_Id, (atmCallbackErrorCodeatmCallBackId) => 
                                  { 
                                      
          //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 == Sit_Long.Atm_Strategy_Id)
                                      {                                
                                          
          Sit_Long.Atm_Is_Created true;
                                          
          Sit_Long.Atm_Error_Code atmCallbackErrorCode;
                                          
          //Print( Sit_Long.Atm_Error_Code );
                                                                      
                                          
          double sl_price GetCurrentBid() -TickSize;
                                          for( 
          int i 0<= 2i++ ) if( sl_price Low[i] ) sl_price Low[i];
                                          Print( 
          Time[0] +" ; "+   GetCurrentBid() +" ; "sl_price );
                                  
                                          
          AtmStrategyChangeStopTarget(0sl_price"Stop1"Sit_Long.Atm_Strategy_Id  );
                                      }
                                  }); 


          This code giver error on both names: "STOP1" and "Stop1" (please, look at screenshot in attachment)
          Attached Files
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment


            #6
            Hello fx.practic,

            It may be that you are attempting to call the order before it is in a working state.

            May I confirm the entry order has filled before this line is called?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I try to change stop ASAP after strategy successfully created.
              I want strategy to work with Calculate.OnBarClose() - and wait for next bar to change stop is dangerous.

              As for I understand, I have 2 ways:
              1) to use Calculate.OnEachTick() (and to change stop on next tick after order filled
              2) to use usual orders (SetStopLoss(), EnterLong())

              Is it right?
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment


                #8
                Hello fx.practic,

                That would not be possible.

                When the entry order is created, it hasn't filled yet and the stop loss and profit targets will not yet have been submitted.

                You will need to wait until these orders exist to modify them.

                If the initial settings are incorrect, you may need to create a new Atm Strategy template.


                Yes, you can wait for the next tick and then check that the entry has filled and then check the state of those orders to be working and then modify them if you would like.

                Or yes, you can choose to not use Atm Strategy methods and instead use methods internal to NinjaScript Strategies.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by f.saeidi, Today, 08:03 AM
                0 responses
                3 views
                0 likes
                Last Post f.saeidi  
                Started by cre8able, 04-17-2024, 04:16 PM
                7 responses
                63 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by Aviram Y, 08-09-2023, 09:04 AM
                11 responses
                299 views
                0 likes
                Last Post arjandezeeuw  
                Started by Christopher Leggit, 02-15-2024, 09:00 AM
                3 responses
                47 views
                0 likes
                Last Post rdtdale
                by rdtdale
                 
                Started by DavidHP, Today, 07:56 AM
                0 responses
                3 views
                0 likes
                Last Post DavidHP
                by DavidHP
                 
                Working...
                X