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

    #16
    ok...

    this method is call by indicator and by strategy....

    what type of date i declare in my method? the name of indicator or what ..
    Last edited by turbofib; 09-15-2017, 08:43 AM.

    Comment


      #17
      Hello turbofib,

      Thank you for your response.

      You would not call an indicator method in your partial class method. You would call it in the OnBarUpdate of the calling object and then pass it's value(s) to the partial class method you are building.

      Can you detail what you are attempting to create for the partial class method?

      I look forward to your response.

      Comment


        #18
        example of my code :
        .....
        ....
        public partial class MyMethods : Indicator
        {
        public static int Pattern(Indicator owner, int numPattern)
        {
        if (numPattern==1 && SMA(owner.High,3)>x) then ......
        }
        }

        ......

        MyIndicator :

        protected override void OnBarUpdate()
        {
        if (..MyMethods.Patttern(this,2))
        //instruction....
        }

        Comment


          #19
          Hello turbofib,

          Thank you for your response.

          In OnBarUpdate:
          Code:
          MyMethods.Pattern(this, SMA(High, 3)[0], 1);
          In the partial class:
          Code:
          		public static int Pattern(NinjaScriptBase owner, double smaValue, int numPattern)
          		{
          			if (numPattern==1 && smaValue>1)
          			{
          				owner.Print("Okay");
          				return 1;
          			}
          			else
          				return 0;
          		}
          Please let me know if you have any questions.

          Comment


            #20
            Ninjascript base is not correct...
            I had try it ..but it give me error on reference

            See error on #14 post
            Last edited by turbofib; 09-15-2017, 10:31 AM.

            Comment


              #21
              Hello turbofib,

              Thank you for your response.

              Please follow my example, it has been tested and confirmed to be working.

              Comment


                #22
                Originally posted by NinjaTrader_PatrickH View Post
                Hello turbofib,

                Thank you for your response.

                In OnBarUpdate:
                Code:
                MyMethods.Pattern(this, SMA(High, 3)[0], 1);
                In the partial class:
                Code:
                		public static int Pattern(NinjaScriptBase owner, double smaValue, int numPattern)
                		{
                			if (numPattern==1 && smaValue>1)
                			{
                				owner.Print("Okay");
                				return 1;
                			}
                			else
                				return 0;
                		}
                Please let me know if you have any questions.
                there is a problem....i dont want use it

                MyMethods.Pattern(this, SMA(High, 3)[0], 1);

                But i want use : MyMethods.Pattern(this, SMA(High, 3), 1);

                I need to have SMA as series in my method and not to pass a double value..

                is possible to do this?

                Comment


                  #23
                  Hello turbofib,

                  Thank you for your response.

                  Pass the overload for the indicator as it's type. For example:
                  Code:
                  public static int Pattern(NinjaScriptBase owner, SMA sma, int numPattern)
                  Then you call the sma with it's barsAgo index:
                  Code:
                  if (numPattern==1 && sma[0] >1)
                  Please let me know if you have any questions.

                  Comment


                    #24
                    see this post



                    if i want to use it (CurrentDayOHL to find High(of 1day ago, 2 days ago...)
                    in my method : public static int Pattern(.....)

                    i give di record the value of High of session in My Method......but is not possible to record it...

                    have you any idea to do this ? (Use CurrentDayOHL to find High session of 1,2. .3 day ago)

                    Comment


                      #25
                      Hello turbofib,

                      Thank you for your response.

                      If you wanted to run the CurrentDayOHL or PriorDayOHLC in a custom method you would need some means to verify the beginning and ending of a period and I can only see looping through the bars object passed to the method as a means to do this. All in all the only concept I can come up with for the partial class method would be inefficient from a performance stand point.

                      I would recommend the use of AddDataSeries() for the Day bar or 1440 Minute bar and reference the Open, High, Low, Close or any other item you need in your script directly from the added series.

                      CurrentDayOHL is generally best reserved for quickly pulling the current session values and PriorDayOHLC is best reserved for pulling the prior session values.

                      Please let me know if you have any questions.

                      Comment


                        #26
                        Originally posted by NinjaTrader_PatrickH View Post
                        Hello turbofib,


                        I would recommend the use of AddDataSeries() for the Day bar or 1440 Minute bar and reference the Open, High, Low, Close or any other item you need in your script directly from the added series.


                        Please let me know if you have any questions.
                        The High of DayBar of 2 bar ago can to be different as High of Session (calcuate intraday) of 2 day ago...(the open and close daily calculate in intraday mode) may not coincide..

                        can i create Array of 24 element ( Open[0]...Open[5], High[0] ..High[5]...) (assigned as http://ninjatrader.com/support/forum...fib#post519992 )
                        and send it as parameter in my method?

                        Comment


                          #27
                          Hello turbofib,

                          Thank you for your response.

                          Your link did not work on my end, but you should be able to pass an array.

                          However, why not just use a 1440 Minute bar? This would essentially be a day bar but with your session template/trading hours template applied to it.

                          Please let me know if you have any questions.

                          Comment


                            #28
                            excuse me...the link is



                            ok ...i use AddDataSeries() for 1440 Minute bar in my Main Indicator and then i send with parameter the Array[24] to my method Pattern
                            Is correct or there is a method less expansive to send it with parameter?
                            Thanks

                            But it is possible to create AddSeries Into my method Pattern? (and not pass it with parameter)
                            Last edited by turbofib; 09-18-2017, 01:24 PM.

                            Comment


                              #29
                              Hello turbofib,

                              Thank you for your response.

                              I am actually suggesting that you refrain from the custom method use and just call the AddDataSeries in each script that needs to access previous session values and call the added 1440 Minute bar's Open, High, Low, or Close without the use of a custom method.

                              Please let me know if you have any questions.

                              Comment


                                #30
                                I can't avoid to create an external method because tin this method there are 60 pattern price..

                                I call this method in many indicator....

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Aviram Y, Today, 05:29 AM
                                0 responses
                                2 views
                                0 likes
                                Last Post Aviram Y  
                                Started by quantismo, 04-17-2024, 05:13 PM
                                3 responses
                                25 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by ScottWalsh, 04-16-2024, 04:29 PM
                                7 responses
                                34 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by cls71, Today, 04:45 AM
                                0 responses
                                6 views
                                0 likes
                                Last Post cls71
                                by cls71
                                 
                                Started by mjairg, 07-20-2023, 11:57 PM
                                3 responses
                                216 views
                                1 like
                                Last Post PaulMohn  
                                Working...
                                X