Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to set a stop loss or Exit Long postion

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

    Trying to set a stop loss or Exit Long postion

    So im trying to set up stop loss/exit Long postion to make help make my backtesting a bit better.
    My current situation is that
    when a certain condition is true i enter either a long or a short by:

    EnterLong(Convert.ToInt32(DefaultQuantity), "longEntry1");
    EnterShort(Convert.ToInt32(DefaultQuantity), "shortEntry1");


    Now I want to set a stop loss for this long right?
    Im not sure if i should use SetStopLoss or ExitLongLimit
    I have the following two options that I wrote that im not sure what is better , I tired using both but in the backtest, the stop losses don't execute:

    SetStopLoss(CalculationMode.Currency, Swing.SwingLow[2]);
    ExitLongLimit(Swing.SwingLow[2], "longEntry1");


    Am i doing something wrong? Backtest seems not to work with the stop losses i have in place.​

    #2
    Hi tchen7, thanks for posting.

    Sell Limit orders must go above the market price, so you would want to use a StopMarket/StopLimit order to act as a stop loss. You can also use SetStopLoss(CalcuationMode.Price, Swing.SwingLow[2]​), make sure to call this line of code before calling the entry order method to arm the stop loss to trigger.

    Kind regards,
    -ChrisL

    Comment


      #3
      A follow up question, does calling SetStopLoss later on override the previous stoploss?

      Comment


        #4
        Hi tchen7, yes it does. If you call SetStopLoss again with a different price will modify the originally placed stop loss.

        Kind regards,
        -ChrisL

        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
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        48 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X