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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    50 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X