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 Waxavi, Today, 02:10 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Waxavi, Today, 02:00 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    5 responses
    23 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X