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.
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!
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
NinjaTrader
DrawLine Help
Collapse
X
-
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.
-
Originally posted by sburtt View PostCode:However, if you do as you say, how then do you handle your overlapping setups?
Code:if (Position.MarketPosition == MarketPosition.Flat)
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
-
Originally posted by sburtt View PostIf 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.
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.- Draw the levels.
- If you want to handle all levels including those that have been subject to a new setup, then store the levels in an ArrayList.
- Remove stale entries (those that have lasted for 5 bars, according to your description).
- Pass the ArrayList to the Strategy, so that it knows what levels are to be used.
- Let the Strategy read and use those levels as needed.
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
-
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.
Comment
-
Originally posted by sburtt View PostCode: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.
Comment
-
Originally posted by sburtt View PostCode: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.
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
-
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 }
Comment
-
Originally posted by sburtt View PostKoganam, 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 }
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
-
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
-
Originally posted by sburtt View Postwhat 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 } }
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
-
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
by techgetgame
Yesterday, 11:42 PM
|
||
Started by sephichapdson, Yesterday, 11:36 PM
|
0 responses
2 views
0 likes
|
Last Post Yesterday, 11:36 PM | ||
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,613 views
0 likes
|
Last Post
by aligator
Yesterday, 07:22 PM
|
||
Started by jaybedreamin, Yesterday, 05:56 PM
|
0 responses
10 views
0 likes
|
Last Post
by jaybedreamin
Yesterday, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
20 views
0 likes
|
Last Post
by DJ888
Yesterday, 05:12 PM
|
Comment