Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AutoTrading from Indicator ??

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

    #16
    Thanks, that makes so much sense. But, would be code look like this?

    If (BETA.ok2Trade[0]==1)
    { code for order here }

    Or this

    If (BETA.ok2Trade==1 [0])
    { code for order here }

    Comment


      #17
      Originally posted by sarasotavince View Post
      Thank you coolmoss, that will be helpful in the future...

      Thank you sledge,

      I believe you understand exactly what I am asking. Your example should give me enough room to experiment. One question for now...I may be back for more later! So, thanks again so much, this is how I learn best...

      Is there a way to be sure the indicator updates before the strategy starts? For example, this entire strategy for entering trades hinges on if it is "ok2Trade" as determined by that variable in the indicator beta003. If ok2Trade is YES and then turns to NO after on bar update, I don't want the strategy to fire off a trade order. Do all active indicators update before all active strategies by default? Does it happen in the order I add items to a chart?...in that case, I would add the indicator first, then the strategy.
      If you want to reference anything other than an element of a Series, you must expose it as a Property, and call Update() in the getter.

      ref: http://www.ninjatrader.com/support/f...ead.php?t=4991

      Comment


        #18
        Hello sarasotadvince,

        Thank you for your response.

        The code would be the first one you listed:
        Originally posted by sarasotavince View Post
        If (BETA.ok2Trade[0]==1)
        { code for order here }

        Comment


          #19
          sledge,

          I am getting closer, but this line I don't quite understand:

          BETA = beta003 ( BarsArray[0], ..... ); //whatever your constructor requires in the indicator

          I have in my code:
          BETA=beta003 (BarsArray[0]); not knowing what "whatever your constructor requires in the indicator" means.

          Can you simplify that for me... since I have nothing afterwards I am getting error CS1501: No overload for method beta003 takes 1 arguments...

          Also your code has OnStartUp... is that different than Initialize?

          Comment


            #20
            Hello sarasotavince,

            Not to step on sledge's toes here but thought I would provide some insight here.

            Constructors refer to the needed parameters for the indicator's method. Like 'period' for the SMA() method. You can find more information at the following link: http://msdn.microsoft.com/en-us/library/ace5hbzh.aspx

            If you attach your indicator to your response I can detail how to call it in a strategy. You will find your indicator in the following directory of your PC as a .cs file: (My) Documents\NinjaTrader 7\bin\Custom\Indicator

            OnStartUp() is called after Initialize() and is used to define any variables or resources you only wish to use in that strategy or indicator.
            You can find information on both methods at the following links:

            Comment


              #21
              Calling variable from indicator to a strategy

              I appreciate your offer. My learning curve was starting to flatten out. I have attached an earlier version Beta00. For my learning, this should achieve the same purpose. I have an INT called ok2Trade that will have a value 1, 2, or 3 based on the conditions. As before, I want to call the variable (the value of that variable) to a strategy. I am including a simple strategy that you can use to call the variable into...if that will help.
              Attached Files

              Comment


                #22
                Originally posted by sarasotavince View Post
                I appreciate your offer. My learning curve was starting to flatten out. I have attached an earlier version Beta00. For my learning, this should achieve the same purpose. I have an INT called ok2Trade that will have a value 1, 2, or 3 based on the conditions. As before, I want to call the variable (the value of that variable) to a strategy. I am including a simple strategy that you can use to call the variable into...if that will help.
                Your code requires no additional parameters.

                The constructor is here:
                Code:
                        public Beta00 Beta00(Data.IDataSeries input)
                        {
                This should compile and work:

                Code:
                BETA = beta003 ( BarsArray[0]);
                *this is how I've done it, there might be an easier way...

                Comment


                  #23
                  sledge,

                  I've read up on BarsArray and don't see how that fits into what I am trying to do. But I am at the end of my rope for what makes sense.

                  In total, I'm surprised...what seemed like any easy task has been so confusing. I even tried moving my entire indicator code inside of a strategy...that produced so many errors it was silly. So, why does Ninja Trader have two sets of instructions to accomplish the same thing all depending on if it's an indicator or a strategy. Would not it have been easier to allow order execution from within an indicator? It's only a few more lines of code but all of that requires a separate strategy to be written and run. Seems very ineffective to me. And why can't I use chart trader when I am running a strategy or at least see the bracket orders on the chart instead of being limited to the dome. I'm just blowing off steam now. And I thought VBA didn't make sense at times...

                  Comment


                    #24
                    Hello sarasotavince,

                    Thank you for your response.

                    For the ok2Trade we can just use Update() in the properties section to allow us to call this value from the strategy. Within the indicator Beta00 place the following in the properties:
                    Code:
                    		[Browsable(false)]
                            [XmlIgnore()]
                            public int Ok2Trade
                            {
                    			// We need to call the Update() method to ensure our exposed variable is in up-to-date.
                                get { Update(); return ok2Trade; }
                            }
                    And then in your strategy you can call the ok2Trade like the following that prints it's value:
                    Code:
                    Print(Beta00().Ok2Trade);
                    For an example of this please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=4991

                    Comment


                      #25
                      Hello Patrick,

                      The second part of your code is throwing an error when I use the following...
                      if (...

                      && Beta00().Ok2Trade==1) // the last condition

                      error message is:

                      No overload for method 'Beta00' takes '0' arguments.


                      Any ideas? Sorry this is proving so difficult a concept for me to understand and code. I'm simply trying to pull a variable from an indicator into a strategy, check that value (as coded above) and if the value is 1, execute the strategy...

                      Comment


                        #26
                        Hello sarasotavince,

                        Please provide the full line of code that generates this error message.

                        Comment


                          #27
                          Thanks but I have given up on this idea...

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by GussJ, 03-04-2020, 03:11 PM
                          11 responses
                          3,221 views
                          0 likes
                          Last Post xiinteractive  
                          Started by andrewtrades, Today, 04:57 PM
                          1 response
                          10 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by chbruno, Today, 04:10 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post chbruno
                          by chbruno
                           
                          Started by josh18955, 03-25-2023, 11:16 AM
                          6 responses
                          436 views
                          0 likes
                          Last Post Delerium  
                          Started by FAQtrader, Today, 03:35 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post FAQtrader  
                          Working...
                          X