Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Negative values in SetStopLoss by Currency?

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

    Negative values in SetStopLoss by Currency?



    Should SetStopLoss by Currency always be a positive value, or can it be set to a negative or positive value?

    Say my current unrealized gain is $30. I want to set a stop loss at -$20, or $50 from my current realized gain. Would the proper statement then be:

    SetStopLoss(CalculationMode.Currency, -20);


    Or, say I want to set an initial stop loss at -$20 from entry price. Then, after a gain, I want to reset to +$20 from entry price. Would this be:

    SetStopLoss(CalculationMode.Currency, -20);
    SetStopLoss(CalculationMode.Currency, 20);

    The reference code uses only a positive value, so I'm unsure how to use currency to specify the -$20/$20 case.

    How to do? Thanks,





    Last edited by timmbbo; 03-14-2024, 05:56 PM.

    #2
    Hello timmbbo,

    Thank you for your post.

    When using Currency for the calculation mode, it must be a positive number. if you put 20, then the stop loss will be placed at a value of $20 PnL away from the average entry price. If it is for a long entry, the stop loss will be placed below the entry price and if it is for a short entry, the stop loss will be placed above the entry price. There is no need to specify positive or negative, as the platform will know which side of the market to place the stop loss.

    On the following page, Currency is described as, "PnL away from average entry. Calculated by the dollar per tick value for the order quantity used. When this mode is used, StopTargetHandling will automatically be set to ByStrategyPosition"


    Please test out SetStopLoss() with the calculation mode set to currency and observe the behavior. It can be most simple to test in the Playback Connection as you can observe the real-time behavior and manipulate the playback time/speed as needed:


    Please let us know if we may be of further assistance.

    Comment


      #3

      Emily, thanks. Given this, it seems like one can not use currency to reset to use for trailing stops. Say I do

      EnterProfitTarget(Current, $100)
      EnterStopLoss(Currency, $20)
      EnterLong()

      After I enter long, I have an unrealized gain of $40. Now, I want to set my stop loss to +$30, to protect my gain. Since I've entered long, EnterStopLoss by Currency will always set the stop loss under the entry price. There's no method to use EnterStopLoss/Currency to set the stop loss above the entry price.

      Therefore, it would seem like EnterStopLoss / Currency can not be used to implemented trailing stops, correct?




      Comment


        #4
        Originally posted by timmbbo View Post
        Emily, thanks. Given this, it seems like one can not use currency to reset to use for trailing stops. Say I do

        EnterProfitTarget(Current, $100)
        EnterStopLoss(Currency, $20)
        EnterLong()

        After I enter long, I have an unrealized gain of $40. Now, I want to set my stop loss to +$30, to protect my gain. Since I've entered long, EnterStopLoss by Currency will always set the stop loss under the entry price. There's no method to use EnterStopLoss/Currency to set the stop loss above the entry price.

        Therefore, it would seem like EnterStopLoss / Currency can not be used to implemented trailing stops, correct?
        You can use SetStopLoss() with a Currency calculation mode for the initial stop loss value, though if you would like to have it trail later on you would likely need to use SetStopLoss() dynamically with the Price calculation mode. If you know the dollar per tick value for the instrument being traded, you could set the stop loss to +$30 by setting it to a Price of Position.AveragePrice + ___ * TickSize, with the underscore being however many ticks in profit you would like to move the stop loss to. For an example of modifying stop and target orders, please see this strategy:


        Please let us know if we may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 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