Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why are separate orders sharing the same stop and profit targets?

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

    Why are separate orders sharing the same stop and profit targets?

    Howdy y'all,

    I am trying to work out why my script applies a shared stop loss and profit target instead of having it uniquely applied to each order. Would love to have your insight.

    Example of the case I am trying to solve:

    Click image for larger version  Name:	image.png Views:	0 Size:	59.6 KB ID:	1258743

    In this example I set my profit target to be $250. LongEntry_170 gains $100 whereas LongEntry_171 gains $150. Combined this results in a gain of $250. However, my goal is for each trade to individually target $250.

    Here is a code snippet.

    Code:
    if (longEntryConditionsAreMet()) {
    
       longTradeCount++;
       string longEntryName = "LongEntry_" + longTradeCount;  // Unique name for each long entry order
    
       // Place long order with unique name
       EnterLong(longEntryName);
    
       // Set stop-loss and profit target for the trade
        SetStopLoss(longEntryName, CalculationMode.Currency, StopLoss, false);
        SetProfitTarget(longEntryName, CalculationMode.Currency, ProfitTarget);
    }
    I have also been playing with the following settings but they yield the same results.

    Entry Handling -> Unique
    Entry Handling -> All


    Thank you for taking the time to read my post. Looking forward to hearing some feedback.

    -Gustav
    Last edited by TradeWithGusto; 07-03-2023, 10:07 AM.

    #2
    Hello, thanks for writing in. You should first try setting your stop and target orders before submitting the entry order. This will arm the strategy to submit the stop and target order on the next submitted order.

    Comment


      #3
      Thanks, Chris. Gave that a try but had the same results as above. I went ahead and switched
      Code:
      CalculationMode.Currency
      to
      Code:
      CalculationMode.Ticks
      .

      This resolved the issue.

      Is there a reason this would work with ticks but not currency? In both cases I would assume it still handles the order individually regardless of how we set the stop loss/profit target.


      Comment


        #4
        Hi, its because when you use Currency the stop value will be placed based on the average entry price. After the first entry, it will adjust the stop value based on the newest average entry price that is seen. See the documentation for some more information on each of the calcuation modes:

        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