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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        93 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        138 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        123 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        73 views
        0 likes
        Last Post PaulMohn  
        Working...
        X