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 Waxavi, 04-19-2024, 02:10 AM
        2 responses
        37 views
        0 likes
        Last Post poeds
        by poeds
         
        Started by chbruno, Yesterday, 04:10 PM
        1 response
        44 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Max238, Today, 01:28 AM
        1 response
        24 views
        0 likes
        Last Post CactusMan  
        Started by giulyko00, Yesterday, 12:03 PM
        2 responses
        10 views
        0 likes
        Last Post giulyko00  
        Started by r68cervera, Today, 05:29 AM
        0 responses
        4 views
        0 likes
        Last Post r68cervera  
        Working...
        X