Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Check if last closed trade reached SL or TP

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

    Check if last closed trade reached SL or TP

    Hi,
    How can i check if the last closed trade has been closed by SL or TP?.

    #2
    Hello,

    One way would be to use the OnExecution override to check which order had last filled.



    Based on which order was filled you could get its signal name, or FromEntrySignal name to determine which order was filled and which order this was a stop or target for.

    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse,

      how can access directly the last one closed order?. Or maybe i should look the last execution?. I am a bit confused.
      Last edited by vibarco; 08-17-2015, 05:06 AM.

      Comment


        #4
        Hello vibarco,

        Here is some example code that may help here:

        Code:
        		protected override void OnExecution(IExecution execution)
        		{
            		    if (execution.Name == "Stop loss")
                 	      Print(string.Format("{0} - Stop loss was filled", execution.Time));
        			
        		    if (execution.Name == "Profit target")
        		      Print(string.Format("{0} - Profit Target was filled", execution.Time));	
        		}
        In this example your output window would show something like:

        8/17/2015 5:55:00 AM - Profit Target was filled
        8/17/2015 7:00:00 AM - Stop loss was filled
        8/17/2015 7:27:00 AM - Stop loss was filled
        8/17/2015 7:53:00 AM - Profit Target was filled

        Comment


          #5
          Thank you Paul,

          I got it.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          68 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          63 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          62 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          53 views
          0 likes
          Last Post CarlTrading  
          Working...
          X