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

Code block "inhibits" indicator

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

    Code block "inhibits" indicator

    This code block functions perfectly, unfortunately any indicator I use it in can no longer be referenced for public vars!

    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);
    Anybody got a clue?
    Last edited by Sleeping Troll; 04-07-2010, 01:23 PM.

    #2
    Sleeping Troll,

    Suggest you break it down further. Find the exact line in question. You should also try looking for conflicts in your variable names. And based on your prior posts with how you are making variables public, I wouldn't suggest making them public in that fashion. Instead I would recommend you keep everything private and just expose properties for the variables you wish to have accessible. Please see this reference demonstrating this concept: http://www.ninjatrader-support2.com/...ead.php?t=4991
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      This is where it crashes.
      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];
                  [COLOR=Red]H90.Set(((HighPrice-OpenPrice) * .90)+OpenPrice);[/COLOR]
      //            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);
      The sole reason for the existence of this script is to provide these values.
      Originally this block was being accessed via an indicator which plotted a diagram, I will probably return to that scenario if I can ever figure out why that simple line of code keeps any indicator from sharing any values.
      Last edited by Sleeping Troll; 04-07-2010, 02:39 PM.

      Comment


        #4
        Suggest you simplify the code and just try setting any value to your DataSeries. I want to reiterate again that you should try to expose properties for your variables and not the variables themself.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          When I initially encountered the problem I tried assigning the dataseries values to statics. I must reiterate that the presence of this code disables access to all publics, even the ones I could previously access.

          Comment


            #6
            The line in red causes the problem...

            Comment


              #7
              Sleeping Troll,

              That line by itself does not signify any issues. You will have to debug along the lines suggested with your public variables which were created with an improper technique to begin with.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                I have tried them as static vars and as dataseries... Regardless if they are correct or not if they do not create an error why would previosly accessible values not be accessible any longer!

                Comment


                  #9
                  Sleeping Troll,

                  It has to do with some relationship in your code that only you can debug. Unfortunately all I can do is tell you areas of interest which raise red flags in my eyes. You can try for yourself with a single exposed parameter and a DataSeries. Setting a value to a DataSeries would not cause the exposed parameter to be inaccessible. This is what the reference sample I linked you to earlier does and all exposed parameters were still accessible despite setting values to a BoolSeries.

                  What I would suggest is to strip it all down to a single variable and a single DataSeries/Plot/etc.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    I have tried making them plots, I have tried making them bare dataseries, I have tried making them simple double, I have tried assigning their values to seperate public vars... I have tried and tried and tried... Look at this script:

                    Code:
                            protected override void Initialize()
                            {
                                CalculateOnBarClose    = true;
                                Overlay                = true;
                                PriceTypeSupported    = false;
                                  Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "F90"));
                                Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "F78"));
                                Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "F62"));
                                Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "F50"));
                                Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "F38"));
                                Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "F22"));
                                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "F10"));
                                D62 = new DataSeries(this);
                                D38 = new DataSeries(this);
                            }
                    
                            /// <summary>
                            /// Called on each bar update event (incoming tick)
                            /// </summary>
                            protected override void OnBarUpdate()
                            {
                                if (CurrentBar <1)return;
                                if (Historical)return;
                                F90.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .9) + BegyHunniewellPeaks().CurrentPeakLow);
                                 DrawText("F90Text","90%",0,((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .9) + BegyHunniewellPeaks().CurrentPeakLow,Color.Black);
                                   F78.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .78) + BegyHunniewellPeaks().CurrentPeakLow);
                                 DrawText("F78Text","78%",0,((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .78) + BegyHunniewellPeaks().CurrentPeakLow,Color.Black);
                                F62.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .618) + BegyHunniewellPeaks().CurrentPeakLow);
                                 DrawText("F62Text","62%",0,((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .618) + BegyHunniewellPeaks().CurrentPeakLow,Color.Black);
                                F50.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .5) + BegyHunniewellPeaks().CurrentPeakLow);
                                 DrawText("F50Text","50%",0,((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .5) + BegyHunniewellPeaks().CurrentPeakLow,Color.Black);
                                F38.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .382) + BegyHunniewellPeaks().CurrentPeakLow);
                                 DrawText("F38Text","38%",0,((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .382) + BegyHunniewellPeaks().CurrentPeakLow,Color.Black);
                                F22.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .22) + BegyHunniewellPeaks().CurrentPeakLow);
                                 DrawText("F22Text","22%",0,((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .22) + BegyHunniewellPeaks().CurrentPeakLow,Color.Black);
                                F10.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .1) + BegyHunniewellPeaks().CurrentPeakLow);
                                 DrawText("F10Text","10%",0,((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .1) + BegyHunniewellPeaks().CurrentPeakLow,Color.Black);
                                D62.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .618) + BegyHunniewellPeaks().CurrentPeakLow + (TickSize * 2));
                                D38.Set(((BegyHunniewellPeaks().CurrentPeakHigh - BegyHunniewellPeaks().CurrentPeakLow) * .382) + BegyHunniewellPeaks().CurrentPeakLow - (TickSize * 2));
                                DrawRegion("Forbidden"+CurrentBar, CurrentBar, 1, D62, D38, Color.Empty, Color.LightCoral, 2);            
                                [COLOR=Red]RefTime = DateTime.Now.AddDays(-1);
                                bAgo=GetBar(new DateTime(RefTime.Year,RefTime.Month,RefTime.Day,16,30,00));
                                SubjectBar = HighestBar(High,bAgo);
                                HighPrice = High[SubjectBar];
                                SubjectBar = LowestBar(Low,bAgo);
                                LowPrice = Low[SubjectBar];
                                OpenPrice = Open[bAgo];
                                H90.Set(((HighPrice-OpenPrice) * .78)+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);[/COLOR]
                            }
                    The dataseries in red are no different from those in black, they are created the same way, in fact the ones in black were created by NinjaTrader as they are plots. If I comment out the area in red, the F90 etc. vars are accessible as public. If I uncomment the single line:
                    H90.Set(((HighPrice-OpenPrice) * .78)+OpenPrice);

                    none of the publics in the script are exposed, or rather I should say, they all return "0".

                    This is how they are currently created:
                    Code:
                    [COLOR=Red]
                            [COLOR=Black][Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                            public DataSeries F10
                            {
                                get { return Values[6]; }
                            }
                    
                            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                            private DataSeries H90
                            {
                                get { return Values[7]; }
                            }[/COLOR][/COLOR]


                    note: the F10 series was created by ninja script when I assigned it as a plot, I made H90...L90 private just to see if it helped, no joy!

                    Comment


                      #11
                      Sleeping Troll, is there any simplified version showing the issue at hand I could run on my end?

                      What I don't understand why you need a private property for the H90...it's either a public one you can plot / access etc or just a internal private dataseries without the need to get into the properties region at all to use it normally.

                      Thanks
                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bubblegum, 03-18-2024, 10:41 AM
                      4 responses
                      51 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by kujista, Yesterday, 12:39 AM
                      3 responses
                      15 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by Yasharandom, 05-04-2024, 07:45 AM
                      2 responses
                      24 views
                      0 likes
                      Last Post Yasharandom  
                      Started by francesjandujar, Today, 05:15 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post francesjandujar  
                      Started by francesjandujar, Today, 05:14 AM
                      0 responses
                      0 views
                      0 likes
                      Last Post francesjandujar  
                      Working...
                      X