Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using negative value in SetStopLoss (Ticks) for breakeven

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

    Using negative value in SetStopLoss (Ticks) for breakeven

    ran into something interesting in ninjascript that compiles and works but apparently produces an error on NT8 startup.

    i was experimenting using SetStopLoss(CalculationMode.Ticks, -2, false) so this way no matter which direction the trade is in the stoploss would always move above (or below for shorts) breakeven by 2 ticks. this seems to function properly in strategy analyzer (shown in image 1) but when launching nt8 i always get the error shown in image 2.

    im curious what the devs at NT8 say about this. is it fine to use? is it a bug? would love to know yalls thoughts and actually i think allowing negative numbers in SetStopLoss just makes sense to me, if its not already a feature.

    #2
    hello travelingsalesman,

    The offset for targets needs to be a positive number, using a negative number there would not be supported and may cause issues.

    The Set methods automatically calculate the correct offset based on the direction of the trade so a positive number is always used for both directions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    47 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 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
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X