Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLong vs ExitLongStop in OnExecution()

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

    ExitLong vs ExitLongStop in OnExecution()

    Hi,

    I have a number of stop types in operation some use ExitLongStop, some use ExitLong. I have a section of code in OnExecution that prints to screen when a stop is actioned, however it only reports back for the ExitLongStop and not for the ExitLong.

    Here are two examples that would appear in OnBarUpdate:

    Code:
    stopOrder = ExitLongStop(0, true, 1, stopPrice, "MyLongTrailingHighOrLowStop", "MyLongEntry");
    
    stopOrder = ExitShort("MyShortTicksStop", "MyShortEntry");
    Then within OnExecution I filter on exits using the following and within this if loop I print to screen:

    Code:
    if (stopOrder != null && stopOrder == execution.Order)
    Using this I only ever get print to screen working for the ExitLongStop even though both stops would be actioned and the Strategy Analyzer results show this accurately.

    However if I refer to the execution exit by name then I can get results for the ExitShort. That is if my if loop looked like:

    Code:
    if("MyShortTicksStop" == execution.Name)
    Why doesn't the reference to stopOrder work for ExitShort while it does for ExitLongStop? It would be preferable to not have to refer to each exit type by name.

    Thanks in advance,
    darmbk.

    #2
    Hello darmbk,

    Thank you for your post.

    Do you see the same behavior when calling the IOrder object for the ExitShort() only? You can do this by commenting out the ExitLongStop() or by setting specific IOrder object names for each exit.

    In addition, are you setting the IOrder object to null when the order is filled? Are you going both long and short in the strategy?

    Comment


      #3
      Apologies Patrick,

      I can no longer replicate the error. My stops are all reporting correctly now.

      Thanks,
      darmbk.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      56 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      143 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X