Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

My Stop Loss and Profit Target are moving with the current bar

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

    My Stop Loss and Profit Target are moving with the current bar

    Hello,

    I provided my code for the strategy, my goal is to make the my profit target and stop loss based on the indicator values at the time it entered into a position and not move anymore. For stop loss
    I use double previouslowerline = myindi.Lowerline[0]; but when I look sometimes on the backtested charts the bars where it finally ends in a stop loss are waaay far gone from the original value of the indicator. So I'm assuming my stop loss is dynamicly moving with the current bar?

    So I was wondering if you could help me out and Thank you in advance
    Attached Files

    #2
    Hello christopher512,

    Call SetStopLoss() before calling an entry method (not after).
    https://ninjatrader.com/support/help...etposition.htm

    The stop price would only be updated if the SetStopLoss() method is called. In the code I am seeing that there is a return if the position is flat.
    Are you certain this line is being called?

    Print the time of the bar one line above the SetStopLoss() call. Are you seeing this print appearing?
    Code:
    https://ninjatrader.com/support/forum/forum/ninjatrader-7/strategy-development-aa/99209-date-conditions-not-working?p=791121#post791121
    Chelsea B.NinjaTrader Customer Service

    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
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X