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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    637 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X