Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator DrawHorizontalLine to Attach: to ALL Charts

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

    #16
    Hello RolfTheus,

    You can use the following code to draw a line from the C# NT strategy...

    // Red SL Line
    str_SLLineTag = "StopLoss"
    ILine DrawLine_objSL;
    DrawLine_objSL = (ILine) DrawHorizontalLine(str_SLLineTag, false,
    GetCurrentAsk() + (int_InitSL_Ticks * TickSize), Color.Red, DashStyle.DashDot,3);
    DrawLine_objSL.Locked = false;

    It returns an obj ILine variable called DrawLine_objSL and then it sets its Locked property to false.
    Since the line is not "locked" you can now moved it around on the chart using your mouse.

    ...


    You can use these routines to Get or Set the price level of the StopLoss line...

    // Initial Price formatting string
    str_PriceFormat = Regex.Replace(((decimal)TickSize).ToString(),"([\\d])","0");
    str_PriceFormat = Regex.Replace(str_PriceFormat,",", ".");

    vSetLinePrice("StopLoss", 19675);
    double dblSL_LinePrice = dblGetLinePrice("StopLoss");

    private void vSetLinePrice(string strTag, double dblPrice)
    {
    // Set ILine Price
    double dbl_tmpLinePrice;
    ILine obj_Line = (ILine) DrawObjects[strTag];

    if (obj_Line != null)
    {
    obj_Line.StartY = dblPrice;
    }
    }

    private double dblGetLinePrice(string strTag)
    {
    // Get ILine Price
    double dbl_tmpLinePrice;
    ILine obj_Line = (ILine) DrawObjects[strTag];

    if (obj_Line == null) {dbl_tmpLinePrice = -1.0;}
    else
    {
    dbl_tmpLinePrice = Instrument.MasterInstrument.Round2TickSize(Convert .ToDouble(obj_Line.StartY.ToString(str_PriceFormat )));
    }

    return(dbl_tmpLinePrice);
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X