Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Currency Stop Loss with Rithmic

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

    Currency Stop Loss with Rithmic

    Hi

    I was experiencing some issues with strategies that I'd created, which backtested fine but then when I ran them live, the stop losses didn't seem to be setting correctly, which resulted in losing trades greater than the stop loss I'd set. I found some other forum posts from people with similar issues and the advice to enter all logic into OnExecutionUpdate().

    Could someone please confirm that this is the correct way to set a currency stop loss, which will work correctly when running a strategy through a Rithmic account?


    Code:
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
    
    if (execution.Order.OrderState == OrderState.Filled)
    {
    if (execution.Order.Name == "Long")
    {
    SetStopLoss("Long", CalculationMode.Currency, StopLoss, false);
    SetProfitTarget("Long", CalculationMode.Currency, ProfitTarget);
    }
    else if (execution.Order.Name == "Short")
    {
    SetStopLoss("Short", CalculationMode.Currency, StopLoss, false);
    SetProfitTarget("Short", CalculationMode.Currency, ProfitTarget);
    }
    }
    
    }​
    Thanks

    #2
    Hello Dan_TUK,

    Thank you for your post.

    Rithmic still uses separate feeds for Order/Execution/Position events and these events still do not have a deterministic order in NinjaTrade. You will want to be mindful to handle these events separately and make you sure do not rely on Order information in OnExectuionUpdate where you would want to handle stop and target submissions.

    I recommend taking a look at this forum post which has Rithmic/IB friendly examples for stop and target submission using exit methods.




    I also note you are using Set methods. Please note that set methods cannot be unset. This means it is important to call the Set method with CalculationMode.Ticks to reset this before calling an entry method (not after).​

    Additionally, if you are going to use Set methods and you want to dynamically change/modify the price of the stop loss and profit target, these methods should be called from within OnBarUpdate() and the price should always be reset when the strategy becomes flat again. This information is noted in the "Tips" section on the following help guide pages:
    The reference sample script SamplePriceModification demonstrates how to change the price of stop loss and profit target orders:

    https://ninjatrader.com/support/helpGuides/nt8/modifying\_the\_price\_of\_stop\_lo.htm

    Please let us know if you have any further questions.

    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