Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Printing my trailing stop on the chart

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

    Printing my trailing stop on the chart

    Hi - I am capturing my stoploss price in a variable and that variable changes depending on what the trade is doing etc. I want to show this price on the chart. I have written the code below and placed it inside OnBarUpdate() and it compiles just fine but the lines never show up on the chart. I've done a lot of googling etc and can't find out what the optimum way of doing this is. The only other thing I can think of AddPlot() and then pass my stoploss variable to that. But I am struggling as to why this is so complicated. I just want to visually see my stop price dynamically on the chart.
    Thanks in advance.


    // Mark the stoplosses on the chart
    if (Position.MarketPosition == MarketPosition.Long)

    {
    Draw.Line(this, "Long Stop", false, 10, longStop, 10, longStop, Brushes.DodgerBlue, DashStyleHelper.Dash, 2);
    }

    else if (Position.MarketPosition == MarketPosition.Short)

    {
    Draw.Line(this, "Short Stop", false, 10, shortStop, 10, shortStop, Brushes.DodgerBlue, DashStyleHelper.Dash, 2);
    }​

    #2
    Hello Red 7 Trading,

    I would suggest turning on autoscale in your drawing objects in case the value of your variable is not being set correctly, that will let the object be seen even if its at a value of 0. Right now you have false in both statements, that would be true to turn on autoscale.

    I also see you used 10 as the from and to bars ago, you need to specify different numbers like 10 and 0 so the line has width.

    This may also relate to where the code is in your script, we would need more details about where you are calling this code and how you are setting the variables being used.

    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by carnitron, Today, 08:42 PM
    0 responses
    5 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Today, 07:51 PM
    0 responses
    6 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,974 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Today, 06:48 PM
    0 responses
    8 views
    0 likes
    Last Post rbeckmann05  
    Started by rhyminkevin, Today, 04:58 PM
    4 responses
    58 views
    0 likes
    Last Post dp8282
    by dp8282
     
    Working...
    X