Announcement

Collapse
No announcement yet.

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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X