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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    65 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    35 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    51 views
    0 likes
    Last Post CarlTrading  
    Working...
    X