Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Values returned from inicator, not what expected

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

    Values returned from inicator, not what expected

    I am at the end of a very lengthy project and am stumped by this little problem.

    Because it is a very lengthy project I will provide snippets with explanations.

    The first snippet is where I assign fib values based on the Day Open - High and Open - Low, there are also Year, Month and Week HLO's in the same array as the Day values, so Day is referenced as [3] alias [CanNumber].

    This Snippet is from Indicator "Begy_Hunniewell_Ladders".

    Code:
                         H90Price[CanNumber] = ((Canhigh[CanNumber]-Canopen[CanNumber]) *  .90)+Canopen[CanNumber];
                        H78Price[CanNumber] =  ((Canhigh[CanNumber]-Canopen[CanNumber]) * .78)+Canopen[CanNumber];
                         H62Price[CanNumber] =  ((Canhigh[CanNumber]-Canopen[CanNumber]) * .618)+Canopen[CanNumber];
                         H50Price[CanNumber] =  ((Canhigh[CanNumber]-Canopen[CanNumber]) * .50)+Canopen[CanNumber];
                         H38Price[CanNumber] =  ((Canhigh[CanNumber]-Canopen[CanNumber]) * .382)+Canopen[CanNumber];
                         H22Price[CanNumber] =  ((Canhigh[CanNumber]-Canopen[CanNumber]) * .22)+Canopen[CanNumber];
                         H10Price[CanNumber] =  ((Canhigh[CanNumber]-Canopen[CanNumber]) * .10)+Canopen[CanNumber];
                         L10Price[CanNumber] =  ((Canopen[CanNumber]-Canlow[CanNumber]) * .10)+Canlow[CanNumber];
                         L22Price[CanNumber] =  ((Canopen[CanNumber]-Canlow[CanNumber]) * .22)+Canlow[CanNumber];
                         L38Price[CanNumber] =  ((Canopen[CanNumber]-Canlow[CanNumber]) * .382)+Canlow[CanNumber];
                         L50Price[CanNumber] =  ((Canopen[CanNumber]-Canlow[CanNumber]) * .50)+Canlow[CanNumber];
                         L62Price[CanNumber] =  ((Canopen[CanNumber]-Canlow[CanNumber]) * .618)+Canlow[CanNumber];
                         L78Price[CanNumber] =  ((Canopen[CanNumber]-Canlow[CanNumber]) * .78)+Canlow[CanNumber];
                         L90Price[CanNumber] =  ((Canopen[CanNumber]-Canlow[CanNumber]) * .90)+Canlow[CanNumber];
    The second snippet is where I access those values from my Strategy "BegyHunniewellLadders"

    Code:
                                         if (Input[0] > Begy_Hunniewell_Ladders().H90Price[3] + TickSize)
                                         {
                                             if (StopLong < Begy_Hunniewell_Ladders().H90Price[3] - (2 *  TickSize))StopLong = Begy_Hunniewell_Ladders().H90Price[3] - (2 *  TickSize);
                                             Print(Begy_Hunniewell_Ladders().H90Price[3] - (2 * TickSize));
                                             Print("Stop Long = " + StopLong);
                                         }
                                         if (Input[0] > Begy_Hunniewell_Ladders().H78Price[3] + TickSize)
                                         {
                                             if (StopLong < Begy_Hunniewell_Ladders().H90Price[3] - (2 *  TickSize))StopLong = Begy_Hunniewell_Ladders().H78Price[3] - (2 *  TickSize);
                                            Print("Stop Long =  " + StopLong);
                                        }
                                         if (Input[0] >  Begy_Hunniewell_Ladders().H62Price[3] + TickSize)
                                         {...
    In the Indicator "Begy_Hunniewell_Ladders" I Plot these values with DrawString (snippet 3)

    Code:
    graphics.DrawString(String.Format("{0:0.00}",H90Price[CanNumber]),  GaugeFontSmallest, textBrushR, new RectangleF( Left[CanNumber],  CurrentTop - 5,(CanLeft[CanNumber] - Left[CanNumber]),10));
    and I can visually confirm that the values are correct and in the 1150.00 range. However the debug print in my Strategy (from snippet 2) outputs .50

    Code:
    Print(Begy_Hunniewell_Ladders().H90Price[3] - (2 *  TickSize));
    I do not think I am overwhelmed with code blindness at this point, however I just cannot fathom the problem! I really hope it is something silly and I hope you can help me out, getting by this one will produce beta 1.

    #2
    This might sound silly, but...
    In your Indicator "Begy_Hunniewell_Ladders" if you have a line in Initialize()
    CalculateOnBarClose = true;

    Remove that line and try again.

    Comment


      #3
      Actually, that makes sense, Let me check that!
      Nope it is false, good thinking though!

      Comment


        #4
        Originally posted by Sleeping Troll View Post
        Actually, that makes sense, Let me check that!
        Nope it is false, good thinking though!
        even if it is false, try to completeley remove that line

        Comment


          #5
          Still, "No joy". If it makes a diff the value returned is -0.5 which is 0 - 2 ticks, it would appear that H90Price is being returned as a zero value.

          Comment


            #6
            Originally posted by Sleeping Troll View Post
            Still, "No joy". If it makes a diff the value returned is -0.5 which is 0 - 2 ticks, it would appear that H90Price is being returned as a zero value.
            Well I don't know then... What type is H90Price? DataSeries? Some array?
            How is it declared in properties section? Do you use any other custom indicators inside it?

            Comment


              #7
              public double
              I have discovered that removing the CalculateOnBarClose line causes a plot error in Begy_Hunniewell_Ladders, which of course would result in "0" values being returned. If that is the problem it looms very large...
              Last edited by Sleeping Troll; 04-06-2010, 11:12 PM.

              Comment


                #8
                Originally posted by Sleeping Troll View Post
                public double
                it cannot be just double since you have index [3].
                Anyway in property getter you can try to call Update() method

                public DataSeries HPrice90
                {
                get { Update(); return whatever_you_returning; }
                }

                I am running out of ideas here. Something else in your code could be causing this outside of snippets you have provided.

                Comment


                  #9
                  Thx for the effort, will try later this am, going to fall out now :O
                  Code:
                          public double[] H90Price = new double[20];
                          public double[] H78Price = new double[20];
                          public double[] H62Price = new double[20];
                          public double[] H50Price = new double[20];
                          public double[] H38Price = new double[20];
                          public double[] H22Price = new double[20];
                          public double[] H10Price = new double[20];
                          public double[] L10Price = new double[20];
                          public double[] L22Price = new double[20];
                          public double[] L38Price = new double[20];
                          public double[] L50Price = new double[20];
                          public double[] L62Price = new double[20];
                          public double[] L78Price = new double[20];
                          public double[] L90Price = new double[20];

                  Comment


                    #10
                    I gave up on Begy_Hunniewell_Ladders and wrote this simple script to provide my fibs:

                    Code:
                            #region Variables
                            private int SubjBar;
                            private DateTime TOI;
                            private int barsAgo;
                            public double OpenPrice;
                            public double HighPrice;
                            public double LowPrice;
                            public double H90Price;
                            public double H78Price;
                            public double H62Price;
                            public double H50Price;
                            public double H38Price;
                            public double H22Price;
                            public double H10Price;
                            public double L10Price;
                            public double L22Price;
                            public double L38Price;
                            public double L50Price;
                            public double L62Price;
                            public double L78Price;
                            public double L90Price;
                            #endregion
                    
                     
                            protected override void Initialize()
                            {
                                CalculateOnBarClose    = false;
                                Overlay                = false;
                                PriceTypeSupported    = false;
                            }
                    
                    
                            protected override void OnBarUpdate()
                            {
                                            if (CurrentBar < 0)return;
                                            TOI = Time[0].AddDays(-1) ;
                                            barsAgo=GetBar(new DateTime(TOI.Year,TOI.Month,TOI.Day,16,30,00));
                                            SubjBar = HighestBar(High,barsAgo);
                                            HighPrice = High[SubjBar];
                                            SubjBar = LowestBar(Low,barsAgo);
                                            LowPrice = Low[SubjBar];
                                            OpenPrice = Open[barsAgo];
                                            H90Price = ((HighPrice-OpenPrice) * .90)+OpenPrice;
                                            H78Price = ((HighPrice-OpenPrice) * .78)+OpenPrice;
                                            H62Price = ((HighPrice-OpenPrice) * .618)+OpenPrice;
                                            H50Price = ((HighPrice-OpenPrice) * .50)+OpenPrice;
                                            H38Price = ((HighPrice-OpenPrice) * .382)+OpenPrice;
                                            H22Price = ((HighPrice-OpenPrice) * .22)+OpenPrice;
                                            H10Price = ((HighPrice-OpenPrice) * .10)+OpenPrice;
                                            L10Price = ((OpenPrice-LowPrice) * .10)+LowPrice;
                                            L22Price = ((OpenPrice-LowPrice) * .22)+LowPrice;
                                            L38Price = ((OpenPrice-LowPrice) * .382)+LowPrice;
                                            L50Price = ((OpenPrice-LowPrice) * .50)+LowPrice;
                                            L62Price = ((OpenPrice-LowPrice) * .618)+LowPrice;
                                            L78Price = ((OpenPrice-LowPrice) * .78)+LowPrice;
                                            L90Price = ((OpenPrice-LowPrice) * .90)+LowPrice;
                            }
                        }
                    }
                    Guess what?... Same problem! Somebody please help me to figure this out, I am at wits end!
                    Last edited by Sleeping Troll; 04-07-2010, 06:35 AM.

                    Comment


                      #11
                      I believe you access the wrong values, try printing those variables to check into if they return what you would expect -

                      Code:
                      TOI = Time[0].AddDays(-1) ;
                                              barsAgo=GetBar(new DateTime(TOI.Year,TOI.Month,TOI.Day,16,30,00));
                                              SubjBar = HighestBar(High,barsAgo);
                                              HighPrice = High[SubjBar];
                                              SubjBar = LowestBar(Low,barsAgo);
                                              LowPrice = Low[SubjBar];
                                              OpenPrice = Open[barsAgo];
                      I would also split up SubjBar into two, one for the highs and one for the lows, this might create an issues with the returned values in your script.

                      Comment


                        #12
                        Yeah, wish it were that simple, the values returned are "0", If you get the time refer to the rest of the post, thx.

                        Comment


                          #13
                          If you like, contact me please at support at ninjatrader dot com Attn Bertrand and I will give your code a run here and see what I can spot.

                          Comment


                            #14
                            My code is 4 indicators and 1 strategy...
                            I have found where the culprit lies though, When I use the following block of code in any script, I can no longer retrieve values from that script!
                            Code:
                                        TOI = Time[0].AddDays(-1);
                                        barsAgo=GetBar(new DateTime(TOI.Year,TOI.Month,TOI.Day,16,30,00));
                                        SubjBar = HighestBar(High,barsAgo);
                                        HighPrice = High[SubjBar];
                                        SubjBar = LowestBar(Low,barsAgo);
                                        LowPrice = Low[SubjBar];
                                        OpenPrice = Open[barsAgo];
                                        H90.Set(((HighPrice-OpenPrice) * .90)+OpenPrice);
                                        H78.Set(((HighPrice-OpenPrice) * .78)+OpenPrice);
                                        H62.Set(((HighPrice-OpenPrice) * .618)+OpenPrice);
                                        H50.Set(((HighPrice-OpenPrice) * .50)+OpenPrice);
                                        H38.Set(((HighPrice-OpenPrice) * .382)+OpenPrice);
                                        H22.Set(((HighPrice-OpenPrice) * .22)+OpenPrice);
                                        H10.Set(((HighPrice-OpenPrice) * .10)+OpenPrice);
                                        L10.Set(((OpenPrice-LowPrice) * .10)+LowPrice);
                                        L22.Set(((OpenPrice-LowPrice) * .22)+LowPrice);
                                        L38.Set(((OpenPrice-LowPrice) * .382)+LowPrice);
                                        L50.Set(((OpenPrice-LowPrice) * .50)+LowPrice);
                                        L62.Set(((OpenPrice-LowPrice) * .618)+LowPrice);
                                        L78.Set(((OpenPrice-LowPrice) * .78)+LowPrice);
                                        L90.Set(((OpenPrice-LowPrice) * .90)+LowPrice);
                            ???

                            Comment


                              #15
                              Sleeping Troll,

                              Which line exactly is the line in question? I suggest you try breaking it down further and isolating which step exactly is giving you issues.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              661 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              375 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              110 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              580 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X