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

Reading a horizontal line "Y" value

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

    #31
    Same Line on price Panel

    Hi again Joydeep. I have another question on these lines I'd appreciate some help. If you look at the attached chart you will see the green line DS2 in Panel2. I get this line as follows:

    PHP Code:

    //Level 2 support
                
                
    if (DrawObjects["DS2"] != null && DrawObjects["DS2"].DrawType == DrawType.Ray)
                {    
                
    IRay    alertLineDS2    null;
                
    IDrawObject        drawAlertLineDS2    DrawObjects["DS2"];
                if (
    drawAlertLineDS2 != null && drawAlertLineDS2.DrawType == DrawType.Ray)
                
    alertLineDS2 = (drawAlertLineDS2 as IRay);
                
                
    lineTargetDS2 showtargetoneDS2 Instrument.MasterInstrument.Round2TickSize(alertLineDS2.Anchor1Y) : targetoneDS2;
                
    DrawOnPricePanel false;DrawText("tag22"false,"DS2", -10,lineTargetDS2, -10,Color.White,new Font("Arial"7FontStyle.Bold),StringAlignment.CenterColor.LimeColor.Black10);DrawOnPricePanel true;
                
    alertLineDS2.Pen.Color Color.Lime;
                
    alertLineDS2.Pen.Width 2;
                
    alertLineDS2.Pen.DashStyle DashStyle.Dot;
                } 
    Once I manually insert DS2 ray I then draw another corresponding ray PS2 on the price panel. What I'd like to do now is automatically draw a PS2 Ray on the price panel without me having to manually draw it. So basically once I draw the DS2 Ray it should automatically draw the PS2 at the low of the bar on the price pane. When I move the DS2 line somewhere else then the PS2 line should also move.

    Any ideas on this one?
    Thanks in advance
    DJ
    Attached Files

    Comment


      #32
      Hello djkiwi,
      After you have drawn the DS2, simply draw the ray programitaccly taking reference of the alertLineDS2's x y value.

      Code:
      // add this line below your code 
      
      DrawRay("ray", alertLineDS2.Anchor1BarsAgo, Low[alertLineDS2.Anchor1BarsAgo], alertLineDS2.Anchor2BarsAgo, Low[alertLineDS2.Anchor1BarsAgo], Color.Blue);
      Please let me know if I can assist you any further.
      JoydeepNinjaTrader Customer Service

      Comment


        #33
        Draw Line

        Hi Joydeep, thank you very much for that. In fact I've been messing around with this piece of code for the last few hours trying to make it work.

        Cheers
        DJ

        Comment


          #34
          Hello DJ,
          Glad to know the code works for you.

          Please let me know if I can assist you any further.
          JoydeepNinjaTrader Customer Service

          Comment


            #35
            Chart Lines moving

            Thanks Joydeep. There is another issue I'd appreciate some help on this chart. Currently I am drawing lines on the bottom panel which is now reflected on the top panel based on the code you gave me. The only problem I'm finding is the lines on the bottom panel keep moving when I log back in or sometimes press F5 etc. The chart is obviously refreshing and changing the position based on new data. If you look at the first chart it all looks ok where I drew the line. The second chart in panel 2 the lines have moved away from the values I want so I have to keep moving them up and down where they should be. I use the actual numerical values on the chart in indicators so it is important the line are at the right place

            So is there a way to stop this happening. i.e automatically keep anchoring the lines on panel 2 to the the nearest high or low or stop the chart repositioning in the panel.

            Thanks in advance
            DJ
            Attached Files

            Comment


              #36
              Hello DJ,
              Unfortunately you cannot change the x values of the manually drawn lines programmatically.

              Please let me know if I can assist you any further.
              JoydeepNinjaTrader Customer Service

              Comment


                #37
                Draw Rectangle

                Hi Joydeep unfortunately I have to seek your services yet again

                I'm having some difficulty with drawrectangle. If you look at the attached chart. I have drawn the rectangle using the following code:

                PHP Code:
                DrawRectangle("upper2"false500,abovevalue1, -25,abovevalue2Color.TransparentColor.Red3); 
                The problem is the 500 number. I want to draw the rectangle from the first bar of the chart to the end. The 500 places it where it is now. If I put in 2000 instead of 500 I get this error in the log saying drawrectangle: startbarsago out of valid range and nothing is drawn. So the question is how do tell it to draw the rectangle from the first bar o the chart to the last bar of the chart?

                Thanks in advance

                DJ
                Attached Files

                Comment


                  #38
                  Hello djkiwi,
                  Please use this code to draw the rectangle from the first bar.

                  Code:
                  DrawRectangle("upper2", false, CurrentBar,abovevalue1, -25,abovevalue2, Color.Transparent, Color.Red, 3);
                  Please let me know if I can assist you any further.
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #39
                    Draw Locked

                    Thanks Joydeep. I did try that before and it didn't work. Seems to work ok now though. I have another one here though. I'm using this code to unlock the Ilines which works well:

                    foreach (IDrawObject draw in DrawObjects)

                    {
                    draw.Locked = false;
                    }

                    The problem is I'm not sure how to unlock a normal drawobject for example this line:
                    PHP Code:
                    DrawRay("PS1"falsealertLineDS1.Anchor1BarsAgoLow[alertLineDS1.Anchor1BarsAgo], alertLineDS1.Anchor2BarsAgoLow[alertLineDS1.Anchor1BarsAgo], Color.Cyan,DashStyle.Dot,2); 
                    I tried just drawobject but did not work.

                    Thanks in advance
                    DJ

                    Comment


                      #40
                      Hello DJ,
                      You can lock/unlock a draw object from the below code:

                      Code:
                      IRay ray = DrawRay("PS1", false, alertLineDS1.Anchor1BarsAgo, Low[alertLineDS1.Anchor1BarsAgo], alertLineDS1.Anchor2BarsAgo, Low[alertLineDS1.Anchor1BarsAgo], Color.Cyan,DashStyle.Dot,2);  
                      
                      ray.Locked = false; //unlock the ray
                      Please let me know if I can assist you any further.
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #41
                        universal line

                        how do i get a line drawn to apply to all charts please

                        Comment


                          #42
                          Hello laredo78676,
                          Unfortunately you cannot draw a line applicable to all charts (Global Draw Objects) via NinjaScript programming. I will however forward your feature request to development for future enhancement.

                          Please let me know if I can assist you any further.
                          JoydeepNinjaTrader Customer Service

                          Comment


                            #43
                            Hello laredo78676,
                            Development has assigned tracker id #570 for your feature request.
                            Please let me know if I can assist you any further.
                            JoydeepNinjaTrader Customer Service

                            Comment


                              #44
                              line

                              for a while i was drawing lines that transdered almost positive?

                              Comment


                                #45
                                Hello laredo78676,
                                To assist you further can you post a screenshot depicting what you are trying to do.

                                To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

                                For detailed instructions please visit the following link

                                How to take a screenshot on your smartphone, tablet, notebook or desktop computer


                                I look forward to assisting you further.
                                JoydeepNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by WHICKED, Today, 12:45 PM
                                1 response
                                8 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by samish18, Today, 01:01 PM
                                0 responses
                                5 views
                                0 likes
                                Last Post samish18  
                                Started by WHICKED, Today, 12:56 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post WHICKED
                                by WHICKED
                                 
                                Started by Spiderbird, Today, 12:15 PM
                                2 responses
                                11 views
                                0 likes
                                Last Post Spiderbird  
                                Started by FrazMann, Today, 11:21 AM
                                2 responses
                                8 views
                                0 likes
                                Last Post NinjaTrader_ChristopherJ  
                                Working...
                                X