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

DrawLine Help

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

    #31
    If this is not what you ment, but you were refering to how to capturing the different signals whilst they are forming, wouldn't that be possible by lets say having 3+ different plots? So if we have a setup that starts forming whilst an other setup is forming we would be able to capture both of these? For example if we get a series of 5 consecutive lower lows, that would create 3 different trigger levels on my chart. But at this moment, with the proposed code, we would be capturing only the first forming trigger, that would be also the less likely to trade, if you immagine 5 identical consecutive lower low bars.

    Have a look at my last uploaded graphic rappresentation. As you see on the chart currenly we are missing out some important long entries. Probably i am not expressing myself properly, but to sum up what i want to be able to capute are all those green trigger levels rerted on the left hand side chart.
    Last edited by sburtt; 02-19-2013, 12:57 AM.

    Comment


      #32
      Originally posted by sburtt View Post
      Code:
      However, if you do as you say, how then do you handle your overlapping setups?
      Wouldn't this be possible by simply checking the market position before going long, and ignoring the trigger levels when the position is already long, by handling only single entries? Something like this:

      Code:
      if (Position.MarketPosition == MarketPosition.Flat)
      You asked for an indicator to give you levels that you would use to trade a strategy. Right now I thought that you were focused on how to pass capture and pass relevant data to from your indicator to your strategy.

      I should think that your strategy proposed methods are a different kettle of fish. But yes, checking your current position is always a good idea.

      Comment


        #33
        Originally posted by sburtt View Post
        If this is not what you ment, but you were refering to how to capturing the different signals whilst they are forming, wouldn't that be possible by lets say having 3+ different plots? So if we have a setup that starts forming whilst an other setup is forming we would be able to capture both of these? For example if we get a series of 5 consecutive lower lows, that would create 3 different trigger levels on my chart. But at this moment, with the proposed code, we would be capturing only the first forming trigger, that would be also the less likely to trade, if you immagine 5 identical consecutive lower low bars.
        The problem here is that you seem to be thinking in very specific terms, without taking into account that your data will not behave as you expect. What if you have 8 consecutive lower lows for example. Now you have only 3 Plots. What then? That is why I said that you would have to predefine your Plots. How many? I have no idea.

        Have a look at my last uploaded graphic rappresentation. As you see on the chart currenly we are missing out some important long entries. Probably i am not expressing myself properly, but to sum up what i want to be able to capute are all those green trigger levels rerted on the left hand side chart.
        That sounds contradictory. You say you want to see old levels to 5 bars, and at the same time you are complaining that doing so means that you do not see the new levels. I specifically said you would either see "most recent", or "first in progress". You asked how to see "first in progress" which I showed you. I had already shown you "most recent", which will show you all levels as they develop, on the natural assumption that old levels become irrelevant as soon as a new setup develops.

        I explained to you that if you want to visually represent all levels then you would need to use lines (as you do not know beforehand now many Plots you might need), and if you wanted information of the all levels then you needed to make arrangements to store the values and retrieve them.


        There is really little more that I can say, beyond what I have already said, which I summarize below.
        1. Draw the levels.
        2. If you want to handle all levels including those that have been subject to a new setup, then store the levels in an ArrayList.
        3. Remove stale entries (those that have lasted for 5 bars, according to your description).
        4. Pass the ArrayList to the Strategy, so that it knows what levels are to be used.
        5. Let the Strategy read and use those levels as needed.
        There are multiple ways to implement the code. It simply depends on your coding style and preferences. You must have an overall framework within which your code is designed. That is what I have endeavored to explain. The implementation details are up to you, and how you prefer to write your code.

        OTOH, if you want to use only the most recent levels, then all you need is a Plot that you can either validate before strategy entries, or you can actually pass and use the bool mayEnterLong, as a gate, and the Plot as the entry level.
        Last edited by koganam; 02-19-2013, 03:23 AM.

        Comment


          #34
          Code:
          The problem here is that you seem to be thinking in very specific terms, without taking into account that your data will not behave as you expect. What if you have 8 consecutive lower lows for example. Now you have only 3 Plots. What then? That is why I said that you would have to predefine your Plots. How many? I have no idea.
          I might be wrong, but I think the answer is we need 5 plots and we need to use "first in progress", so each plot will not process a new setup when one is already in progress. Assume infinte consecutive lows starting to count from bar 0, in this scenario on bar3 plot0 would start forming, on bar4 plot1 will start forming, and so on. on bar7 plot0 will have drawn a segment 5bars long at the price level of bar0's high, hence on bar8 plot0 would start drawing a new segment at the price level of bar5's high, and so on. Does this make sense to you?

          Comment


            #35
            Originally posted by sburtt View Post
            Code:
            The problem here is that you seem to be thinking in very specific terms, without taking into account that your data will not behave as you expect. What if you have 8 consecutive lower lows for example. Now you have only 3 Plots. What then? That is why I said that you would have to predefine your Plots. How many? I have no idea.
            I might be wrong, but I think the answer is we need 5 plots and we need to use "first in progress", so each plot will not process a new setup when one is already in progress. Assume infinte consecutive lows starting to count from bar 0, in this scenario on bar3 plot0 would start forming, on bar4 plot1 will start forming, and so on. on bar7 plot0 will have drawn a segment 5bars long at the price level of bar0's high, hence on bar8 plot0 would start drawing a new segment at the price level of bar5's high, and so on. Does this make sense to you?
            Yes, and what about if there are 13 consecutive lows. How about 20? How about 26? The point is not how many there are, but how to account for the fact that you do not know how many there will be, so you cannot know how many Plots need to be predeclared at the design time. Again, you are focusing on minor specifics instead of the big picture of the framework in which your code will have to operate.

            Comment


              #36
              Originally posted by sburtt View Post
              Code:
              The problem here is that you seem to be thinking in very specific terms, without taking into account that your data will not behave as you expect. What if you have 8 consecutive lower lows for example. Now you have only 3 Plots. What then? That is why I said that you would have to predefine your Plots. How many? I have no idea.
              I might be wrong, but I think the answer is we need 5 plots and we need to use "first in progress", so each plot will not process a new setup when one is already in progress. Assume infinte consecutive lows starting to count from bar 0, in this scenario on bar3 plot0 would start forming, on bar4 plot1 will start forming, and so on. on bar7 plot0 will have drawn a segment 5bars long at the price level of bar0's high, hence on bar8 plot0 would start drawing a new segment at the price level of bar5's high, and so on. Does this make sense to you?
              The text that I have highlighted in green is in direct contradiction to that in blue. You say in green, to not process new startups when one is in progress, then in blue, to process each new setup while the first is still in progress.

              This is going in circles. I am going to have to disengage, as it is evident that I am failing to get you to see the holes in your descriptions.

              Comment


                #37
                Koganam, sorry if I wasted your time. Probably I should have been more clear in the first place. However I don't think that what I am trying to do is impossible. Have a look at the code below, what I was trying to accomplish is making those "Buy Line" displayed on the chart a trigger level to EnterLong

                Code:
                {
                
                    [Description("")]
                    public class aaatest : Indicator
                    {
                        #region Variables
                        private int                         plotWidth             = 2;
                        #endregion
                
                
                        protected override void Initialize()
                        {
                            CalculateOnBarClose    = true;
                            Overlay                = true;
                            PlotsConfigurable     = false;
                        }
                
                        protected override void OnBarUpdate()
                        {
                            if(CurrentBar < 10)
                                return;
                            
                            if (Low[0] < Low[1] && Low[1] < Low[2])
                            {
                                DrawLine("Buy Line" + CurrentBar, false, -1, High[2], -5, High[2], Color.Green, DashStyle.Solid, plotWidth);
                            }
                
                
                        }
                        #region Properties
                                
                
                        [Description("Width.")]
                        [Category("Plot Parameters")]
                        [Gui.Design.DisplayNameAttribute("Width")]
                        public int PlotWidth
                        {
                            get { return plotWidth; }
                            set { plotWidth = Math.Max(1, value); }
                        }
                
                        } 
                        #endregion
                    }
                Again, thanks for your patience, most appreciated

                Comment


                  #38
                  Originally posted by sburtt View Post
                  Koganam, sorry if I wasted your time. Probably I should have been more clear in the first place. However I don't think that what I am trying to do is impossible. Have a look at the code below, what I was trying to accomplish is making those "Buy Line" displayed on the chart a trigger level to EnterLong

                  Code:
                  {
                   
                      [Description("")]
                      public class aaatest : Indicator
                      {
                          #region Variables
                          private int                         plotWidth             = 2;
                          #endregion
                   
                   
                          protected override void Initialize()
                          {
                              CalculateOnBarClose    = true;
                              Overlay                = true;
                              PlotsConfigurable     = false;
                          }
                   
                          protected override void OnBarUpdate()
                          {
                              if(CurrentBar < 10)
                                  return;
                   
                              if (Low[0] < Low[1] && Low[1] < Low[2])
                              {
                                  DrawLine("Buy Line" + CurrentBar, false, -1, High[2], -5, High[2], Color.Green, DashStyle.Solid, plotWidth);
                              }
                   
                   
                          }
                          #region Properties
                   
                   
                          [Description("Width.")]
                          [Category("Plot Parameters")]
                          [Gui.Design.DisplayNameAttribute("Width")]
                          public int PlotWidth
                          {
                              get { return plotWidth; }
                              set { plotWidth = Math.Max(1, value); }
                          }
                   
                          } 
                          #endregion
                      }
                  Again, thanks for your patience, most appreciated
                  Yes it is. It is EXACTLY what I said that you would have to do if you wanted to visually show all lines. This is how I put it in a post in this thread, at 11:02AM, (yesterday) February 18, my time, "If you want to do what you are now describing, you will have to draw lines instead of a Plot. In which case you merely have to draw a line 5 bars long, at the requisite level whenever your triggerCount is greater than 1. " (emphasis added).

                  Now how are you going to reference it from the Strategy? I am looking at the entire picture of what you claim that you want to do, and how the parts fit together: you seem to be focused on each detail in isolation.
                  Last edited by koganam; 02-19-2013, 04:19 PM.

                  Comment


                    #39
                    what if in the code you first sent me we add a second plot, structured exactly as plot0, but that is based on the following condition?

                    if (Low[0] < Low[1] && Low[1] < Low[2] && Low[2] < Low[3])

                    rather than the condition if (Low[0] < Low[1] && Low[1] < Low[2]) we used for plot0?

                    How would you code this, I tried but with no success, I would appreciate if you could try this for me if it doesn't take too much time. for simplicity I've attached the code we are working on:

                    Code:
                     {
                            #region Variables
                            
                             private int triggerCount = 0;
                            private int triggerBar = -1;
                            private int entryKillBar = -1;
                            private bool mayEnterLong = false;
                            private double plotValue = 0;
                    
                            #endregion
                    
                            protected override void Initialize()
                            {
                            Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot0"));
                            Overlay = true;
                            }
                            
                            
                            protected override void OnBarUpdate()
                            {
                            if (CurrentBar < 2) return;
                            
                            //check Trigger condition
                            this.triggerCount = (Low[0] < Low[1]) ? this.triggerCount + 1 : 0;
                            if (this.triggerCount >= 2) this.mayEnterLong = true;
                            
                            if (this.triggerCount == 2)
                            {
                            this.triggerBar = CurrentBar;
                            this.entryKillBar = CurrentBar + 5;
                            this.plotValue = High[2];
                            }
                            
                            if (CurrentBar == this.entryKillBar + 1)
                            {
                            this.triggerBar = -1;
                            this.entryKillBar = -1;
                            this.mayEnterLong = false;
                            }
                            
                            if (CurrentBar > this.triggerBar && CurrentBar <= this.entryKillBar)
                            {
                            Plot0.Set(this.plotValue);
                            }
                            else
                            {
                            Plot0.Reset();
                            }
                            }
                            
                            #region Properties    
                     
                            [Browsable(false)]
                            [XmlIgnore()]
                            public DataSeries Plot0
                            {
                                get { return Values[0]; }
                            }
                            
                            #endregion
                        }
                    }

                    Comment


                      #40
                      Originally posted by sburtt View Post
                      what if in the code you first sent me we add a second plot, structured exactly as plot0, but that is based on the following condition?

                      if (Low[0] < Low[1] && Low[1] < Low[2] && Low[2] < Low[3])

                      rather than the condition if (Low[0] < Low[1] && Low[1] < Low[2]) we used for plot0?

                      How would you code this, I tried but with no success, I would appreciate if you could try this for me if it doesn't take too much time. for simplicity I've attached the code we are working on:

                      Code:
                       {
                              #region Variables
                       
                               private int triggerCount = 0;
                              private int triggerBar = -1;
                              private int entryKillBar = -1;
                              private bool mayEnterLong = false;
                              private double plotValue = 0;
                       
                              #endregion
                       
                              protected override void Initialize()
                              {
                              Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot0"));
                              Overlay = true;
                              }
                       
                       
                              protected override void OnBarUpdate()
                              {
                              if (CurrentBar < 2) return;
                       
                              //check Trigger condition
                              this.triggerCount = (Low[0] < Low[1]) ? this.triggerCount + 1 : 0;
                              if (this.triggerCount >= 2) this.mayEnterLong = true;
                       
                              if (this.triggerCount == 2)
                              {
                              this.triggerBar = CurrentBar;
                              this.entryKillBar = CurrentBar + 5;
                              this.plotValue = High[2];
                              }
                       
                              if (CurrentBar == this.entryKillBar + 1)
                              {
                              this.triggerBar = -1;
                              this.entryKillBar = -1;
                              this.mayEnterLong = false;
                              }
                       
                              if (CurrentBar > this.triggerBar && CurrentBar <= this.entryKillBar)
                              {
                              Plot0.Set(this.plotValue);
                              }
                              else
                              {
                              Plot0.Reset();
                              }
                              }
                       
                              #region Properties    
                       
                              [Browsable(false)]
                              [XmlIgnore()]
                              public DataSeries Plot0
                              {
                                  get { return Values[0]; }
                              }
                       
                              #endregion
                          }
                      }
                      I do not code just to see what happens. I design code to do a specific objective. Therefore, I see little point in writing that code. The issue is not whether it is possible to use multiple plots to provide multiple levels: the issue is that Plots MUST be defined at design time, and so as you do not know at design time how many Plots will be needed, (because future runtime data is indeterminate), there is no way to know how many Plots to predefine.

                      Once again, instead of looking at the context in which the code will run, it would seem that you are focusing on the single minute detail of whether it is possible to use a second Plot in ONE PARTICULAR scenario, which corresponds to exactly only one runtime scenario. Yes, it is, yet given the context, it is also apropos of nothing.
                      Last edited by koganam; 02-19-2013, 03:50 PM.

                      Comment


                        #41
                        I might be wrong, but I am quite sure the answer is the one I stated earlier, we need 5 plots. It's crystal clear in my head what the indicator should do, and you can visually represent this buy testing the code I quoted Today at 02:15 P. The conditions for each of the 5 plots should be:

                        Plot0
                        (Low[0] < Low[1] && Low[1] < Low[2])

                        Plot1
                        if (Low[0] < Low[1] && Low[1] < Low[2] && Low[2] < Low[3])

                        Plot2
                        if (Low[0] < Low[1] && Low[1] < Low[2] && Low[2] < Low[3] && Low[3] < Low[4])

                        Plot3
                        if (Low[0] < Low[1] && Low[1] < Low[2] && Low[2] < Low[3] && Low[3] < Low[4] && Low[4] < Low[5])

                        Plot4
                        if (Low[0] < Low[1] && Low[1] < Low[2] && Low[2] < Low[3] && Low[3] < Low[4] && Low[4] < Low[5] && Low[5] < Low[6])

                        If each plot uses "first in progress", if we get an other lower low, at that point plot0 will start printing a new line (as it currently is doing in the code you've sent me) and so on. I think this should work

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by techgetgame, Yesterday, 11:42 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post techgetgame  
                        Started by sephichapdson, Yesterday, 11:36 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post sephichapdson  
                        Started by bortz, 11-06-2023, 08:04 AM
                        47 responses
                        1,613 views
                        0 likes
                        Last Post aligator  
                        Started by jaybedreamin, Yesterday, 05:56 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        20 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Working...
                        X