Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing Horizontal Lines

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

    Drawing Horizontal Lines

    I have a strategy that draws a horizontal line at the price that it went long (or short) at based on an ATM Strategy.

    DrawHorizontalLine("tag1",GetAtmStrategyPositionAv eragePrice(AtmStrategyId), Color.Yellow);

    When the trade is over, the line is removed:

    if (GetAtmStrategyMarketPosition(AtmStrategyId) == MarketPosition.Flat)
    {
    RemoveDrawObjects();
    }

    What I need to know, is how to draw 3 other lines:

    1 - a line at my stop - private int stop = 22;
    2 - a line at my target - private int target = 24;
    3 - a line 2 ticks above my entry

    Also, will the one line of code: RemoveDrawObjects(); get rid of all the lines at once?

    #2
    Hello Ghunt,

    If you're able to draw at the entry price, then you could just add/subtract from this value to draw at your stops and targets.

    Below is what you would use for targets in a long position.
    Code:
    DrawHorizontalLine("Target", GetAtmStrategyPositionAveragePrice(AtmStrategyId) + TickSize * 24, Color.Yellow);
    You would subtract 24 ticks for your target in a short position.

    Yes, RemoveDrawObjects() will remove all drawing objects from your chart at once.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    59 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    143 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X