Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Target Profit/Stoploss Horizontal Lines

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

    Target Profit/Stoploss Horizontal Lines

    is there a code to have lines set to adjust Target Profit/Stoploss orders like "Chart trader"? Not looking for all the details that Chart trader plots...but would be nice

    Code:
    [SIZE=2][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/SIZE]
    [FONT=Courier New][SIZE=2](Position.MarketPosition == MarketPosition.Long)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"long stop"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ,Position.AvgPrice - (stop_ticks* TickSize),Color.Pink,DashStyle.Dot,[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"long tp"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ,Position.AvgPrice + (tp_ticks * TickSize),Color.PaleGreen,DashStyle.Dot,[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]} [/FONT][/SIZE]

    #2
    Hi duck_CA, are you looking for code to visualize your strategies stop and target levels while running? Or are you looking to modify your strategy orders by dragging and dropping those horizontal lines?

    Comment


      #3
      looking to adjust target/stop loss levels

      either way would work for me

      Comment


        #4
        You currently cannot modify orders through draw objects. Thank you for the suggestion. We will add it to the list of future considerations.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Bertrand,

          I'd be interested in best way to go about visualizing my stops (stop & profit stop). I was thinking of writing an indicator that accepts data series as inputs. And then use Add() within Strategy.Initialize() to add this indicator to the strategy, and pass it some data series that would represent the stop values over time (sometimes it would be null when not in a trade). The strategy would then update the underlying DataSeries objects it passed into the indicator via OnBarUpdate, etc. as the trade position state changed.

          Would this be the best way to go about solving this? Or do you have a sample that illustrates a way to achieve this visualization of values modified within a strategy?

          Thanks,

          JD

          Comment


            #6
            Hi JD, the easiest way would be to use Draw methods directly from the strategy to visualize the levels. Just make sure you use unique tags if you need to see also the past levels...

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            596 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            554 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X