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

i cant figure out timespan

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

    #16
    Hello tkaboris,

    The code you posted in post # 3 is not an indicator class.

    This is a custom class that is not an indicator. (There might be an indicator included with the package, but the code you posted is not it)

    That method requires you to supply the double lowerPrice to the method call.

    public FVG(string tag, FVGType type, double lowerPrice, double uppperPrice, DateTime gapStartTime)

    This is something you would supply to this method and not something that it would provide from the method that I can see.

    It is not a public property of an indicator.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      There is a link to download indicator in post 3 from ecosystem.
      I will see if i can try to get to values from the strategy.

      Comment


        #18
        Would creating Plots first will help?
        because right now nothing gets plotted in datawindow

        Comment


          #19
          Hello tkaboris,

          Looking at the file from the User App Share, I see FVG is a custom class that is being used in a public list.

          [Browsable(false)]
          [XmlIgnore()]
          public List<FVG> FVGList
          {
          get { return new List<FVG>(fvgList); }
          }​

          I also see that Update() is not being called in the getter.

          Call Update(); in the getter before returning the new list.

          With a list or collection, an index would need to be used.

          For example to get the first element.

          Print(FVGList[0].lowerPrice);
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            I changed FVG from private to public
            public List<FVG> fvgList = new List<FVG>();

            With this code its not printing anything in the strategy. Did it work on your end?
            when i print .count it prints 0 at all times.

            protected override void OnBarUpdate()
            {
            if(CurrentBar < 10)
            return;
            if (fvgIndicator != null && fvgIndicator.FVGList.Count > 0)
            {
            Print(fvgIndicator.FVGList[0].lowerPrice);
            }
            // Print(fvgIndicator.fvgs.Last);
            // if (fvgIndicator != null && fvgIndicator.FVGList.Count > 0)
            // {

            // }
            }​
            Last edited by tkaboris; 09-11-2023, 02:53 PM.

            Comment


              #21
              Hello tkaboris,

              Have you called Update() as directed?

              To understand the behavior it would be necessary to debug the indicator by adding prints to confirm that after calling Update() the indicator is adding elements to the list.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22
                I wasnt sure where to put Update.
                I put it here but nothing prints
                Click image for larger version

Name:	image.png
Views:	68
Size:	38.3 KB
ID:	1268437

                Comment


                  #23
                  Would it be possible if you can show me an exaple of how to addplots to plot lowerPrice and uppperPrice

                  Comment


                    #24
                    Hello tkaboris,

                    Below is a link to sample code of adding plots and setting the value.
                    I'm trying to expose my variables to the strategy builder so everyone can have better use of the WaveTrend indicator (it has a lot of code). Explain this to me like I am 5 because this isnt the first time I've tried to figure it out and hit a wall. What is Series? I know its like an array that stores bars. Why not just call it


                    Call Update() from the getter of FVGList as advised in post # 12.

                    public List<FVG> FVGList
                    get {
                    Update();
                    return new List<FVG>(fvgList); }

                    The help guide provides sample code. See the code example for the TripleValue public property.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      I have updated to include Update(): and in prints, strategy prints only one same instance

                      Print("last lower price:"+fvgIndicator.FVGList[0].lowerPrice);
                      Print("last upper price:"+fvgIndicator.FVGList[0].upperPrice);​
                      Prints below. it only prints teh same value, even though new ones formed already many times. .Count method print updated consecutive values it seems. What does this mean?

                      last lower price:15383
                      last upper price:15384​

                      public List<FVG> FVGList
                      {

                      get {
                      Update();
                      return new List<FVG>(fvgList); }
                      }​
                      Last edited by tkaboris; 09-12-2023, 09:29 AM.

                      Comment


                        #26
                        Hello tkaboris,

                        This is a C# list.

                        A list can be looped through.

                        DotNetPerls provides a tutorial and sample code.
                        Create a new List, add elements to it, and loop over its elements with for and foreach.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          in indicator code i have added plots and foreach loop, it complains that it cant convert to double. I am not sure if i am doing it right but again I need to access last or before last occurences and values of upperPrice and lowerPrice values... If i change forlop to int, it still cant conver to Int
                          public List<FVG> fvgList = new List<FVG>();

                          protected override void OnBarUpdate()
                          {
                          // Only operate on selected data series type
                          if (BarsInProgress != iDataSeriesIdx || CurrentBars[iDataSeriesIdx] < 4) return;

                          if (FVGList.Count > 0)
                          {
                          MyPlot1[0] = FVGList[0].lowerPrice;
                          MyPlot2[0] = FVGList[0].upperPrice;
                          }
                          foreach (double prime in fvgList)
                          {
                          System.Console.WriteLine("PRIME ELEMENT: {0}", prime);
                          }

                          ​​Click image for larger version  Name:	image.png Views:	0 Size:	43.7 KB ID:	1268577
                          Last edited by tkaboris; 09-12-2023, 10:31 AM.

                          Comment


                            #28
                            Hello tkaboris,

                            The lowerPrice would be a double. The list itself is holding FVG class objects.

                            Is this code from the host script or the hosted FVGICT indicator?

                            If this is the host script, the indicator is saved to the fvgIndicator variable correct?

                            Try:
                            Code:
                            foreach (FVG fvg in fvgIndicator.FVGList)
                            {
                            Print("fvg.lowerPrice: " + fvg.lowerPrice);
                            }
                            Or you can use indexes
                            Code:
                            for (int index = 0; index < fvgIndicator.FVGList.Count(); index++)
                            {
                            Print(string.Format("index: {0}: fvgIndicator.FVGList[{0}].lowerPrice: {1}", index, fvgIndicator.FVGList[index].lowerPrice));
                            }
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #29
                              I am not sure but indicator is not hosted, its just from ecosystem.
                              I am able to print below in indicator code
                              foreach (FVG fvg in FVGList)
                              {
                              Print("fvg.lowerPrice: " + fvg.lowerPrice);

                              }​

                              but when i am in strategy, i cant print the code it says fvg not in the context
                              Click image for larger version

Name:	image.png
Views:	46
Size:	483.3 KB
ID:	1268601​​
                              Attached Files

                              Comment


                                #30
                                Hello tkaboris,

                                fvgIndicator.FVGList[index].lowerPrice


                                A strategy that calls an indicator is a host to that hosted indicator (symbiont).

                                The same is true of an indicator that calls another indicator. The host indicator calls the hosted indicator.
                                Chelsea B.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by cre8able, Today, 01:35 PM
                                0 responses
                                2 views
                                0 likes
                                Last Post cre8able  
                                Started by martin70, Today, 04:06 AM
                                6 responses
                                14 views
                                0 likes
                                Last Post martin70  
                                Started by morleyc, Today, 11:37 AM
                                3 responses
                                11 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by Uregon, Today, 12:55 PM
                                1 response
                                4 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by RaddiFX, Today, 11:26 AM
                                3 responses
                                12 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Working...
                                X