Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Loss price modification

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

    Stop Loss price modification

    I used your Sample Price Modification Strategy to change SetStopLoss() prices. Since I need to use different Price based stop losses for the Long and Short Position, I thought to use the overload with the "from Entry Signal" string, but in this way the price modification stopped to work.
    Here is my code:

    if (Position.MarketPosition == MarketPosition.Flat)

    {
    SetStopLoss("Long", CalculationMode.Price, Min, false);
    }

    else if (Position.MarketPosition == MarketPosition.Long)
    {

    if (Close[0] > Position.AvgPrice + MyInput0 * TickSize)
    {
    SetStopLoss("Long", CalculationMode.Price, Position.AvgPrice, false);
    }
    }



    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss("Short", CalculationMode.Price, Max, false);
    }

    else if (Position.MarketPosition == MarketPosition.Short)
    {

    if (Close[0] < Position.AvgPrice - MyInput0 * TickSize)
    {
    SetStopLoss("Short", CalculationMode.Price, Position.AvgPrice, false);
    }
    }

    Something is wrong because I was running optimizations before successfully, with the new overload method for SetStopLoss I get the same results for each parameter.

    Thank you

    #2
    Hi Stefy,

    Thanks for your post.

    Please add TraceOrders = True to your Initialize code section.

    This way you can view all your stop loss modifications in the output window of the Control Center, which makes it easier to debug your code and see where you need to make a change.

    Please also review this link - http://www.ninjatrader-support.com/H...aceOrders.html

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    571 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    549 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    549 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X