Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

From DrawingTools namepace object, get High and Low of a bar that has been clicked on

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

    From DrawingTools namepace object, get High and Low of a bar that has been clicked on

    I am trying to get the Bar object when it is clicked on from a drawing tool. I can't seem to find how to reference it. I can get to it from an indicator, but not sure how to get to the array with a DrawingTool. Do you have any examples I could leverage? I did quite a bit of searching and didn't find it.

    I see ChartBars.Bars, but not sure how to index that (is 0 the main array of bars?) - I'm not new to C# but I'm a NT programming novice.

    Last edited by robbsadler; 06-29-2022, 12:11 PM.

    #2
    Hello robbsadler,

    Thank you for your post.

    You'd need to grab the ChartBars in the OnMouseDown method using GetAttachedToChartBars():

    Code:
    public override void OnMouseDown(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
    {
    // get the attached chart bars
    ChartBars myBars = GetAttachedToChartBars();
    
    int MyBarIdx = myBars.GetBarIdxByTime(chartControl, dataPoint.Time);
    Print("High: " + myBars.Bars.GetHigh(MyBarIdx) + " | Low:" + myBars.Bars.GetLow(MyBarIdx));
    
    // code continues


    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the guidance - it was very helpful!

      Now I am trying to go in the opposite direction from an OnBarUpdate event. How do I get the chartScale so I can call chartScale.GetYByValue?

      Thanks again!

      Comment


        #4
        Hello robbsadler,

        Thank you for your reply.

        Is this in an indicator or strategy? Drawing Tools don't use OnBarUpdate.

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DayTradingDEMON, Today, 09:28 AM
        3 responses
        19 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Stanfillirenfro, Today, 07:23 AM
        9 responses
        23 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by George21, Today, 10:07 AM
        0 responses
        8 views
        0 likes
        Last Post George21  
        Started by navyguy06, Today, 09:28 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        8 responses
        32 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X