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 rhyminkevin, Today, 04:58 PM
          0 responses
          16 views
          0 likes
          Last Post rhyminkevin  
          Started by lightsun47, Today, 03:51 PM
          0 responses
          6 views
          0 likes
          Last Post lightsun47  
          Started by 00nevest, Today, 02:27 PM
          1 response
          14 views
          0 likes
          Last Post 00nevest  
          Started by futtrader, 04-21-2024, 01:50 AM
          4 responses
          49 views
          0 likes
          Last Post futtrader  
          Started by Option Whisperer, Today, 09:55 AM
          1 response
          15 views
          0 likes
          Last Post bltdavid  
          Working...
          X