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

write an external AddON to draw line

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

    write an external AddON to draw line

    i want to write an AddOn to draw a line

    Examples:

    in my indicator i call class Static and i pass it some value

    It draw me a line in chart...(This class uses Draw.Line)

    I give to use New AddON ?

    if i use Draw.line in this static class I must to inherit from?ù

    i Hope you understand my post...thanks

    #2
    Hello turbofib,

    Thank you for your post.

    Is the add on added to the chart or is it in it's own window?

    I look forward to your response.

    Comment


      #3
      Add on chart

      Comment


        #4
        Hello turbofib,

        Thank you for your response.

        I have attached a basic example of an indicator that adds buttons in a side panel to the chart and allows for drawing objects through the buttons clicks. Please review the code and let me know if you have any questions.
        Attached Files

        Comment


          #5
          thanks...but you don't understand my post

          i give you another different example:


          ClassDraw(High[0], 0 , Low[10], 10);
          i want that it draw Rectangle....

          i ask you this question :

          How can i code ClassDraw? I want to create a separate Class not together to my class indicator

          Comment


            #6
            Hello turbofib,

            Thank you for your response.

            So you would call this class and pass it the variables and you want the class to draw the object on the chart, correct?

            I look forward to your response.

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Hello turbofib,

              Thank you for your response.

              So you would call this class and pass it the variables and you want the class to draw the object on the chart, correct?

              I look forward to your response.
              Yes...the function of this class is only to draw rectangle
              I want to use in this class Draw.Rectangle
              Last edited by turbofib; 05-05-2017, 01:55 PM.

              Comment


                #8
                Hello turbofib,

                Thank you for your response.

                I want to make sure you and I are clear here; the Add On is not it's own window, correct?

                Are you familiar with Partial Classes? Have you defined your class as part of the Indicator class?
                You can refer to the following link for information on Partial Classes: http://ninjatrader.com/support/helpG...hangesOverview

                I look forward to your response.

                Comment


                  #9
                  yes is correct...



                  Yes...i think there are no problem to use it

                  thanks you

                  Comment


                    #10
                    excuse me...i've a problem

                    namespace NinjaTrader.NinjaScript.Indicators
                    {
                    public partial class LucaStaticiMetodi : Indicator
                    {

                    public static bool prova()
                    {
                    if (Open[0] < High[0]) return false;
                    else return true;
                    }

                    }

                    i can't call Open[0] because is not static

                    I must to pass the reference Bars?

                    (https://ninjatrader.com/support/help...us/?getbar.htm)
                    Last edited by turbofib; 05-06-2017, 05:06 AM.

                    Comment


                      #11
                      Hello turbofib,

                      Thank you for your response.

                      You would pass the two doubles, the price of the High and the price of the Open.

                      Please let me know if you have any questions.

                      Comment


                        #12
                        In other uses i need to have : High Low Open Close of first candle....and High Low Open close Of second Candle.
                        Then i must to pass 8 values

                        i would pass 1 reference....it's easier and it's set off better

                        it's possibile to do this or not?
                        Last edited by turbofib; 05-09-2017, 10:17 AM.

                        Comment


                          #13
                          Hello turbofib,

                          Thank you for your response.

                          Below is a basic example of using the close of the current bar and the close of the prior bar in a partial class to draw a line on the chart.
                          Code:
                          namespace NinjaTrader.NinjaScript.Indicators
                          {
                          	public class TestPartialClass : Indicator
                          	{
                          		protected override void OnStateChange()
                          		{
                          			if (State == State.SetDefaults)
                          			{
                          				Description									= "";
                          				Name										= "TestPartialClass";
                          				Calculate									= Calculate.OnBarClose;
                          				IsOverlay									= true;
                          			}
                          		}
                          
                          		protected override void OnBarUpdate()
                          		{
                          			if (CurrentBar <= 2) return;
                          			MyMethods.drawLine(this, BarsArray[0], CurrentBar);
                          		}
                          	}
                          	
                          	public partial class MyMethods : Indicator
                          	{
                          		public static void drawLine(NinjaScriptBase owner, Bars bars, int cb)
                          		{
                          			Draw.Line(owner, "tag", 1, bars.GetClose(cb-1), 0, bars.GetClose(cb), Brushes.Orange);
                          		}
                          	}
                          }
                          Please let me know if you have any questions.

                          Comment


                            #14
                            Originally posted by NinjaTrader_PatrickH View Post
                            Hello turbofib,

                            Thank you for your response.

                            Below is a basic example of using the close of the current bar and the close of the prior bar in a partial class to draw a line on the chart.
                            Code:
                            namespace NinjaTrader.NinjaScript.Indicators
                            {
                                public class TestPartialClass : Indicator
                                {
                                    protected override void OnStateChange()
                                    {
                                        if (State == State.SetDefaults)
                                        {
                                            Description                                    = "";
                                            Name                                        = "TestPartialClass";
                                            Calculate                                    = Calculate.OnBarClose;
                                            IsOverlay                                    = true;
                                        }
                                    }
                             
                                    protected override void OnBarUpdate()
                                    {
                                        if (CurrentBar <= 2) return;
                                        MyMethods.drawLine(this, BarsArray[0], CurrentBar);
                                    }
                                }
                             
                                public partial class MyMethods : Indicator
                                {
                                    public static void drawLine(NinjaScriptBase owner, Bars bars, int cb)
                                    {
                                        Draw.Line(owner, "tag", 1, bars.GetClose(cb-1), 0, bars.GetClose(cb), Brushes.Orange);
                                    }
                                }
                            }
                            Please let me know if you have any questions.
                            if i would to use CurrentDayOHL() in MyMethods.drawLine
                            i code it :

                            double oo = CurrentDayOHL(owner.Input).CurrentHigh[0];
                            But it give me error : https://gyazo.com/ef9584ba7e7a99036c1a595afbc5c4b3

                            but i don't understand ..the object reference should be owner.high

                            How can resolve it? thanks
                            Last edited by turbofib; 09-14-2017, 05:30 PM.

                            Comment


                              #15
                              Hello turbofib,

                              Thank you for your post.

                              An indicator would need to run over historical data. The partial class is not loading any bars data like OnBarUpdate() would be. You need to pass anything that is needed by any method you call to your own method.

                              If you need an indicator's method to run, call it in the indicator and then pass it's value to the partial class method.

                              In my example the bars object is created in OnBarUpdate and then passed to the custom method. You would need to call the indicator and then pass it's value(s) to the custom method you need.

                              Please let me know if you have any questions.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, Today, 06:40 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post algospoke  
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post quantismo  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              8 responses
                              168 views
                              0 likes
                              Last Post jeronymite  
                              Started by cre8able, Today, 04:22 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X