Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get "SignalName no matching FromEntrySignal" on 2nd trade

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

    Get "SignalName no matching FromEntrySignal" on 2nd trade

    I have a strategy where I create 3 profit targets and a stop loss. After entry of the trade, the Exit orders are created and are repeated on the first tick of each new bar (calculation is onPriceChange).

    I have ExitLongStopMarket and ExitLongLimit and for each the signal is @"MES_Stop1", Stop2, and so on. For Profit Targets, they are @"MES_Profit1", Profit2, and so on... The Entry signal name is "MES_Long1", Long2, Long3, Short1, 2, and 3... hopefully you get the point.

    When I run the strategy, it will work as expected on the first trade in either direction, long or short. However, when it triggers a 2nd time in either direction, in the output, I get Ignored with a reason of 'SignalName does not have a matching FromEntrySignal to exit'. I can't quite make sense of this. Of course this works great in playback mode, but has only surfaced when trading live on a sim account. Also, when looking at the logs, there are no errors and it says the orders were accepted and filled, leaving me more confused.

    I'd also be very interested in ways to use ATM strategies instead of trying to manage the entries and exits myself, but I'm not sure ATM strategies would work with what I'm trying to accomplish. What I have attempted to program is for dynamic stops, profits, breakeven targets, and trail stops. I know ATM can do trails by ticks, but I'm looking to dynamically set that based on risk and other factors. My limited understanding is that isn't possible, however I hope to be wrong about that as that probably makes things both much simpler and safer than programming something on my own.

    Below are the lines from the output window:

    Shows the original entry.

    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=4 LimitPrice=0 StopPrice=0 SignalName='MES_Short1' FromEntrySignal=''
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=4 LimitPrice=0 StopPrice=0 SignalName='MES_Short2' FromEntrySignal=''
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=2 LimitPrice=0 StopPrice=0 SignalName='MES_Short3' FromEntrySignal=''

    Shows the Stop1 and Profit1 for Short1 are created, before Short2 and Short3 are ignored. ON the chart, I get the orders for 4 of the 10 contracts, leaving 6 active with no exit orders created.

    Placing stop and targets short1: firstTick = False, secondTick = True, p1Contracts = 4, p2Contracts = 4, p3Contracts = 2
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=4 LimitPrice=0 StopPrice=6022.75 SignalName='MES_Stop1' FromEntrySignal='MES_Short1'
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=Limit Quantity=4 LimitPrice=6018.25 StopPrice=0 SignalName='MES_Profit1' FromEntrySignal='MES_Short1'

    Placing stop and targets short2: firstTick = False, secondTick = True, p1Contracts = 4, p2Contracts = 4, p3Contracts = 2
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=4 LimitPrice=0 StopPrice=6022.75 SignalName='MES_Stop2' FromEntrySignal='MES_Short2'
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Ignored SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=4 LimitPrice=0 StopPrice=6022.75 SignalName='MES_Stop2' FromEntrySignal='MES_Short2' Reason='SignalName does not have a matching FromEntrySignal to exit'
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=Limit Quantity=4 LimitPrice=6013.25 StopPrice=0 SignalName='MES_Profit2' FromEntrySignal='MES_Short2'
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Ignored SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=Limit Quantity=4 LimitPrice=6013.25 StopPrice=0 SignalName='MES_Profit2' FromEntrySignal='MES_Short2' Reason='SignalName does not have a matching FromEntrySignal to exit'

    Placing stop and targets short3: firstTick = False, secondTick = True, p1Contracts = 4, p2Contracts = 4, p3Contracts = 2
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=2 LimitPrice=0 StopPrice=6022.75 SignalName='MES_Stop3' FromEntrySignal='MES_Short3'
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Ignored SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=StopMarket Quantity=2 LimitPrice=0 StopPrice=6022.75 SignalName='MES_Stop3' FromEntrySignal='MES_Short3' Reason='SignalName does not have a matching FromEntrySignal to exit'
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Entered internal SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=Limit Quantity=2 LimitPrice=6009.25 StopPrice=0 SignalName='MES_Profit3' FromEntrySignal='MES_Short3'
    1/27/2025 3:15:59 PM Strategy 'SHStrategyReversalBarMES/347506803': Ignored SubmitOrderManaged() method at 1/27/2025 3:15:59 PM: BarsInProgress=0 Action=BuyToCover OrderType=Limit Quantity=2 LimitPrice=6009.25 StopPrice=0 SignalName='MES_Profit3' FromEntrySignal='MES_Short3' Reason='SignalName does not have a matching FromEntrySignal to exit'
    Setting profit and stop orders Short -- 15:16:00

    Thanks in advance!!
    Scott​​

    #2
    Hello shunsinger22,

    Are you certain that you have the correct string for the from entry signal in the second set of targets?

    Comment


      #3
      I'm pretty sure, yes. I'll post below to be more clear, but I'd expect that if they were not correct, that it wouldn't work on the first trade. Again, the first trade executes the stop and profit targets perfectly, it doesn't fail until the 2nd trade for some reason.

      entries: Just showing for short since my example is a failure on short

      EnterShort((int)p1Contracts, @"MES_Short1");

      if (p2Contracts > 0)
      {
      EnterShort((int)p2Contracts, @"MES_Short2");

      if (p3Contracts > 0)
      {
      EnterShort((int)p3Contracts, @"MES_Short3");
      }
      }

      InTrade = true;​

      Then here is the code to set the stops and profits:

      if ((Position.MarketPosition == MarketPosition.Short)
      && ((IsFirstTickOfBar)
      || (InTrade == true))
      && (GetCurrentAsk(0) < ShortStop)
      && (GetCurrentBid(0) < ShortStop))
      {

      ExitShortStopMarket((int)p1Contracts, StandardTrailingStopStarted ? newStandardTrailStopPrice : stopLossResetToBreakEven ? BreakevenPrice : ShortStop, @"MES_Stop1", @"MES_Short1");

      ExitShortLimit((int)p1Contracts, profitTargetPrice1, @"MES_Profit1", @"MES_Short1");

      if (p2Contracts > 0)
      {
      ExitShortStopMarket((int)p2Contracts, StandardTrailingStopStarted ? newStandardTrailStopPrice : stopLossResetToBreakEven ? BreakevenPrice : ShortStop, @"MES_Stop2", @"MES_Short2");

      ExitShortLimit((int)p2Contracts, profitTargetPrice2, @"MES_Profit2", @"MES_Short2");

      if (p3Contracts > 0)
      {
      ExitShortStopMarket((int)p3Contracts, StandardTrailingStopStarted ? newStandardTrailStopPrice : stopLossResetToBreakEven ? BreakevenPrice : ShortStop, @"MES_Stop3", @"MES_Short3");

      ExitShortLimit((int)p3Contracts, profitTargetPrice3, @"MES_Profit3", @"MES_Short3");
      }
      }​

      Comment


        #4
        I think what is happening is that the stop and profit orders are happening prior to the original entry getting accepted and filled. That seems to make the most sense, but I'm struggling with the proper way to manage that.

        I did another test and at first it did the same thing where it didn't find the signal name for short2 or short3, but did for short1, however at the start of the next candle, that code ran again and it did create the stop and profit orders for shorts 2 and 3.

        Comment


          #5
          Is there a way to query to see if a signal name exists? If so, I could build logic around that to verify the entry was filled before executing the stop and profit orders.

          Comment


            #6
            Hello shunsinger22,

            It sounds like you found the problem, if you call the exit order at the same time as the entry it's not going to be able to find it because that entry has not been submitted or filled yet, you have to wait until you are actually in that position before trying to submit the exit order.

            Comment


              #7
              Thanks Jesse for confirmation.

              For anyone else who may run into this, I'll share what I am attempting to do to resolve it. I'll first say that I'm a novice and always learning, so there are likely much better approaches to this than I can come up with. But none the less, this was the approach I've taken and will continue to test and monitor.

              I'm using OnOrderUpdate to assign orders to variables I've created for each order to start. This is probably not necessary but was in an example I found and I believe it allows for more granular checking of the order if needed later, which I'm not doing.

              example;
              private Order entryOrderShort1 = null;

              if (order.Name == "MES_Short1")
              {
              entryOrderShort1 = order;
              Print($"DEBUG: MES_Short1 updated. State: {order.OrderState}, Filled: {order.Filled}");
              }

              Then I'm looking for when the order is filled, then setting a bool to true. That bool is then used to allow the OnBarUpdate stop and profit orders to process.

              private bool filledShort1 = false;

              if (entryOrderShort1 != null && entryOrderShort1 == order)
              {
              if (order.OrderState == OrderState.Filled)
              {
              filledShort1 = true;
              }
              }

              Then once the position is flat and before looking for the next trade signal, I reset the variables to null and false.

              ​Hopefully that's an acceptable approach, if not, I suppose I'll find out. If there are obvious flaws with this approach, I'd appreciate the heads up

              Thanks again.​

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              58 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              133 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X