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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    60 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    39 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    20 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    22 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    51 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X