Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot Modified Stop

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

    Plot Modified Stop

    I am using the example at the link below to modify the stoploss based on the market rising/falling compare to the entry. I am trying to plot/draw a dot/line/something to show where the stoploss is now and in the past when in a position. I am only able to get it to show up using plot during the last bar. How can I achieve having the something plotted at the current and past stoploss prices?



    Cheers!

    GT

    #2
    Hi GT,

    For one idea, please see this recent post:


    With IOrders you can expose the exact value of stop orders used. Position.AvgPrice - TickSize * 10 or similar will work if you're always placing stop losses at a fixed tick level.

    If your stop loss order is placed using SetStopLoss(), there is a special technique required for exposing its properties. This sample can help with the technique:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      With IOrders you can expose the exact value of stop orders used. Position.AvgPrice - TickSize * 10 or similar will work if you're always placing stop losses at a fixed tick level.

      What method would I use here? DrawLine()? I have recorded each level of my stop with variable using StopLevel1, StopLevel2, etc. Is that he best way? Also, would I use BarsSinceEntry() and BarsSinceExit() to have it only plot from the open of a position to the close?

      Comment


        #4
        cfree5119,
        Yes, draw objects are best for visualizing real-time stop levels in a strategy. This sample can help:


        I would provide a unique Draw command and tag for each of the levels you want to visualize. If you want it drawn only on the last few bars since you've been in a position, BarsSinceEntry() can be good for this. A simple approach could also be to draw horizontal lines that will be drawn the length of the chart. With horizontal lines then you can focus only on the Y value for placement.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I developed this code below. I am having issues with the "end date." I want it to be the current bar if I am in a long position or if I am not in a position I want it to end at the order "MyStopLoss" or "MyProfitTaker." Also, can I dynamically change this stop? So upon execution of "Long1" I begin drawing the line. When order "Long2" fires, I use the same tag line but change the y-value? This under OnExecution() of course. Thanks Ryan.

          Code:
          DrawLine("StopOrderLevel", false, BarsSinceEntry("Long1"), longStopOrderLevel1, CurrentBar, longStopOrderLevel1, Color.Magenta, DashStyle.DashDot, 1);

          Comment


            #6
            Best way to do this is probably:
            StartBarsAgo = BarsSinceEntry()
            EndBarsAgo = 0.

            Yes, can update the line with any dynamic changes. Use the same variable in your stop orders as you use in the draw statement and it will draw at the same point.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              0 does not produce a line. When I enter BarsSinceExit() with a position open, it draws a line from the last exit to the next open instead of the open to the most current bar. Not sure what is going on here.

              Comment


                #8
                is file corrupted?

                Originally posted by NinjaTrader_RyanM View Post
                Hi GT,

                For one idea, please see this recent post:
                [url]...

                If your stop loss order is placed using SetStopLoss(), there is a special technique required for exposing its properties. This sample can help with the technique:
                http://www.ninjatrader.com/support/f...ead.php?t=5790
                I have tried to download and extract this folder, but trying from 2 different computer gives same result - once extracted there is no .cs file in the Strategy folder. Am I just being a complete doofus? Or is something wrong with the zip folder?

                Thanks for checking!

                Comment


                  #9
                  Hi coolmoss,
                  It looks OK here. You don't have to open the zip file. Download it and then import it using File > Utilities > Import NinjaScript. You'll then have a SampleMonitorProfitTarget strategy available under Tolols > Edit NinjaScript > Strategy
                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  648 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  369 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  572 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X