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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    41 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X