Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Entries, Single Exit

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

    Multiple Entries, Single Exit

    Hi All,

    I've been customizing a strategy in strategy editor and have hit a wall. Currently its set up to enter and exit when certain indicator criteria is met. Super basic strategy.

    I'd like to be able to add a second buy if the existing position dips and exit all on the existing exit criteria.

    For example, strategy buys 1 contract, position dips 20 ticks, another buy, then all positions are closed at the same time. If the position does not dip, it would stick with 1 contract and exit.

    Any thoughts? Thanks in advance!

    #2
    Hello Deep_ITM_Puts, thanks for your post.

    You might need to set the position quantity as the quantity for exit orders e.g. in your exit action:


    This could be one solution, it depends on how exactly your strategy is written out. Please give this idea a test.

    Kind regards,
    -ChrisL

    Comment


      #3
      Thank you. I'm actually working with the code directly. I'm basically looking to keep everything the same except to buy 1 additional contract if open position decreases by X ticks. Any suggestions?

      protected override void OnBarUpdate()
      {
      // Exit if cross has occurred since entry, or SMAs are no longer in up trend.
      if (!TrailStop && Position.MarketPosition != MarketPosition.Flat
      && (CrossAbove(smaFast, smaSlow, 1) || CrossBelow(smaFast, smaSlow, 1))
      && (smaFast[0] < smaFast[1] || smaSlow[0] < smaSlow[1]))
      {
      ExitLong();
      }

      // Or exit with our trailing stop on the fast (50 period by default) SMA.
      else if (TrailStop && Position.MarketPosition != MarketPosition.Flat)
      {
      if (Close[0] > smaFast[0])
      ExitLongStopMarket(smaFast[0]);
      else
      ExitLong();
      }

      // Enter on smaFast crossing above smaSlow.
      if (CrossAbove(smaFast, smaSlow, 1)
      && Position.MarketPosition == MarketPosition.Flat)
      {
      if (!IncreasingVolume)
      EnterLong(); // No increasing volume factor.
      else if (IncreasingVolume && Volume[0] > Volume[1])
      EnterLong(); // Enter only if volume is increasing since prior bar.
      }
      }

      Comment


        #4
        Figured it out!! I've added this and it worked. Thanks!

        // Buy the dip
        if (Position.GetUnrealizedProfitLoss(PerformanceUnit. Ticks, Close[0]) == -200)
        {
        EnterLong(Convert.ToInt32(DefaultQuantity), "");
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        43 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        47 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X