Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using exposed variable from indicator within strategy

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

    Using exposed variable from indicator within strategy

    Hi,

    I have a question related to using an exposed variable from an indicator within a strategy.

    After following the code break changes if I apply the said indicator to a chart the variable is printing to the output screen as expected however when I attempt to print and or use the exposed variable from within the strategy it is not showing the correct value at any time.

    I'm sure the solution to this problem is something simple but I'm unable to identify what it may be.

    Regards,
    suprsnipes

    #2
    How are you declaring / using the variable? Can you provide some code snippets so we can offer some debugging assistance?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by suprsnipes View Post
      Hi,

      I have a question related to using an exposed variable from an indicator within a strategy.

      After following the code break changes if I apply the said indicator to a chart the variable is printing to the output screen as expected however when I attempt to print and or use the exposed variable from within the strategy it is not showing the correct value at any time.

      I'm sure the solution to this problem is something simple but I'm unable to identify what it may be.

      Regards,
      suprsnipes
      What type of variable?

      Have you run Update() in the getter?

      Comment


        #4
        Hi,

        Thanks for the responses, this is the code I am using to expose the variable and then use the variable within the strategy. However when I attempt to access this variable from within the strategy it returns a 0.

        As mentioned I am also using the Print function which when applying the indicator to a chart the variable is working correctly but this same exposed variable within the strategy is not.

        Is anyone else experiencing this problem?

        Expose the variable within the indicator;

        Code:
        #region Properties
                [Browsable(false)]
                [XmlIgnore()]
                public double OkToTrade
                {
        // We need to call the Update() method to ensure our exposed variable is in    up-to-date.
                    get { Update(); return okToTrade; }
                }
        #endregion
        Access the variable within the strategy;

        Code:
        this.DB().OkToTrade

        EDIT: Just tested the following...created a new indicator and using a Print statement to access the exposed variable and applied this to a chart which worked as expected. I did the same for a new blank strategy where the result was the same as above. Also note that I am using the strategy analyzer for the strategies.

        Regards,
        suprsnipes
        Last edited by suprsnipes; 06-24-2015, 06:48 PM.

        Comment


          #5
          Humm,

          I have had similar issues but not exactly the same. What I found is if you want to use an indicator within a Strategy, you need to define it in the "Configuration" section for use with the Strategy Analyzer. I don't know what happens when you use it directly within the "OnUpdate()" function.

          Some indicators you might need to explicitly add the dataseries to use "BarsArray[0]" for example.

          So something like this in State.Configure:

          myInd = myInd(BarsArray[0],...,...,...);

          Comment


            #6
            Can NinjaTrader verify this?

            I'm not quite sure how to follow your example below. Can you provide additional guidance. Is there anything in the help guide I can refer to?

            Thanks.

            Originally posted by NJA_MC View Post
            Humm,

            I have had similar issues but not exactly the same. What I found is if you want to use an indicator within a Strategy, you need to define it in the "Configuration" section for use with the Strategy Analyzer. I don't know what happens when you use it directly within the "OnUpdate()" function.

            Some indicators you might need to explicitly add the dataseries to use "BarsArray[0]" for example.

            So something like this in State.Configure:

            myInd = myInd(BarsArray[0],...,...,...);

            Comment


              #7
              Hello,

              This does not seem to be matching the NT7 expected outcome for exposed variables, so I have submitted this to development for review.

              Once I have an update I will post back but for now this is now being looked into.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Hi,

                I have installed version 3 of the closed beta and I'm glad to report that the problem I was experiencing is now resolved.

                suprsnipes.

                Comment


                  #9
                  Thanks for following up and lettings us know.
                  MatthewNinjaTrader Product Management

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pmachiraju, 11-01-2023, 04:46 AM
                  8 responses
                  148 views
                  0 likes
                  Last Post rehmans
                  by rehmans
                   
                  Started by mattbsea, Today, 05:44 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post mattbsea  
                  Started by RideMe, 04-07-2024, 04:54 PM
                  6 responses
                  33 views
                  0 likes
                  Last Post RideMe
                  by RideMe
                   
                  Started by tkaboris, Today, 05:13 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post tkaboris  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  16 responses
                  3,282 views
                  0 likes
                  Last Post Leafcutter  
                  Working...
                  X