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 NullPointStrategies, Today, 05:17 AM
    0 responses
    20 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    119 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X