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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by tsantospinto, 04-12-2024, 07:04 PM
        7 responses
        126 views
        0 likes
        Last Post aligator  
        Started by futtrader, 04-21-2024, 01:50 AM
        5 responses
        56 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Started by PeakTry, Today, 10:49 AM
        0 responses
        2 views
        0 likes
        Last Post PeakTry
        by PeakTry
         
        Started by llanqui, Today, 10:32 AM
        0 responses
        5 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by StockTrader88, 03-06-2021, 08:58 AM
        45 responses
        3,994 views
        3 likes
        Last Post johntraderuser2  
        Working...
        X