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

stopOrder.StopPrice

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

    stopOrder.StopPrice

    I am trying to pickup the value of StopPrice

    Apparently I am not using stopOrder.StopPrice properly...i.e. you can use it like this

    if (stopOrder != null && stopOrder.StopPrice > Position.AvgPrice)

    however can not use it in a print statement nor assign its value to a variable

    is it possible to access this value...if not now, NT7?

    ideally, I want to be able to plot the value of the trailing stop from SetTrailStop

    since the value can be used in logic/if statements and it is printed in the Log, why is it not available from code

    thanks.

    #2
    Originally posted by ATI user View Post
    I am trying to pickup the value of StopPrice

    Apparently I am not using stopOrder.StopPrice properly...i.e. you can use it like this

    if (stopOrder != null && stopOrder.StopPrice > Position.AvgPrice)

    however can not use it in a print statement nor assign its value to a variable

    is it possible to access this value...if not now, NT7?

    ideally, I want to be able to plot the value of the trailing stop from SetTrailStop

    since the value can be used in logic/if statements and it is printed in the Log, why is it not available from code

    thanks.
    Have you checked out this reference sample? I am quite sure you can access the stop price...

    RayNinjaTrader Customer Service

    Comment


      #3
      yes...I had...and immediately forgot about it...tried another way which did not work (also does not work if you use AtmStrategyCreate code instead)

      thanks

      here is the code for others:


      protected override void OnOrderUpdate(IOrder order)
      {

      // Process stop loss orders
      if (stopLossTokens.Contains(order.Token))
      {
      // Check order for terminal state
      if (order.OrderState == OrderState.Cancelled || order.OrderState == OrderState.Filled || order.OrderState == OrderState.Rejected)
      {
      // Print out information about the order
      Print(order.ToString());

      // Remove from collection
      stopLossTokens.Remove(order.Token);
      }

      // Print out the current stop loss price
      else
      Print("The order name " + order.Name + " stop price is currently " + order.StopPrice);
      }

      Comment


        #4
        ATM generated orders will NOT trigger OnOrderUpdate() in a NinjaScript strategy.
        RayNinjaTrader Customer Service

        Comment


          #5
          right..thanks....

          that is one of the reasons I am switching away from ATM code

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          14 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          13 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,983 views
          3 likes
          Last Post jhudas88  
          Working...
          X