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 Disapears

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

    Indicator Disapears

    Hi, my indicator disapears after refreshing, im trying to call a stochastic from a moving average indi, ive done this kind of things before so i thought i had it figured out , gess not..lol,

    this is the code:

    ... Variables

    private DataSeries stochD;
    private DataSeries stochFifty;

    ....protected override void Initialize()

    stochD = new DataSeries(this);
    stochFifty = new DataSeries(this);

    .... protected override void OnBarUpdate()

    {
    double maValue = 0;
    switch (matype)
    {
    case 1:
    {
    Middle.Set(maValue = EMA(Inputs[0], Period)[0]);
    break;
    }
    case 2:
    {
    Middle.Set(maValue = HMA(Inputs[0], Period)[0]);
    break;

    (................................................. ............................)


    stochD.Set(KBT_Stochastics(Close,5,8,5).D[0]);
    stochFifty.Set(KBT_Stochastics(Close,5,8,5).Middle Line[0]);




    if ( (Middle[0] > Middle[3 ]) && (stochD[0] < stochFifty[0] ) )
    {
    if (showStochRegionAlerts) DrawRegion(............ );
    }


    after compiling and refreshing the window the entire thing disappears.. i been here before..

    help please

    #2
    Hello kabott,

    Do you see any error inside the Log tab of the Control Center?

    Typically, when an indicator displays then disappears there is an error, and most commonly it is due to referencing a value that is not defined yet. Programmatically, I do not see anything wrong with your code. Are you checking to make sure you have enough bars for your calculations?

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

    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      hi JC , yes says "Error On bar update,On bar 125: Index Out of matrix limits"

      Comment


        #4
        How do i fix it? Do you need me to post the indicator?

        Comment


          #5
          Hello kabott,

          With the code currently that you have posted I would not be able to tell what may be going on.

          You can either post it if you like or send a *toy* NinjaScript code replicating the behavior to Support[at]NinjaTrader[dot]com so that I may point you in the right direction.


          Happy to be of further assistance.

          *Toy* - a basic form of the code that isn't necessarily the whole logic. Making it easier to identify the lines of code.
          JCNinjaTrader Customer Service

          Comment


            #6
            Here it is, JC
            Last edited by kabott; 08-21-2012, 07:12 PM.

            Comment


              #7
              Hello kabott,

              Thanks for those files.

              I am not familiar with the KBTxStochastics() indicator, and that being so I commented these two lines of code and did not receive that error:

              Code:
              stochD.Set(KBTxStochastics(Close,5,8,5).D[0]);
              stochFifty.Set(KBTxStochastics(Close,5,8,5).MiddleLine[0]);
              Taking a further look into it, you are trying to access KBTxStochastics()'s MiddleLine value. Lines are not meant to be a dynamic value, which I believe is the reason why you are accessing it. If you want to access a dynamic value you would want to access a Plot() like D or K inside KBTxStochastics().

              Did you create the KBTxStochastics() indicator?


              Happy to be of further assistance.
              JCNinjaTrader Customer Service

              Comment


                #8
                Hi JC , i really dont remember were i got it, but it was a simple stochastic, i added the KBT in front because i was planing to experiment with it latter and i have too many lol

                So ,anyways, if want to measure wen "D" goes under the middle line (value 50) can i do it like this?

                if ( (Middle[0] > Middle[3 ]) && (stochD[0] < 50 ) )
                {
                if (showStochRegionAlerts) DrawRegion(............ );
                }

                Comment


                  #9
                  OK THAT WORKS, and now i understand why i didnt before , thanks very much JC

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by JonesJoker, 04-22-2024, 12:23 PM
                  8 responses
                  41 views
                  0 likes
                  Last Post JonesJoker  
                  Started by timko, Today, 06:45 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post timko
                  by timko
                   
                  Started by Waxavi, 04-19-2024, 02:10 AM
                  2 responses
                  37 views
                  0 likes
                  Last Post poeds
                  by poeds
                   
                  Started by chbruno, Yesterday, 04:10 PM
                  1 response
                  44 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by Max238, Today, 01:28 AM
                  1 response
                  25 views
                  0 likes
                  Last Post CactusMan  
                  Working...
                  X