Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multiple profit targets in custom coded strategy?

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

    multiple profit targets in custom coded strategy?

    My strategy is custom coded (didn't use strat builder).

    I currently have working auto-breakeven and trailing stop.

    However, I cannot seem to get multiple profit targets working.

    Let's say I have a position with 4 contracts and I want to add a profit target to close 1. Do I use ExitLongLimit?

    EDIT: I guess I cannot because I'm currently using Managed Approach. So I need to switch to Unmanaged. Does anyone have an example code using unmanaged approach, with multiple profit targets (exiting 1 contract for each target for example)
    Last edited by iantriestrading; 08-21-2024, 03:23 PM.

    #2
    Hello iantriestrading,

    In the managed approach you would need to submit separate entries with different signal names, by doing that you could have multiple sets of targets, one for each signal name.

    Comment


      #3
      Hi Jesse,

      Is it instead possible for my strategy to continue using Managed Approach, but set up simulated profit targets, and when price reaches a profit target on a long for example, it would use ExitLong() to exit just 1 contract out of a 4 contract position?

      Comment


        #4
        Hello iantriestrading,

        Yes you can do that if that works for what you wanted to do. You would just make price conditions instead of submitting a target and then submit a market exit when the condition becomes true. While that is a valid approach if you are trading a fast moving market that could result is substantial losses if the market moves out of favor quickly due to a market order being used.

        Comment


          #5
          I wish I had more to add, this is my management of multiple positions, but it does require the entries per direction to account for the 2 positions. I have run several replays and they don't add new positions if the entry count isn't maxed..... can you share the methods for your auto breakeven and trails? I can't get them to work for the life of me. Basically, I believe, it sees the initial stop loss and therefore won't set the new break even.

          Code:
          if (isLong)
          {
              if (useSecondContract)
              {
                  // Enter first contract with target 1
                  EnterLong(1, "Entry1");
                  SetStopLoss("Entry1", CalculationMode.Ticks, StopLossTicks, false);
                  SetProfitTarget("Entry1", CalculationMode.Ticks, ProfitTarget1Ticks, false);
          
                  // Enter second contract with target 2
                  EnterLong(1, "Entry2");
                  SetStopLoss("Entry2", CalculationMode.Ticks, StopLossTicks, false);
                  SetProfitTarget("Entry2", CalculationMode.Ticks, ProfitTarget2Ticks, false);
              }
              else
              {
                  EnterLong(1, "Entry");
                  SetStopLoss("Entry", CalculationMode.Ticks, StopLossTicks, false);
                  SetProfitTarget("Entry", CalculationMode.Ticks, ProfitTarget1Ticks, false);
              }
          }
          else
          {
              if (useSecondContract) 
              {
                  // Enter first contract with target 1
                  EnterShort(1, "Entry1");
                  SetStopLoss("Entry1", CalculationMode.Ticks, StopLossTicks, false);
                  SetProfitTarget("Entry1", CalculationMode.Ticks, ProfitTarget1Ticks, false);
          
                  // Enter second contract with target 2
                  EnterShort(1, "Entry2");
                  SetStopLoss("Entry2", CalculationMode.Ticks, StopLossTicks, false);
                  SetProfitTarget("Entry2", CalculationMode.Ticks, ProfitTarget2Ticks, false);
              }
              else
              {
                  EnterShort(1, "Entry");
                  SetStopLoss("Entry", CalculationMode.Ticks, StopLossTicks, false);
                  SetProfitTarget("Entry", CalculationMode.Ticks, ProfitTarget1Ticks, false);
              }
          }
          }​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          39 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X