Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question regarding charting problem

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

    Question regarding charting problem

    Hi. I got a NT8 indicator called GomLabelHorizLines (first one listed on this page : http://ninjatrader.com/support/forum...N&pp=15&page=2 ) from the code section of this forum. This indicator shows labels on all horizontal lines of the chart. I have tried editing the code so that it labels lines instead of horizontal lines and so far I have been successful to this point. However, I would like to ask how to do I restrict the scope of the chart data from which the lines are labeled? The code was originally written to label all the horizontal lines on the chart but I would like to limit this to label only the lines which are either in the current session or alternatively in the visible part of the chart. Could you please give me an idea how to do this? I have attached the code for your reference. Thanks.
    Attached Files

    #2
    Hello,

    Thank you for the question.

    Either case would need to be handled with logic, you could do either really it would just depend which way you want to go.

    You can get the bar number of the first visible chart and check the objects against that, or you could check if the objects are from the date of the current session or before.

    You could look into using the Session Iterator object to limit logic or get the Time of the beginning of the session to do logic: http://ninjatrader.com/support/helpG...ghtsub=session

    For the visible chart bars, you could see this documentation on ChartControl: http://ninjatrader.com/support/helpG...imepainted.htm

    I look forward to being of further assistance.

    Comment


      #3
      How do I access the y value (price value) of a line chartobject?

      Thanks for your feedback. When there is a line chartobject which is attached to Ninjascript, how can I get its y value (price value)? What is the method I need to use in my code to access this property? Thanks.

      code snippet

      protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
      {
      foreach (Gui.NinjaScript.IChartObject co in ChartControl.ChartObjects)
      {
      if (co is NinjaTrader.NinjaScript.DrawingTools.Line)
      {
      NinjaTrader.NinjaScript.DrawingTools.Line l1 = (co as NinjaTrader.NinjaScript.DrawingTools.Line);

      if(l1.( I DON'T KNOW WHAT METHOD TO USE HERE) == price_x)
      //do something;

      Comment


        #4
        Hello,

        Here is the completed syntax to find the Price of the line. In NT8 there is a concept of Anchors, often tools will have multiple anchors so you will be looking for the Anchor you need the price of.

        Code:
        foreach (Gui.NinjaScript.IChartObject co in ChartControl.ChartObjects)
        {
        	if (co is NinjaTrader.NinjaScript.DrawingTools.Line)
        	{
        		NinjaTrader.NinjaScript.DrawingTools.Line l = co as NinjaTrader.NinjaScript.DrawingTools.Line;
        				
        		Print(string.Format("started at {0} and ended at {1}", l.StartAnchor.Price,l.EndAnchor.Price));
        	}
        }
        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        670 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X