Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

exit handling

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

    exit handling

    Hi,
    I would like some help about the exit from a position.
    For example I have a script, the OnBarUpdate() consist of an EnterLong(), and next row a stoploss, with SetStopLoss(). In the next end of bar the OnBarUpdate() will be calling. In the case,when the price reached the stop loss price, how will be handling the exit. Where is the moment, when the position will be terminated? First run the whole OnBarUpdate() with all commands written by my own, and then will terminated the position, or the position will be terminated without running OnBarUpdate().
    May be that my problem will be more comprehensible if you see my job: I would like to print the cause of the terminating of the position. (The price reached the stop loss, or there was a forced terminating with ExitShort(), or ExitLong(), or the end of the day).
    Where can I found any kind of material about this issue?
    Best regard
    Akos

    #2
    Hello Akos,

    This can be told when the executions are submitted. The stop loss will be labeled "Stop loss" and the Exit() orders will be labeled "Exit"

    During a backtest when a bar is reached it will run OBU once, in this process any working orders will be checked for the next bar for a fill.

    If an Exit() order is submitted it will be processed immediately during that time, which could be filled before the StopLoss.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hello Cal
      Thank you for the fast response. Yes, I can see on the chart the labels, but I want to print in the output window the cause of terminating. So I think in the script I have to put Print("the cause of the terminating...") rows. But how can I discuss the causes? May be there is a property like the IOrder, which consist of this information?
      Best regard
      Akos

      Comment


        #4
        Akkiss,

        The cause would be the market price being hit for the Stop loss price, unless the Exit() order is submitted before the fill.

        If we are referring to a backtest, the same manner applies, if the price check for the Stop loss is hit it will close out the position, if the logic for the Exit() order is submitted before the Stop loss is filled then the position will be exited and the Stop loss will be cancelled.

        If you are wanting to know of the exit is happening first then you can add a print before, or after, the submission of the ExitLong() or ExitShort() order.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Hi Cal
          So a Print("terminated, because of ExitLong()") row will be put next to the ExitLong() row. But where is the right place of the Print("terminated , because reached the stoploss") row?

          Comment


            #6
            Hello Akos,

            Thank you for your response.

            Use IExecution in OnExecution() and check for the execution.Name == "Stop loss": http://www.ninjatrader.com/support/h...nexecution.htm

            Comment


              #7
              Hello Patrick
              Thank you for the answer, I thought something like this! So hard to understand this object, but it will be very useful
              Best regards
              Akos

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cre8able, Yesterday, 01:16 PM
              3 responses
              11 views
              0 likes
              Last Post cre8able  
              Started by ChartTourist, Today, 08:22 AM
              0 responses
              6 views
              0 likes
              Last Post ChartTourist  
              Started by LiamTwine, Today, 08:10 AM
              0 responses
              2 views
              0 likes
              Last Post LiamTwine  
              Started by Balage0922, Today, 07:38 AM
              0 responses
              5 views
              0 likes
              Last Post Balage0922  
              Started by JoMoon2024, Today, 06:56 AM
              0 responses
              6 views
              0 likes
              Last Post JoMoon2024  
              Working...
              X