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