Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

i cant figure out timespan

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

    #31
    thank you for your patience...
    Its compaining in strategy.
    Click image for larger version

Name:	image.png
Views:	119
Size:	624.0 KB
ID:	1268618

    Comment


      #32
      Hello tkaboris,

      Apologies, that was copied and pasted from post # 28.

      fvgIndicator.FVGList[index].lowerPrice
      Chelsea B.NinjaTrader Customer Service

      Comment


        #33
        Thank you it works now.
        how can i find previous lowerPrice?
        if i print this, it gives out onbarupdate error its out of range
        Print(string.Format("index: {0}: fvg.start gap time previous[{0}]: {1}", index, fvgIndicator.FVGList[1].lowerPrice));

        Comment


          #34
          Hello tkaboris,

          This not a plot series. This is a List<> object.

          You can loop through the list.

          If the Count is greater than 2 you can use fvgIndicator.FVGList.Count() - 2 as the index of the second to last element.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #35
            thank you
            I think i am doing it wrong trying to access previous lowerPrice

            Code:
            for (int index = 0; index < fvgIndicator.FVGList.Count(); index++)
                        {
            //            Print(string.Format("index: {0}: fvg.start gap time previous[{0}]: {1}", index, fvgIndicator.FVGList[1].gapStartTime));
                        Print(string.Format("index: {0}: fvg.start gap time[{0}]: {1}", index, fvgIndicator.FVGList[index].gapStartTime));
                        Print(string.Format("index: {0}: fvg.type[{0}]: {1}", index, fvgIndicator.FVGList[index].type));
                        Print(string.Format("index: {0}: fvg.lowerPrice[{0}]: {1}", index, fvgIndicator.FVGList[index].lowerPrice));
                        Print(string.Format("index: {0}: fvg.upperPrice[{0}]: {1}", index, fvgIndicator.FVGList[index].upperPrice));
                        Print(string.Format("index: {0}: fvg.filled[{0}]: {1}", index, fvgIndicator.FVGList[index].filled));
                        Print(string.Format("index: {0}: fvg.fill time[{0}]: {1}", index, fvgIndicator.FVGList[index].fillTime));
                        Print(string.Format("index: {0}: fvg.tag[{0}]: {1}", index, fvgIndicator.FVGList[index].tag));
            
                            if (fvgIndicator.FVGList.Count >= 2)
                            {
                                Print("Previous");
                                Print(string.Format("index: {0}: fvg.lowerPrice[{0}]: {1}", index, fvgIndicator.FVGList[1].lowerPrice));
                            }
                        }​

            Comment


              #36
              Hello tkaboris,

              An index of [1] would be the second added FVG object to the list. (I'm not sure that would be the previous lowerPrice value. The author would know how this script's logic is designed)

              An index of [fvgIndicator.FVGList.Count() - 2] would be the second to last object added to the list.

              if (fvgIndicator.FVGList.Count() > 1)
              Print(fvgIndicator.FVGList[fvgIndicator.FVGList.Count() - 2].lowerPrice);

              This would be the index if you were trying to use it outside of a loop as you were trying to do in post # 31.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #37
                Thank you.
                When i print
                Print(string.Format("index: {0}: fvg.type[{0}]: {1}", index, fvgIndicator.FVGList[index].type));

                it prints type R for resistnace or S for support

                index: 13: fvg.type[13]: R

                I need to evaluate if recent levels is of type R or S, but it gives error. I tried differnt ways but still cant get it to evaluate correctly
                if ((fvgIndicator.FVGList[index].type = "R")
                && High[1] > fvgIndicator.FVGList[index].lowerPrice
                )
                {
                EnterShort(1, "Short");
                }

                From indicaotor S R are enums
                public enum FVGType
                {
                S, R
                }​
                public FVGType type;
                Can you please help?
                ​​Click image for larger version  Name:	image.png Views:	0 Size:	346.0 KB ID:	1268712
                Last edited by tkaboris; 09-12-2023, 07:05 PM.

                Comment


                  #38
                  if (fvgIndicator.FVGList[index].type == FVGType.R && High[1] > fvgIndicator.FVGList[index].lowerPrice)
                  {

                  }

                  Comment


                    #39
                    Thank you when i implement that it throws an error. its not seeing FVGType
                    FVGType does not exist in current context.
                    Last edited by tkaboris; 09-13-2023, 04:57 AM.

                    Comment


                      #40
                      You need to write full path where FVGType located. Open file where FVGType is defined and hover you mouse over it's name. You will see full namespace path. Something like "Ninjatrader.Indicators.....". Add this path before your FVGType.R and add dot. Like this "Ninjatrader.Indicators.SomeIndicator.FVGType. R".

                      Comment


                        #41
                        Or just add that namespace at start of your code with "using" word.

                        Comment


                          #42
                          Thank you again.

                          Can you also help me to access opposite upperPrice level, so i can create a condition to avoid if levels from S and R are too close.
                          Currently Print("opposite upper"); is not reached when entered short



                          Code:
                          for (int index = 0; index < fvgIndicator.FVGList.Count(); index++)
                                      {
                                          Print("================================");
                          //            Print(string.Format("index: {0}: fvg.start gap time previous[{0}]: {1}", index, fvgIndicator.FVGList[1].gapStartTime));
                                      Print(string.Format("index: {0}: fvg.start gap time[{0}]: {1}", index, fvgIndicator.FVGList[index].gapStartTime));
                                      Print(string.Format("index: {0}: fvg.type[{0}]: {1}", index, fvgIndicator.FVGList[index].type));
                          
                                      Print(string.Format("index: {0}: fvg.lowerPrice[{0}]: {1}", index, fvgIndicator.FVGList[index].lowerPrice));
                                      Print(string.Format("index: {0}: fvg.upperPrice[{0}]: {1}", index, fvgIndicator.FVGList[index].upperPrice));
                                      Print(string.Format("index: {0}: fvg.filled[{0}]: {1}", index, fvgIndicator.FVGList[index].filled));
                                      Print(string.Format("index: {0}: fvg.fill time[{0}]: {1}", index, fvgIndicator.FVGList[index].fillTime));
                                      Print(string.Format("index: {0}: fvg.tag[{0}]: {1}", index, fvgIndicator.FVGList[index].tag));
                                      Print("================================");
                          
                                      if (fvgIndicator.FVGList[index].type == NinjaTrader.NinjaScript.Indicators.FVGICT.FVGType.R
                                          && High[0] > fvgIndicator.FVGList[index].lowerPrice && Close[0] < Open[0])
                          
                          
                          
                                      {
                                          EnterShort(1, "Short");
                                          Print("Entering Short");
                                          if (fvgIndicator.FVGList.Count() > 2 && fvgIndicator.FVGList[index].type == NinjaTrader.NinjaScript.Indicators.FVGICT.FVGType.S)
                                              {
                                                  Print("opposite upper");
                                                  Print(fvgIndicator.FVGList[fvgIndicator.FVGList.Count() - 2].upperPrice);                
                                              }
                                      }
                                      }​
                          Output: example

                          ================================
                          index: 14: fvg.start gap time[14]: 8/30/2023 7:48:00 AM
                          index: 14: fvg.type[14]: S
                          index: 14: fvg.lowerPrice[14]: 15394.25
                          index: 14: fvg.upperPrice[14]: 15397
                          index: 14: fvg.filled[14]: False
                          index: 14: fvg.fill time[14]: 1/1/0001 12:00:00 AM
                          index: 14: fvg.tag[14]: FVGUP_c2410df2-b611-491e-925e-302585d7da4d_4966
                          ================================​

                          Click image for larger version  Name:	image.png Views:	0 Size:	10.1 KB ID:	1268832
                          Last edited by tkaboris; 09-13-2023, 10:36 AM.

                          Comment


                            #43
                            >Currently Print("opposite upper"); is not reached when entered short

                            Because you put "if" inside other "if". First one requires type == FVGType.R but second one requires type == FVGICT.FVGType.S with the same index. It's not possible.

                            ​You probably need to segregate S from R because you can't do that in single loop. But I'm not sure.

                            Comment


                              #44
                              right i think we first need to loop through FVGList to find upperprice but maybe there could ne a nested loop to loop through List to find last type S..

                              @NinjaTrader_ChelseaB

                              Comment


                                #45
                                Hello tkaboris,

                                It is possible to put a loop in another loop if you want this custom logic.

                                Below is a link to a 3rd party educational site on nested loops.
                                A nested loop in c# states that a loop inside another loop where the inner loop executes completely for each iteration of the outer loop. The following section shows a few examples to illustrate the nested loops ?


                                "Currently Print("opposite upper"); is not reached when entered short"

                                This would mean one of the conditions is not evaluating as true.

                                Print the values in the conditions with labels for the values and labels for the comparison operators so we can see how these are being compared.
                                Chelsea B.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                559 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                324 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                546 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                547 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X