Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

HorizontalLine available values

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

    HorizontalLine available values

    I am trying to write an strategy to pull the 'AnchorY' value of the horizontal lines that are drawn on the Chart. I can pull the tag and name of the items but I cannot find the variable to pull the 'AnchorY' value.

    I am using the following:

    protected override void OnBarUpdate()
    {
    if (DrawObjects.Count > 0)
    {
    foreach (DrawingTool draw in DrawObjects.ToList())
    {
    // Print ("Tag name: "+draw.Tag);
    // Print ("Tag name: "+draw.Name);
    // Print ("Tag name: "+draw.ToString());
    if (draw is DrawingTools.HorizontalLine)
    {
    DrawingTools.HorizontalLine temp = draw as DrawingTools.HorizontalLine;

    //Print("startYPrice: " + temp.StartAnchor.Price.ToString());

    }
    }
    }
    }​

    #2
    Hello thepcmd,

    I've copied the code into a script and uncommented the print and this is printing without issue.

    Click image for larger version  Name:	2023-01-18_8-23-30.png Views:	0 Size:	121.9 KB ID:	1231755

    Unrelated to this, typically I will recommend using the dynamic approach instead of type casting as this would prevent errors should you ever decide to export this as an assembly.
    https://ninjatrader.com/support/help...assemblies.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I have tested your information above and it works if I place a Horz line on the chart. The lines are generated by a 3rd party indicator. I am trying to export them so I can add them to another indicator. Is there any way to gather that information. I have attached a screenshot. Thanks in advance.
      Attached Files

      Comment


        #4
        Hello,

        Yes, this is possible. You will want to lock() the DrawingObjects collection to prevent access errors.

        Click image for larger version

Name:	2023-01-18_9-06-29.png
Views:	134
Size:	121.8 KB
ID:	1231770
        Last edited by NinjaTrader_ChelseaB; 01-18-2023, 10:06 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Unfortunately, that does not work for that 3rd party indicator. Is it possible to pull the 'Anchor Y 'value based on the tag number. I have given an example where it pull the data from a manually place line but does not give the price of the others - Maybe they aren't technically recognized as a Horz line since the tag name is system generated

          Tag name: c7f8c39f-16ff-4609-a282-5cbf85cb954c
          Tag name: aeb29ebf-a1ca-43e7-b247-074ccf2c8598
          Tag name: Horizontal Line 7 startYPrice: 33795.6974735737
          Tag name: a1b89e29-0cf5-4efc-a005-e6f3777d0806
          Tag name: 7238fcee-3b6d-4faa-8750-c8e8805a781a​

          Comment


            #6
            Hello thepcmd,

            I can provide you my test files that show this is possible.

            It might be an issue with the 3rd party script. It might be that it's an assembly and you need to use the dynamic approach instead of type casting as advised in post # 2.

            You could send the vendor or author an inquiry on how to use this with their software.
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Do you have any examples scripts of the dynamic approach?

              Comment


                #8
                Hello thepcmd,

                I would just be copying and pasting the code example from the help guide.

                Are you finding the example code in the help guide in insufficient for your needs?

                Have you copied and pasted this into a script and had a compile error?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I am able to get it to produce the AnchorY value. Thank you for your help!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  647 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  369 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  572 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X