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

Indicator within an indicator not updating

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

    Indicator within an indicator not updating

    I've created an indicator that is designed to function as a widget for use in other indicators. The indicator has no Set() value, instead it has public methods that return studies to the indicator utilizing it. The problem I'm having is that the widget indicator doesn't seem to update along with the indicator using it within its code. The widget functions as expected when used by itself. Here is an example of how I'm trying to implement it:
    Last edited by darckeen; 04-08-2009, 04:43 AM.

    #2
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest1 : Indicator[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
     
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] count;[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT] 
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Overlay = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]PriceTypeSupported = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT] 
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]count++;[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT] 
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] GetUpdateCount() [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{[/SIZE][/FONT]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] count;[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT]}
    Last edited by darckeen; 04-08-2009, 04:31 AM.

    Comment


      #3
      Code:
      [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest2 : Indicator[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
       
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest1 test1;[/SIZE][/FONT][/SIZE][/FONT]
       
      [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
      [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]Overlay = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]PriceTypeSupported = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]test1 = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest1();[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
       
      [/SIZE][/FONT]
      [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CurrentBar==Bars.Count-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) {[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Test1 Update Count: "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + test1.GetUpdateCount());[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}[/SIZE][/FONT]
      [/SIZE][/FONT]

      Comment


        #4
        The output is: Test1 Update Count: 0

        Which is indicating that test1 is not updating at all. I had assumed it would update whenever test2 updated since i've created an instance of test1 when test2 intialized. How can I get test1 to update when test2 updates?

        Comment


          #5
          I am wondering whether this concept has any chance to operate as desired, darckeen. Consider that you do not instantiate your main indicator 'BAMTest2' yourself. It is instantiated and registered by the parent class 'Indicator'. You instantiate class 'BAMTest1' yourself but it is not registerend by 'Indicator' and for that reason most likely not triggered.

          Regards
          Ralph

          Comment


            #6
            darckeen,

            If you just want to create some functions I suggest you use UserDefinedMethods. http://www.ninjatrader-support.com/H...tml?Overview45
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Well the widget indicator is too complicated to be implicated as a single function and is dependent on the sequence of the data series. My inspriation for arranging it as an indicator using another indicator came from looking at the AutoTrendline() indicator you published. In it you used a method call from the Swing() indicator to pick the points and then used them in the Autotrendline() indicator. I was trying to do something similar to that. I guess i'll have to look more closely at Swing() and figure out how its data is up to date when AutoTrendline() calls methods from it.

              Comment


                #8
                So after looking at the methods in Swing I figured out that they utilize Update() to get synced with the data from the calling indicator. Also the calling indicator doesn't declare an instance of the widget indcator instead it uses a call to a static method i think? dunno, not so sharp with c. Anyways this code will work as intended:

                Code:
                [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest1 : Indicator {[/SIZE][/FONT][/SIZE][/FONT]
                [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]private int count;[/SIZE][/FONT][/SIZE][/FONT]
                [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()
                {
                count++;
                }
                [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] GetUpdateCount() {
                Update();
                [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] count;
                }
                [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]}
                 
                [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest2 : Indicator {[/SIZE][/FONT][/SIZE][/FONT]
                [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()
                {
                [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CurrentBar==Bars.Count-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) { [/SIZE][/FONT][/SIZE][/FONT]
                [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Print([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Test1 Update Count: "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + BAMTest1().GetUpdateCount());}
                }
                [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}
                
                [/SIZE][/FONT][/SIZE][/FONT]

                Comment


                  #9
                  Originally posted by darckeen View Post
                  ...they utilize Update() to get synced with the data from the calling indicator...
                  I learned something, Thanks darckeen.

                  Comment


                    #10
                    So now my question is there anyway i can call methods from another indicator from an instance of the the indicator or can i only call it from the constructor? The reason I ask is that i'd like to have two instances of the indicator running off different PriceTypes within an indicator.

                    Code:
                    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]testhigh = BAMTest1();
                    testhigh.PriceType = PriceType.High;
                    
                    testlow = BAMTest1();
                    testlow.PriceType = PriceType.Low;
                    [/SIZE][/FONT][/SIZE][/FONT]
                    This code compiles but both variables are referencing the same instance of BAMTest1 so they can't have seperate PriceTypes.

                    Comment


                      #11
                      You have to instantiate with the new-operator. Or is it just a typo in your code example?

                      Regards
                      Ralph

                      Comment


                        #12
                        darckeen,

                        had again a look at the automatically created appendix at the end of each custom-indicator. What you refer to in your last sample code is a public method of base class 'Indicator' (testhigh = BAMTest1()) This method returns an instance of your indicator BAMTest1, which is stored in a private indicator-array. You always refer to the same instance of your indicator, as long as you request it with the same parameter-set (in your case empty brackets).

                        Regards
                        Ralph

                        Comment


                          #13
                          Cool Ralph i'll have to take a look at what that auto generated stuff does and try to get a better idea how it works. As far as instacing the widget indicator with a new statement it doesn't work. It complies but the Update method will no longer function properly.

                          Comment


                            #14
                            What if you accept to use a single BAMTest1-instance but with the price type as a parameter? You wouldn't refer to the instance directly but return the result of a BAMTest1-calculation based on the parameter value:
                            Code:
                            resultHigh = BAMTest1(PriceType.High);
                            resultLow = BAMTest1(PriceType.Low);

                            Regards
                            Ralph

                            Comment


                              #15
                              Well that would work if it were a simple calculation, however the method returns an array of data that builds on previous points in the data series. So to be accurate they'd need to be separate instances or reanalyse all the data everytime its updated. Really at this point I think the easiest way to program a widget type indicator is to encapsulate it in its own class, pass it the Indicator in the constructor to give it access to nt variables, and give it an update method that fires in the OnBarUpdate of the indicator using it. Cuts a little overhead since it doesn't inherit all the indicator stuff and gives you better control over instancing whenever your using it.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by trimpy, Today, 04:38 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by dpolyakov, 03-29-2024, 11:30 AM
                              4 responses
                              150 views
                              2 likes
                              Last Post NinjaTrader_RyanS  
                              Started by traderqz, Today, 12:06 AM
                              1 response
                              2 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by kujista, Today, 06:23 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Pattontje, Yesterday, 02:10 PM
                              2 responses
                              34 views
                              0 likes
                              Last Post Pattontje  
                              Working...
                              X