Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

setstoploss handling

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

    setstoploss handling

    Hello,

    I cant find a solution or reply in the forum for working with setstoploss in a script-strategy in onExecution or onOrderupdate.

    I want to change the value of a variable if trade was stopped out with setstoploss.

    Thank you
    Tony

    #2
    Hello tonynt,

    Thank you for writing in.

    I would suggest taking a look at this particular reference sample on our support forum showing how you can reference SetStopLoss(): http://ninjatrader.com/support/forum...ead.php?t=5790

    You will see that in OnOrderUpdate() in the reference sample above, you'll want to check if the IOrder object's name is "Stop loss". This would be the same in OnExecution().

    In your particular example, you want to set a variable if the order is stopped out by your stop loss.

    So:

    Code:
    protected override void OnExecution(IExecution execution)
    {
         // when the stop loss is filled, set variable
         if (execution.Order != null && execution.Order.Name == "Stop loss" && execution.Order.OrderState == OrderState.Filled)
              // set variable
    }
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hello Zachary,

      thank you for your reply.

      But how to refer to a certain position "... from entry name..." or something like this?

      Thanks
      Tony

      Comment


        #4
        Hello tonynt,

        Please take a look at the various properties that can be accessed from an IOrder object: https://ninjatrader.com/support/help...t7/?iorder.htm

        You will want to use the FromEntrySignal property.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DayTradingDEMON, Today, 09:28 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        8 responses
        31 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by helpwanted, Today, 03:06 AM
        2 responses
        21 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by navyguy06, Today, 09:28 AM
        0 responses
        3 views
        0 likes
        Last Post navyguy06  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        77 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Working...
        X