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

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, 03: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 BarzTrading, Today, 07:25 AM
                    1 response
                    9 views
                    1 like
                    Last Post NinjaTrader_Clayton  
                    Started by EB Worx, 04-04-2023, 02:34 AM
                    7 responses
                    161 views
                    0 likes
                    Last Post VFI26
                    by VFI26
                     
                    Started by Mizzouman1, Today, 07:35 AM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by Radano, 06-10-2021, 01:40 AM
                    20 responses
                    616 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by i019945nj, 12-14-2023, 06:41 AM
                    6 responses
                    69 views
                    0 likes
                    Last Post i019945nj  
                    Working...
                    X