Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

help with DrawRay function

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

    help with DrawRay function

    Hello,

    Can someonone help on the following code?

    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    // Plot0.Set(Close[0]);

    if (CurrentBar > 1) DrawRay("ray", 1, Open[0], 0, Open[0], Color.LimeGreen);

    //this.DrawRectangle("Rec", false, 0, High[0], -10, Open[0], Color.Blue, Color.Blue, 3);
    //RemoveDrawObject("tag1");
    }
    This indicator works but does not display the Price. I would like it to display the price on the Price Panel or as a text above the Line

    Thanks

    #2
    Hello KenyaTrader,

    Thank you for your post and welcome to the forums!

    When you say not displaying the price are you referring the plot? or the DrawRay()?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I am referring the plot

      Comment


        #4
        Hello kenyaTrader,

        You will need to uncomment the Plot0.Set(Close[0]);, so remove the '//' in front of the Plot0.Set().

        Comment


          #5
          Sorry for the confusion. This is what i wanted with the below code, when the line is drawn, to have it dispaying the price on th line

          protected override void OnBarUpdate()

          if (CurrentBar > 1) DrawLine ("Open", -20, Open[0], 0, Open[0], Color.Blue);
          DrawLine("Open2", -20, Open[0] - 3 * TickSize, 0, Open[0] - 3 * TickSize, Color.Red);
          DrawLine("Open3", -20, Open[0] + 3 * TickSize, 0, Open[0] + 3 * TickSize, Color.Red);

          Or there might be another way to achieve my goal

          Thanks...
          Attached Files

          Comment


            #6
            Originally posted by kenyaTrader View Post
            Sorry for the confusion. This is what i wanted with the below code, when the line is drawn, to have it dispaying the price on th line

            protected override void OnBarUpdate()

            if (CurrentBar > 1) DrawLine ("Open", -20, Open[0], 0, Open[0], Color.Blue);
            DrawLine("Open2", -20, Open[0] - 3 * TickSize, 0, Open[0] - 3 * TickSize, Color.Red);
            DrawLine("Open3", -20, Open[0] + 3 * TickSize, 0, Open[0] + 3 * TickSize, Color.Red);

            Or there might be another way to achieve my goal

            Thanks...
            ref: http://www.ninjatrader.com/support/f...64&postcount=3

            Comment


              #7
              Sorry for my limited knowledge but can you please explain the following variable? strStopValue
              Last edited by kenyaTrader; 03-30-2015, 02:32 PM.

              Comment


                #8
                Hello kenyaTrader,

                Thank you for your response and thank you to koganam for that post.

                strStopValue is likely a string representing the price level of the stop order in the context of that example. So likely a double that has been converted to a string to be passed to the DrawText().

                Comment


                  #9
                  this is my final version that works

                  thanks koganam + NinjaTrader_PatrickH for helping me

                  protected override void OnBarUpdate()
                  {
                  double myOpen = Open[0] ;
                  double myOpen1 = Open[0] - 3 * TickSize;
                  double myOpen2 = Open[0] + 3 * TickSize;

                  if (CurrentBar > 1) DrawLine ("Open", -17, Open[0], 0, Open[0], Color.Blue);
                  DrawText("Text", true, myOpen.ToString(), -20, Open[0], 0, Color.Black, new Font("Times New Roman", 12), StringAlignment.Center, Color.Blue, Color.Gray, 100);

                  DrawLine ("Open1", -20, Open[0] - 3 * TickSize, 0, Open[0] - 3 * TickSize, Color.Red);
                  DrawText("Text1", true, myOpen1.ToString(), -20, Open[0] - 3 * TickSize, 0, Color.Black, new Font("Times New Roman", 12), StringAlignment.Center, Color.Blue, Color.Gray, 100);

                  DrawLine ("Open2", -20, Open[0] + 3 * TickSize, 0, Open[0] + 3 * TickSize, Color.Red);
                  DrawText("Text2", true, myOpen2.ToString(), -20, Open[0] + 3 * TickSize, 0, Color.Black, new Font("Times New Roman", 12), StringAlignment.Center, Color.Blue, Color.Gray, 100);

                  }
                  Attached Files

                  Comment


                    #10
                    Originally posted by kenyaTrader View Post
                    this is my final version that works

                    thanks koganam + NinjaTrader_PatrickH for helping me

                    protected override void OnBarUpdate()
                    {
                    double myOpen = Open[0] ;
                    double myOpen1 = Open[0] - 3 * TickSize;
                    double myOpen2 = Open[0] + 3 * TickSize;

                    if (CurrentBar > 1) DrawLine ("Open", -17, Open[0], 0, Open[0], Color.Blue);
                    DrawText("Text", true, myOpen.ToString(), -20, Open[0], 0, Color.Black, new Font("Times New Roman", 12), StringAlignment.Center, Color.Blue, Color.Gray, 100);

                    DrawLine ("Open1", -20, Open[0] - 3 * TickSize, 0, Open[0] - 3 * TickSize, Color.Red);
                    DrawText("Text1", true, myOpen1.ToString(), -20, Open[0] - 3 * TickSize, 0, Color.Black, new Font("Times New Roman", 12), StringAlignment.Center, Color.Blue, Color.Gray, 100);

                    DrawLine ("Open2", -20, Open[0] + 3 * TickSize, 0, Open[0] + 3 * TickSize, Color.Red);
                    DrawText("Text2", true, myOpen2.ToString(), -20, Open[0] + 3 * TickSize, 0, Color.Black, new Font("Times New Roman", 12), StringAlignment.Center, Color.Blue, Color.Gray, 100);

                    }
                    You are creating 3 copies of the same font object per run, and not disposing of the objects. You would be better off creating one copy of the font object, using it 3 times, then disposing of it.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by owenwong, Today, 06:34 PM
                    2 responses
                    17 views
                    0 likes
                    Last Post owenwong  
                    Started by REI140205, Today, 06:17 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post REI140205  
                    Started by Gathem, Today, 06:06 PM
                    1 response
                    11 views
                    0 likes
                    Last Post Gathem
                    by Gathem
                     
                    Started by tg1886, Today, 04:09 PM
                    3 responses
                    25 views
                    0 likes
                    Last Post NinjaTrader_ShawnB  
                    Started by mythue, Today, 03:48 PM
                    2 responses
                    13 views
                    0 likes
                    Last Post mythue
                    by mythue
                     
                    Working...
                    X